Example
A sample implementation and usage of the sap.ve.dvl.DecryptionHandler interface with the asmCrypto library.
...
<script src="http://vibornoff.com/asmcrypto.js"></script>
...
var decryptionHandler = {
deriveKey: function(salt, password) {
try {
return asmCrypto.PBKDF2_HMAC_SHA256.bytes(password, salt, 10000, 16);
} catch (ex) {
return null;
}
},
decrypt: function(key, iv, input) {
try {
return asmCrypto.AES_CBC.decrypt(input, key, true, iv);
} catch (ex) {
return null;
}
}
};
...
var dvl = ...
dvl.Client.setDecryptionHandler(decryptionHandler);
...
Methods
decrypt(key, iv, encryptedData) → {Uint8Array}
Parameters:
Name | Type | Description |
---|---|---|
key |
object | The derived key generated by the previous call to sap.ve.dvl.DecryptionHandler.deriveKey. |
iv |
Uint8Array | The 128-bit initialization vector. |
encryptedData |
Uint8Array | The encrypted buffer. |
Returns:
The decrypted buffer.
- Type
- Uint8Array
deriveKey(salt, password) → {object}
Generates a cryptographic session key derived from a base data value.
The key must be derived with the PBKDF2 algorithm by applying the
HMAC-SHA256
function 10,000 times.
The resulting 128-bit key should be passed to subseqeunt calls to sap.ve.dvl.DecryptionHandler.decrypt.
Parameters:
Name | Type | Description |
---|---|---|
salt |
Uint8Array | Random data that is used as an additional input to a one-way function that "hashes" a password or passphrase. |
password |
Uint8Array | A password used for encryption/decryption. |
Returns:
A derived 128-bit key that should be passed to subsequent calls to sap.ve.dvl.DecryptionHandler.decrypt.
- Type
- object