Constructor
new SubtleCrypto()
The SubtleCrypto class provides low-level cryptographic primitives and algorithms.
WebCrypto API reference http://www.w3.org/TR/WebCryptoAPI/#subtlecrypto-interface
- Source:
Methods
-
decrypt(algorithm, key, data) → {Promise}
-
The decrypt method returns a new Promise object that will decrypt data using the specified algorithm identifier with the supplied Key. WebCrypto API reference http://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-decrypt
Supported algorithm names:- GOST 28147-ECB "prostaya zamena" (ECB) mode (default)
- GOST 28147-CFB "gammirovanie s obratnoj svyaziyu po shifrotekstu" (CFB) mode
- GOST 28147-OFB "gammirovanie s obratnoj svyaziyu po vyhodu" (OFB) mode
- GOST 28147-CTR "gammirovanie" (counter) mode
- GOST 28147-CBC Cipher-Block-Chaining (CBC) mode
- GOST R 34.12-ECB "prostaya zamena" (ECB) mode (default)
- GOST R 34.12-CFB "gammirovanie s obratnoj svyaziyu po shifrotekstu" (CFB) mode
- GOST R 34.12-OFB "gammirovanie s obratnoj svyaziyu po vyhodu" (OFB) mode
- GOST R 34.12-CTR "gammirovanie" (counter) mode
- GOST R 34.12-CBC Cipher-Block-Chaining (CBC) mode
Parameters:
Name Type Description algorithmAlgorithmIdentifier Algorithm identifier keyKey Key object dataCryptoOperationData Operation data - Source:
Returns:
Promise that resolves with CryptoOperationData- Type
- Promise
-
deriveBits(algorithm, baseKey, length) → {Promise}
-
The deriveBits method returns length bits on baseKey using the specified algorithm identifier. WebCrypto API reference http://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-deriveBits
Supported algorithm names:- GOST R 34.10-DH ECDH Key Agreement mode
- GOST R 34.11-KDF Key for Derivation Algorithm
- GOST R 34.11-PBKDF2 Password Based Key for Derivation Algorithm
- GOST R 34.11-PFXKDF PFX Key for Derivation Algorithm
- GOST R 34.11-CPKDF Password Based Key for CryptoPro Derivation Algorithm
- SHA-PBKDF2 Password Based Key for Derivation Algorithm
- SHA-PFXKDF PFX Key for Derivation Algorithm
Parameters:
Name Type Description algorithmAlgorithmIdentifier Algorithm identifier baseKeyKey Derivation key object lengthnumber Length bits - Source:
Returns:
Promise that resolves with CryptoOperationData- Type
- Promise
-
deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages) → {Promise}
-
The deriveKey method returns a new Promise object that will key(s) using the specified algorithm identifier. Key can be used in according with KeyUsage sequence. The recognized key usage values are "encrypt", "decrypt", "sign", "verify", "deriveKey", "deriveBits", "wrapKey" and "unwrapKey". WebCrypto API reference http://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-deriveKey
Supported algorithm names:- GOST R 34.10-DH ECDH Key Agreement mode
- GOST R 34.11-KDF Key for Derivation Algorithm
- GOST R 34.11-PBKDF2 Password Based Key for Derivation Algorithm
- GOST R 34.11-PFXKDF PFX Key for Derivation Algorithm
- GOST R 34.11-CPKDF Password Based Key for CryptoPro Derivation Algorithm
- SHA-PBKDF2 Password Based Key for Derivation Algorithm
- SHA-PFXKDF PFX Key for Derivation Algorithm
Parameters:
Name Type Description algorithmAlgorithmIdentifier Algorithm identifier baseKeyKey Derivation key object derivedKeyTypeAlgorithmIdentifier Derived key algorithm identifier extractableboolean Whether or not the raw keying material may be exported by the application keyUsagesKeyUsages Key usage array: type of operation that may be performed using a key - Source:
Returns:
Promise that resolves with Key- Type
- Promise
-
digest(algorithm, data) → {Promise}
-
The digest method returns a new Promise object that will digest data using the specified algorithm identifier. WebCrypto API reference http://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-digest
Supported algorithm names:- GOST R 34.11-94 Old-Style GOST Hash
- GOST R 34.11 GOST Streebog Hash
- SHA SHA Hash
Parameters:
Name Type Description algorithmAlgorithmIdentifier Algorithm identifier dataCryptoOperationData Operation data - Source:
Returns:
Promise that resolves with CryptoOperationData- Type
- Promise
-
encrypt(algorithm, key, data) → {Promise}
-
The encrypt method returns a new Promise object that will encrypt data using the specified algorithm identifier with the supplied Key. WebCrypto API reference http://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-encrypt
Supported algorithm names:- GOST 28147-ECB "prostaya zamena" (ECB) mode (default)
- GOST 28147-CFB "gammirovanie s obratnoj svyaziyu po shifrotekstu" (CFB) mode
- GOST 28147-OFB "gammirovanie s obratnoj svyaziyu po vyhodu" (OFB) mode
- GOST 28147-CTR "gammirovanie" (counter) mode
- GOST 28147-CBC Cipher-Block-Chaining (CBC) mode
- GOST R 34.12-ECB "prostaya zamena" (ECB) mode (default)
- GOST R 34.12-CFB "gammirovanie s obratnoj svyaziyu po shifrotekstu" (CFB) mode
- GOST R 34.12-OFB "gammirovanie s obratnoj svyaziyu po vyhodu" (OFB) mode
- GOST R 34.12-CTR "gammirovanie" (counter) mode
- GOST R 34.12-CBC Cipher-Block-Chaining (CBC) mode
Parameters:
Name Type Description algorithmAlgorithmIdentifier Algorithm identifier keyKey Key object dataCryptoOperationData Operation data - Source:
Returns:
Promise that resolves with CryptoOperationData- Type
- Promise
-
exportKey(format, key) → {Promise}
-
The exportKey method returns a new Promise object that will key data in defined format.
The suppored key format values are:- 'raw' - An unformatted sequence of bytes. Intended for secret keys.
- 'pkcs8' - The DER encoding of the PrivateKeyInfo structure from RFC 5208.
- 'spki' - The DER encoding of the SubjectPublicKeyInfo structure from RFC 5280.
Supported algorithm names:- GOST R 34.10-94 GOST Private and Public keys
- GOST R 34.10 ECGOST Private and Public keys
- GOST 28147 Key for encryption GOST 28147 modes
- GOST 28147-KW Key for key wrapping GOST 28147 modes
- GOST R 34.12 Key for encryption GOST R 34.12 modes
- GOST R 34.12-KW Key for key wrapping GOST R 34.12 modes
- GOST R 34.11-KDF Key for Derivation Algorithm
- GOST R 34.11-PBKDF2 Import Password for Key for Derivation Algorithm
- GOST R 34.11-PFXKDF Import PFX Key for Derivation Algorithm
- GOST R 34.11-CPKDF Import Password Key for CryptoPro Derivation Algorithm
- SHA-PBKDF2 Import Password for Key for Derivation Algorithm
- SHA-PFXKDF Import PFX Key for Derivation Algorithm
Parameters:
Name Type Description formatKeyFormat Format specifies a serialization format for a key keyKey Key object - Source:
Returns:
Promise that resolves with CryptoOperationData- Type
- Promise
-
generateKey(algorithm, extractable, keyUsages) → {Promise}
-
The generateKey method returns a new Promise object that will key(s) using the specified algorithm identifier. Key can be used in according with KeyUsages sequence. The recognized key usage values are "encrypt", "decrypt", "sign", "verify", "deriveKey", "deriveBits", "wrapKey" and "unwrapKey". WebCrypto API reference http://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-generateKey
Supported algorithm names:- GOST R 34.10 ECGOST Key Pairs
- GOST 28147 Key for encryption GOST 28147 modes
- GOST 28147-KW Key for wrapping GOST 28147 modes
- GOST R 34.12 Key for encryption GOST R 34.12 modes
- GOST R 34.12-KW Key for wrapping GOST R 34.12 modes
- GOST R 34.11-KDF Key for Derivation Algorithm
Note: Generation key for GOST R 34.10-94 not supported.Parameters:
Name Type Description algorithmAlgorithmIdentifier Key algorithm identifier extractableboolean Whether or not the raw keying material may be exported by the application keyUsagesKeyUsages Key usage array: type of operation that may be performed using a key - Source:
Returns:
- Type
- Promise
-
importKey(format, keyData, algorithm, extractable, keyUsages) → {Promise}
-
The importKey method returns a new Promise object that will key(s) using the specified algorithm identifier. Key can be used in according with KeyUsage sequence. The recognized key usage values are "encrypt", "decrypt", "sign", "verify", "deriveKey", "deriveBits", "wrapKey" and "unwrapKey".
Parameter keyData contains data in defined format. The suppored key format values are:- 'raw' - An unformatted sequence of bytes. Intended for secret keys.
- 'pkcs8' - The DER encoding of the PrivateKeyInfo structure from RFC 5208.
- 'spki' - The DER encoding of the SubjectPublicKeyInfo structure from RFC 5280.
Supported algorithm names:- GOST R 34.10-94 GOST Private and Public keys
- GOST R 34.10 ECGOST Private and Public keys
- GOST 28147 Key for encryption GOST 28147 modes
- GOST 28147-KW Key for key wrapping GOST 28147 modes
- GOST R 34.12 Key for encryption GOST 34.12 modes
- GOST R 34.12-KW Key for key wrapping GOST 34.12 modes
- GOST R 34.11-KDF Key for Derivation Algorithm
Parameters:
Name Type Description formatKeyFormat Key format Format specifies a serialization format for a key keyDataCryptoOperationData algorithmAlgorithmIdentifier Key algorithm identifier extractableboolean Whether or not the raw keying material may be exported by the application keyUsagesKeyUsages Key usage array: type of operation that may be performed using a key - Source:
Returns:
Promise that resolves with Key- Type
- Promise
-
sign(algorithm, key, data) → {Promise}
-
The sign method returns a new Promise object that will sign data using the specified algorithm identifier with the supplied Key. WebCrypto API reference http://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-sign
Supported algorithm names:- GOST R 34.10-94 GOST Signature
- GOST R 34.10-94/GOST R 34.11-94 GOST Signature with Hash
- GOST R 34.10 ECGOST Signature
- GOST R 34.10/GOST R 34.11-94 ECGOST Signature with Old-Style Hash
- GOST R 34.10/GOST R 34.11 ECGOST Signature with Streebog Hash
- GOST 28147-MAC MAC base on GOST 28147
- GOST R 34.12-MAC MAC base on GOST R 43.12
- GOST R 34.11-HMAC HMAC base on GOST 34.11
- SHA-HMAC HMAC base on SHA
Parameters:
Name Type Description algorithmAlgorithmIdentifier Algorithm identifier keyKey Key object dataCryptoOperationData Operation data - Source:
Returns:
Promise that resolves with CryptoOperationData- Type
- Promise
-
unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages) → {Promise}
-
The unwrapKey method returns a new Promise object that will unwrapped key(s). WebCrypto API reference http://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-unwrapKey
Supported algorithm names:- GOST 28147-KW Key Wrapping GOST 28147 modes
- GOST R 34.12-KW Key Wrapping GOST R 34.12 modes
- GOST 28147-MASK Key Mask GOST 28147 modes
- GOST R 34.12-MASK Key Mask GOST R 34.12 modes
- GOST R 34.10-MASK Key Mask GOST R 34.10 modes
Parameters:
Name Type Description formatKeyFormat Format specifies a serialization format for a key. Now suppored only 'raw' key format. wrappedKeyCryptoOperationData Wrapped key data unwrappingKeyKey Unwrapping key object unwrapAlgorithmAlgorithmIdentifier Algorithm identifier unwrappedKeyAlgorithmAlgorithmIdentifier Key algorithm identifier extractableboolean Whether or not the raw keying material may be exported by the application keyUsagesKeyUsages Key usage array: type of operation that may be performed using a key - Source:
Returns:
Promise that resolves with Key- Type
- Promise
-
verify(algorithm, key, signature, data) → {Promise}
-
The verify method returns a new Promise object that will verify data using the specified algorithm identifier with the supplied Key. WebCrypto API reference http://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-verify
Supported algorithm names:- GOST R 34.10-94 GOST Signature
- GOST R 34.10-94/GOST R 34.11-94 GOST Signature with Hash
- GOST R 34.10 ECGOST Signature
- GOST R 34.10/GOST R 34.11-94 ECGOST Signature with Old-Style Hash
- GOST R 34.10/GOST R 34.11 ECGOST Signature with Streebog Hash
- GOST 28147-MAC MAC base on GOST 28147
- GOST R 34.12-MAC MAC base on GOST R 34.12
- GOST R 34.11-HMAC HMAC base on GOST 34.11
- SHA-HMAC HMAC base on SHA
Parameters:
Name Type Description algorithmAlgorithmIdentifier Algorithm identifier keyKey Key object signatureCryptoOperationData Signature data dataCryptoOperationData Operation data - Source:
Returns:
Promise that resolves with boolean value of verification result- Type
- Promise
-
wrapKey(format, key, wrappingKey, wrapAlgorithm) → {Promise}
-
The wrapKey method returns a new Promise object that will wrapped key(s). WebCrypto API reference http://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-wrapKey
Supported algorithm names:- GOST 28147-KW Key Wrapping GOST 28147 modes
- GOST R 34.12-KW Key Wrapping GOST R 34.12 modes
- GOST 28147-MASK Key Mask GOST 28147 modes
- GOST R 34.12-MASK Key Mask GOST R 34.12 modes
- GOST R 34.10-MASK Key Mask GOST R 34.10 modes
Parameters:
Name Type Description formatKeyFormat Format specifies a serialization format for a key. Now suppored only 'raw' key format. keyKey Key object wrappingKeyKey Wrapping key object wrapAlgorithmAlgorithmIdentifier Algorithm identifier - Source:
Returns:
Promise that resolves with CryptoOperationData- Type
- Promise