askarKeyDeriveEcdhEs function
Implementation
AskarResult<LocalKeyHandle> askarKeyDeriveEcdhEs(
KeyAlgorithm algorithm,
LocalKeyHandle ephemeralKey,
LocalKeyHandle recipientKey,
Uint8List algId,
Uint8List apu,
Uint8List apv,
bool receive,
) {
Pointer<NativeLocalKeyHandle> outPtr = calloc<NativeLocalKeyHandle>();
Pointer<Utf8> algPointer = nullptr;
Pointer<NativeByteBuffer> algIdByteBufferPtr = nullptr;
Pointer<NativeByteBuffer> apuByteBufferPtr = nullptr;
Pointer<NativeByteBuffer> apvByteBufferPtr = nullptr;
try {
algPointer = algorithm.value.toNativeUtf8();
algIdByteBufferPtr = bytesListToByteBuffer(algId);
apuByteBufferPtr = bytesListToByteBuffer(apu);
apvByteBufferPtr = bytesListToByteBuffer(apv);
final funcResult = nativeAskarKeyDeriveEcdhEs(
algPointer,
ephemeralKey.toInt(),
recipientKey.toInt(),
algIdByteBufferPtr.ref,
apuByteBufferPtr.ref,
apvByteBufferPtr.ref,
boolToInt(receive),
outPtr,
);
final errorCode = ErrorCode.fromInt(funcResult);
final value = LocalKeyHandle.fromPointer(errorCode, outPtr);
return AskarResult<LocalKeyHandle>(errorCode, value);
} finally {
freePointer(outPtr);
freePointer(algPointer);
freeByteBufferPointer(algIdByteBufferPtr);
freeByteBufferPointer(apuByteBufferPtr);
freeByteBufferPointer(apvByteBufferPtr);
}
}