#ifndef WebCryptoAlgorithm_h
#define WebCryptoAlgorithm_h
#include "WebCommon.h"
#include "WebPrivatePtr.h"
#if INSIDE_BLINK
#include "wtf/PassOwnPtr.h"
#endif
namespace blink {
enum WebCryptoAlgorithmId {
WebCryptoAlgorithmIdAesCbc,
WebCryptoAlgorithmIdHmac,
WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
WebCryptoAlgorithmIdRsaEsPkcs1v1_5,
WebCryptoAlgorithmIdSha1,
WebCryptoAlgorithmIdSha256,
WebCryptoAlgorithmIdSha384,
WebCryptoAlgorithmIdSha512,
WebCryptoAlgorithmIdAesGcm,
WebCryptoAlgorithmIdRsaOaep,
WebCryptoAlgorithmIdAesCtr,
WebCryptoAlgorithmIdAesKw,
#if INSIDE_BLINK
WebCryptoAlgorithmIdLast = WebCryptoAlgorithmIdAesKw,
#endif
};
enum WebCryptoAlgorithmParamsType {
WebCryptoAlgorithmParamsTypeNone,
WebCryptoAlgorithmParamsTypeAesCbcParams,
WebCryptoAlgorithmParamsTypeAesKeyGenParams,
WebCryptoAlgorithmParamsTypeHmacImportParams,
WebCryptoAlgorithmParamsTypeHmacKeyGenParams,
WebCryptoAlgorithmParamsTypeRsaKeyGenParams,
WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams,
WebCryptoAlgorithmParamsTypeRsaHashedImportParams,
WebCryptoAlgorithmParamsTypeAesGcmParams,
WebCryptoAlgorithmParamsTypeRsaOaepParams,
WebCryptoAlgorithmParamsTypeAesCtrParams,
};
class WebCryptoAesCbcParams;
class WebCryptoAesKeyGenParams;
class WebCryptoHmacImportParams;
class WebCryptoHmacKeyGenParams;
class WebCryptoRsaKeyGenParams;
class WebCryptoAesGcmParams;
class WebCryptoRsaOaepParams;
class WebCryptoAesCtrParams;
class WebCryptoRsaHashedKeyGenParams;
class WebCryptoRsaHashedImportParams;
class WebCryptoAlgorithmParams;
class WebCryptoAlgorithmPrivate;
class WebCryptoAlgorithm {
public:
#if INSIDE_BLINK
WebCryptoAlgorithm() { }
BLINK_PLATFORM_EXPORT WebCryptoAlgorithm(WebCryptoAlgorithmId, PassOwnPtr<WebCryptoAlgorithmParams>);
#endif
BLINK_PLATFORM_EXPORT static WebCryptoAlgorithm createNull();
BLINK_PLATFORM_EXPORT static WebCryptoAlgorithm adoptParamsAndCreate(WebCryptoAlgorithmId, WebCryptoAlgorithmParams*);
~WebCryptoAlgorithm() { reset(); }
WebCryptoAlgorithm(const WebCryptoAlgorithm& other) { assign(other); }
WebCryptoAlgorithm& operator=(const WebCryptoAlgorithm& other)
{
assign(other);
return *this;
}
BLINK_PLATFORM_EXPORT bool isNull() const;
BLINK_PLATFORM_EXPORT WebCryptoAlgorithmId id() const;
BLINK_PLATFORM_EXPORT WebCryptoAlgorithmParamsType paramsType() const;
BLINK_PLATFORM_EXPORT const WebCryptoAesCbcParams* aesCbcParams() const;
BLINK_PLATFORM_EXPORT const WebCryptoAesKeyGenParams* aesKeyGenParams() const;
BLINK_PLATFORM_EXPORT const WebCryptoHmacImportParams* hmacImportParams() const;
BLINK_PLATFORM_EXPORT const WebCryptoHmacKeyGenParams* hmacKeyGenParams() const;
BLINK_PLATFORM_EXPORT const WebCryptoRsaKeyGenParams* rsaKeyGenParams() const;
BLINK_PLATFORM_EXPORT const WebCryptoAesGcmParams* aesGcmParams() const;
BLINK_PLATFORM_EXPORT const WebCryptoRsaOaepParams* rsaOaepParams() const;
BLINK_PLATFORM_EXPORT const WebCryptoAesCtrParams* aesCtrParams() const;
BLINK_PLATFORM_EXPORT const WebCryptoRsaHashedImportParams* rsaHashedImportParams() const;
BLINK_PLATFORM_EXPORT const WebCryptoRsaHashedKeyGenParams* rsaHashedKeyGenParams() const;
BLINK_PLATFORM_EXPORT static bool isHash(WebCryptoAlgorithmId);
private:
BLINK_PLATFORM_EXPORT void assign(const WebCryptoAlgorithm& other);
BLINK_PLATFORM_EXPORT void reset();
WebPrivatePtr<WebCryptoAlgorithmPrivate> m_private;
};
}
#endif