示例#1
0
 /// <summary>
 /// Encrypt data with the specified key, and return the result.
 /// </summary>
 /// <param name="sourceData">A byte array with the source data.</param>
 /// <param name="useSharedKey">Whether to use the Zymbit cloud key.</param>
 /// <returns>The encrypted data.</returns>
 public byte[] LockData(byte[] sourceData, bool useSharedKey = false)
 {
     NativeHelper.Validate(NativeMethods.zkLockDataB2B(_ref, sourceData, sourceData.Length, out var output, out var outputLen, useSharedKey));
     return(NativeHelper.PtrToArray(output, outputLen));
 }
示例#2
0
 /// <summary>
 /// Return the ECDSA public key at the specified slot.
 /// </summary>
 /// <param name="slot">The Zymkey slot.</param>
 /// <returns>The ECDSA public key.</returns>
 public byte[] GetEcdsaPubkey(int slot = 0)
 {
     NativeHelper.Validate(NativeMethods.zkGetECDSAPubKey(_ref, out var publicKey, out var publicKeyLen, slot));
     return(NativeHelper.PtrToArray(publicKey, publicKeyLen));
 }
示例#3
0
 /// <summary>
 /// Encrypt data from a file with the specified key, and return the result.
 /// </summary>
 /// <param name="sourceFile">The source filename.</param>
 /// <param name="useSharedKey">Whether to use the Zymbit cloud key.</param>
 /// <returns>The encrypted data.</returns>
 public byte[] LockData(string sourceFile, bool useSharedKey = false)
 {
     NativeHelper.Validate(NativeMethods.zkLockDataF2B(_ref, sourceFile, out var output, out var outputLen, useSharedKey));
     return(NativeHelper.PtrToArray(output, outputLen));
 }
示例#4
0
 /// <summary>
 /// Generate an ECDSA signature from a digest.
 /// </summary>
 /// <param name="digest">The digest to sign.</param>
 /// <param name="slot">The Zymkey key slot to use for the operation.</param>
 /// <returns>The ECDSA signature.</returns>
 public byte[] GenerateEcdsaSignatureFromDigest(byte[] digest, int slot = 0)
 {
     NativeHelper.Validate(NativeMethods.zkGenECDSASigFromDigest(_ref, digest, slot, out var output, out var outputLen));
     return(NativeHelper.PtrToArray(output, outputLen));
 }