getPayloadFor method
Implementation
@override
List<int>? getPayloadFor(
JsonWebKey? key,
JoseHeader header,
JoseRecipient recipient,
) {
if (key == null) {
return null;
}
var aad = sharedProtectedHeader?.toBase64EncodedString() ?? '';
if (additionalAuthenticatedData != null) {
aad += '.${String.fromCharCodes(additionalAuthenticatedData!)}';
}
if (header.encryptionAlgorithm == 'none') {
throw JoseException('Encryption algorithm cannot be `none`');
}
var cek = header.algorithm == 'dir'
? key
: key.unwrapKey(recipient.data, algorithm: header.algorithm);
return cek.decrypt(data,
initializationVector: initializationVector,
additionalAuthenticatedData: Uint8List.fromList(aad.codeUnits),
authenticationTag: authenticationTag,
algorithm: header.encryptionAlgorithm);
}