#ifndef CryptoKeyRSA_h
#define CryptoKeyRSA_h
#include "CryptoKey.h"
#include <functional>
#if ENABLE(SUBTLE_CRYPTO)
#if OS(DARWIN) && !PLATFORM(EFL) && !PLATFORM(GTK)
typedef struct _CCRSACryptor *CCRSACryptorRef;
typedef CCRSACryptorRef PlatformRSAKey;
#endif
namespace WebCore {
class CryptoKeyDataRSAComponents;
class CryptoKeyPair;
class PromiseWrapper;
class CryptoKeyRSA final : public CryptoKey {
public:
static PassRefPtr<CryptoKeyRSA> create(CryptoAlgorithmIdentifier identifier, CryptoKeyType type, PlatformRSAKey platformKey, bool extractable, CryptoKeyUsage usage)
{
return adoptRef(new CryptoKeyRSA(identifier, type, platformKey, extractable, usage));
}
static PassRefPtr<CryptoKeyRSA> create(CryptoAlgorithmIdentifier, const CryptoKeyDataRSAComponents&, bool extractable, CryptoKeyUsage);
virtual ~CryptoKeyRSA();
void restrictToHash(CryptoAlgorithmIdentifier);
bool isRestrictedToHash(CryptoAlgorithmIdentifier&) const;
size_t keySizeInBits() const;
typedef std::function<void(CryptoKeyPair&)> KeyPairCallback;
typedef std::function<void()> VoidCallback;
static void generatePair(CryptoAlgorithmIdentifier, unsigned modulusLength, const Vector<uint8_t>& publicExponent, bool extractable, CryptoKeyUsage, KeyPairCallback, VoidCallback failureCallback);
PlatformRSAKey platformKey() const { return m_platformKey; }
private:
CryptoKeyRSA(CryptoAlgorithmIdentifier, CryptoKeyType, PlatformRSAKey, bool extractable, CryptoKeyUsage);
virtual CryptoKeyClass keyClass() const override { return CryptoKeyClass::RSA; }
virtual void buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&) const override;
virtual std::unique_ptr<CryptoKeyData> exportData() const override;
PlatformRSAKey m_platformKey;
bool m_restrictedToSpecificHash;
CryptoAlgorithmIdentifier m_hash;
};
inline bool isCryptoKeyRSA(const CryptoKey& key)
{
return key.keyClass() == CryptoKeyClass::RSA;
}
CRYPTO_KEY_TYPE_CASTS(CryptoKeyRSA)
}
#endif // ENABLE(SUBTLE_CRYPTO)
#endif // CryptoKeyRSA_h