private static bool TryExecuteTransform( ReadOnlySpan <byte> source, Span <byte> destination, out int bytesWritten, SecKeyTransform transform) { SafeCFDataHandle outputHandle; SafeCFErrorHandle errorHandle; int ret = transform(source, out outputHandle, out errorHandle); using (errorHandle) using (outputHandle) { switch (ret) { case kSuccess: return(CoreFoundation.TryCFWriteData(outputHandle, destination, out bytesWritten)); case kErrorSeeError: throw CreateExceptionForCFError(errorHandle); default: Debug.Fail($"transform returned {ret}"); throw new CryptographicException(); } } }
private static byte[] ExecuteTransform(ReadOnlySpan <byte> source, SecKeyTransform transform) { const int Success = 1; const int kErrorSeeError = -2; SafeCFDataHandle data; SafeCFErrorHandle error; int ret = transform(source, out data, out error); using (error) using (data) { if (ret == Success) { return(CoreFoundation.CFGetData(data)); } if (ret == kErrorSeeError) { throw CreateExceptionForCFError(error); } Debug.Fail($"transform returned {ret}"); throw new CryptographicException(); } }