namespace webcrypto {
class CryptoData;
+class GenerateKeyResult;
class Status;
// AlgorithmImplementation is a base class for *executing* the operations of an
const CryptoData& data,
std::vector<uint8_t>* buffer) const;
- // VerifyKeyUsagesBeforeGenerateKey() must be called prior to
- // GenerateSecretKey() to validate the requested key usages.
- virtual Status VerifyKeyUsagesBeforeGenerateKey(
- blink::WebCryptoKeyUsageMask usage_mask) const;
-
- // This method corresponds to Web Crypto's crypto.subtle.generateKey().
- virtual Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm,
- bool extractable,
- blink::WebCryptoKeyUsageMask usage_mask,
- blink::WebCryptoKey* key) const;
-
- // VerifyKeyUsagesBeforeGenerateKeyPair() must be called prior to
- // GenerateKeyPair() to validate the requested key usages.
- virtual Status VerifyKeyUsagesBeforeGenerateKeyPair(
- blink::WebCryptoKeyUsageMask combined_usage_mask,
- blink::WebCryptoKeyUsageMask* public_usage_mask,
- blink::WebCryptoKeyUsageMask* private_usage_mask) const;
-
// This method corresponds to Web Crypto's crypto.subtle.generateKey().
- virtual Status GenerateKeyPair(
- const blink::WebCryptoAlgorithm& algorithm,
- bool extractable,
- blink::WebCryptoKeyUsageMask public_usage_mask,
- blink::WebCryptoKeyUsageMask private_usage_mask,
- blink::WebCryptoKey* public_key,
- blink::WebCryptoKey* private_key) const;
+ //
+ // Implementations MUST verify |usages| and return an error if it is not
+ // appropriate.
+ virtual Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm,
+ bool extractable,
+ blink::WebCryptoKeyUsageMask usages,
+ GenerateKeyResult* result) const;
// -----------------------------------------------
// Key import
// ImportKeyJwk() must do the final usage check.
virtual Status VerifyKeyUsagesBeforeImportKey(
blink::WebCryptoKeyFormat format,
- blink::WebCryptoKeyUsageMask usage_mask) const;
+ blink::WebCryptoKeyUsageMask usages) const;
// This method corresponds to Web Crypto's
// crypto.subtle.importKey(format='raw').
virtual Status ImportKeyRaw(const CryptoData& key_data,
const blink::WebCryptoAlgorithm& algorithm,
bool extractable,
- blink::WebCryptoKeyUsageMask usage_mask,
+ blink::WebCryptoKeyUsageMask usages,
blink::WebCryptoKey* key) const;
// This method corresponds to Web Crypto's
virtual Status ImportKeyPkcs8(const CryptoData& key_data,
const blink::WebCryptoAlgorithm& algorithm,
bool extractable,
- blink::WebCryptoKeyUsageMask usage_mask,
+ blink::WebCryptoKeyUsageMask usages,
blink::WebCryptoKey* key) const;
// This method corresponds to Web Crypto's
virtual Status ImportKeySpki(const CryptoData& key_data,
const blink::WebCryptoAlgorithm& algorithm,
bool extractable,
- blink::WebCryptoKeyUsageMask usage_mask,
+ blink::WebCryptoKeyUsageMask usages,
blink::WebCryptoKey* key) const;
// This method corresponds to Web Crypto's
virtual Status ImportKeyJwk(const CryptoData& key_data,
const blink::WebCryptoAlgorithm& algorithm,
bool extractable,
- blink::WebCryptoKeyUsageMask usage_mask,
+ blink::WebCryptoKeyUsageMask usages,
blink::WebCryptoKey* key) const;
// -----------------------------------------------