askarKeyUnwrapKey function
Implementation
AskarResult<LocalKeyHandle> askarKeyUnwrapKey(
LocalKeyHandle handle,
KeyAlgorithm algorithm,
Uint8List ciphertext, {
Uint8List? nonce,
Uint8List? tag,
}) {
Pointer<NativeLocalKeyHandle> out = calloc<NativeLocalKeyHandle>();
Pointer<Utf8> algPtr = nullptr;
Pointer<NativeByteBuffer> cipherByteBufferPtr = nullptr;
Pointer<NativeByteBuffer> nonceByteBufferPtr = nullptr;
Pointer<NativeByteBuffer> tagByteBufferPtr = nullptr;
try {
algPtr = algorithm.value.toNativeUtf8();
cipherByteBufferPtr = bytesListToByteBuffer(ciphertext);
nonceByteBufferPtr = bytesListToByteBuffer(nonce);
tagByteBufferPtr = bytesListToByteBuffer(tag);
final funcResult = nativeAskarKeyUnwrapKey(
handle.toInt(),
algPtr,
cipherByteBufferPtr.ref,
nonceByteBufferPtr.ref,
tagByteBufferPtr.ref,
out,
);
final errorCode = ErrorCode.fromInt(funcResult);
final value = LocalKeyHandle.fromPointer(errorCode, out);
return AskarResult<LocalKeyHandle>(errorCode, value);
} finally {
freePointer(out);
freePointer(algPtr);
freeByteBufferPointer(cipherByteBufferPtr);
freeByteBufferPointer(nonceByteBufferPtr);
freeByteBufferPointer(tagByteBufferPtr);
}
}