#ifndef WebCryptoKeyAlgorithm_h
#define WebCryptoKeyAlgorithm_h
#include "WebCommon.h"
#include "WebCryptoAlgorithm.h"
#include "WebCryptoKeyAlgorithmParams.h"
#include "WebPrivatePtr.h"
#if INSIDE_BLINK
#include "wtf/PassOwnPtr.h"
#endif
namespace blink {
class WebCryptoKeyAlgorithmPrivate;
class WebCryptoKeyAlgorithm {
public:
WebCryptoKeyAlgorithm() { }
#if INSIDE_BLINK
BLINK_PLATFORM_EXPORT WebCryptoKeyAlgorithm(WebCryptoAlgorithmId, PassOwnPtr<WebCryptoKeyAlgorithmParams>);
#endif
BLINK_PLATFORM_EXPORT static WebCryptoKeyAlgorithm adoptParamsAndCreate(WebCryptoAlgorithmId, WebCryptoKeyAlgorithmParams*);
BLINK_PLATFORM_EXPORT static WebCryptoKeyAlgorithm createAes(WebCryptoAlgorithmId, unsigned short keyLengthBits);
BLINK_PLATFORM_EXPORT static WebCryptoKeyAlgorithm createHmac(WebCryptoAlgorithmId hash, unsigned keyLengthBits);
BLINK_PLATFORM_EXPORT static WebCryptoKeyAlgorithm createRsa(WebCryptoAlgorithmId, unsigned modulusLengthBits, const unsigned char* publicExponent, unsigned publicExponentSize);
BLINK_PLATFORM_EXPORT static WebCryptoKeyAlgorithm createRsaHashed(WebCryptoAlgorithmId, unsigned modulusLengthBits, const unsigned char* publicExponent, unsigned publicExponentSize, WebCryptoAlgorithmId hash);
~WebCryptoKeyAlgorithm() { reset(); }
WebCryptoKeyAlgorithm(const WebCryptoKeyAlgorithm& other) { assign(other); }
WebCryptoKeyAlgorithm& operator=(const WebCryptoKeyAlgorithm& other)
{
assign(other);
return *this;
}
BLINK_PLATFORM_EXPORT bool isNull() const;
BLINK_PLATFORM_EXPORT WebCryptoAlgorithmId id() const;
BLINK_PLATFORM_EXPORT WebCryptoKeyAlgorithmParamsType paramsType() const;
BLINK_PLATFORM_EXPORT WebCryptoAesKeyAlgorithmParams* aesParams() const;
BLINK_PLATFORM_EXPORT WebCryptoHmacKeyAlgorithmParams* hmacParams() const;
BLINK_PLATFORM_EXPORT WebCryptoRsaKeyAlgorithmParams* rsaParams() const;
BLINK_PLATFORM_EXPORT WebCryptoRsaHashedKeyAlgorithmParams* rsaHashedParams() const;
private:
BLINK_PLATFORM_EXPORT void assign(const WebCryptoKeyAlgorithm& other);
BLINK_PLATFORM_EXPORT void reset();
WebPrivatePtr<WebCryptoKeyAlgorithmPrivate> m_private;
};
}
#endif