askarKeyWrapKey function
Implementation
AskarResult<EncryptedBuffer> askarKeyWrapKey(
LocalKeyHandle handle,
LocalKeyHandle other, {
Uint8List? nonce,
}) {
Pointer<NativeEncryptedBuffer> encryptedBufferPtr = calloc<NativeEncryptedBuffer>();
Pointer<NativeByteBuffer> byteBufferPointer = nullptr;
try {
byteBufferPointer = bytesListToByteBuffer(nonce);
final errorCode = ErrorCode.fromInt(
nativeAskarKeyWrapKey(
handle.toInt(),
other.toInt(),
byteBufferPointer.ref,
encryptedBufferPtr,
),
);
final value =
(errorCode == ErrorCode.success)
? readNativeEncryptedBuffer(encryptedBufferPtr.ref)
: EncryptedBuffer(Uint8List.fromList([]), 0, 0);
return AskarResult<EncryptedBuffer>(errorCode, value);
} finally {
freeEncryptedBufferPointer(encryptedBufferPtr);
freeByteBufferPointer(byteBufferPointer);
}
}