Пример #1
0
 /// <summary>
 /// Decrypt data with the specified key, and store the result in a file.
 /// </summary>
 /// <param name="sourceData">A byte array with the source data.</param>
 /// <param name="destFile">The destination filename.</param>
 /// <param name="useSharedKey">Whether to use the Zymbit cloud key.</param>
 public void UnlockData(byte[] sourceData, string destFile, bool useSharedKey = false)
 => NativeHelper.Validate(NativeMethods.zkUnlockDataB2F(_ref, sourceData, sourceData.Length, destFile, useSharedKey));
Пример #2
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));
 }
Пример #3
0
 /// <summary>
 /// Decrypt data from a file with the specified key, and store the result in a file.
 /// </summary>
 /// <param name="sourceFile">The source filename.</param>
 /// <param name="destFile">The destination filename.</param>
 /// <param name="useSharedKey">Whether to use the Zymbit cloud key.</param>
 public void UnlockData(string sourceFile, string destFile, bool useSharedKey = false)
 => NativeHelper.Validate(NativeMethods.zkUnlockDataF2F(_ref, sourceFile, destFile, useSharedKey));
Пример #4
0
 /// <summary>
 /// Sets the action taken when a perimeter channel is tripped.
 /// </summary>
 /// <param name="channel">The channel to set.</param>
 /// <param name="actionFlags">Bitfield of the action(s) to take.</param>
 public void SetPerimeterEventAction(int channel, uint actionFlags)
 => NativeHelper.Validate(NativeMethods.zkSetPerimeterEventAction(_ref, channel, actionFlags));
Пример #5
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));
 }
Пример #6
0
 /// <summary>
 /// Gets the perimeter detection info.
 /// </summary>
 /// <returns>The info as an array of ints.</returns>
 public int[] GetPerimeterDetectInfo()
 {
     NativeHelper.Validate(NativeMethods.zkGetPerimeterDetectInfo(_ref, out IntPtr info, out var infoCount));
     return(NativeHelper.PtrToArrayInt(info, (int)infoCount));
 }
Пример #7
0
 /// <summary>
 /// Clears the perimeter detection info and rearms all channels.
 /// </summary>
 public void ClearPerimeterDetectEvents()
 => NativeHelper.Validate(NativeMethods.zkClearPerimeterDetectEvents(_ref));
Пример #8
0
 /// <summary>
 /// Disposes the Zymkey context.
 /// </summary>
 public void Dispose()
 {
     NativeHelper.Validate(NativeMethods.zkClose(_ref));
 }
Пример #9
0
 /// <summary>
 /// Sets the sensitivity of tap operations.
 /// </summary>
 /// <param name="axis">The axis to configure.</param>
 /// <param name="sensitivity">The sensitivity, expressed as a percentage.</param>
 public void SetTapSensitivity(ZkAccelAxisType axis, float sensitivity)
 => NativeHelper.Validate(NativeMethods.zkSetTapSensitivity(_ref, axis, sensitivity));
Пример #10
0
 /// <summary>
 /// Flashes the hardware LED for the specified times.
 /// </summary>
 /// <param name="on">The time the LED will stay on.</param>
 /// <param name="off">The time the LED will stay off.</param>
 /// <param name="numFlashes">The number of times to flash. If 0, the LED will flash indefinitely.</param>
 public void LedFlash(uint on, uint off = 0, uint numFlashes = 0)
 => NativeHelper.Validate(NativeMethods.zkLEDFlash(_ref, on, off, numFlashes));
Пример #11
0
 /// <summary>
 /// Sets the Zymkey's I2C address.
 /// </summary>
 /// <param name="addr">The I2C address.</param>
 public void SetI2CAddr(int addr)
 => NativeHelper.Validate(NativeMethods.zkSetI2CAddr(_ref, addr));
Пример #12
0
 /// <summary>
 /// Turns the hardware LED on.
 /// </summary>
 public void LedOn()
 => NativeHelper.Validate(NativeMethods.zkLEDOn(_ref));
Пример #13
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));
 }
Пример #14
0
 /// <summary>
 /// Save the ECDSA public key at the specified slot to a file.
 /// </summary>
 /// <param name="destFile">The file to save to.</param>
 /// <param name="slot">The Zymkey slot.</param>
 public void SaveEcdsaPubkeyToFile(string destFile, int slot = 0)
 => NativeHelper.Validate(NativeMethods.zkSaveECDSAPubKey2File(_ref, destFile, slot));
Пример #15
0
 /// <summary>
 /// Opens a new Zymkey context.
 /// </summary>
 public Zymkey()
 {
     NativeHelper.Validate(NativeMethods.zkOpen(out _ref));
 }
Пример #16
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));
 }