public void Initialize() { _protocol = new Model.Protocol(); _userState = _protocol.CreateUserState(); // won't read any existing files. }
/// <summary> /// Fetch the private key from the given OtrlUserState associated with the given account. /// </summary> /// <param name="us"></param> /// <param name="accountname"></param> /// <param name="protocol"></param> /// <returns></returns> public static PrivateKey otrl_privkey_find(UserState us, string accountname, string protocol) { return null; }
/// <summary> /// Calculate a human-readable hash of our DSA public key. Return it in /// the passed fingerprint buffer. Return NULL on error, or a pointer to /// the given buffer on success. /// </summary> /// <param name="userState">The current <see cref="UserState" />.</param> /// <param name="accountName">The AccountName.</param> /// <param name="protocol">The Protocol.</param> /// <returns>A human readable fingerprint (45 chars).</returns> public static string otrl_privkey_fingerprint(UserState userState, string accountName, string protocol) { PrivateKey privateKey = otrl_privkey_find(userState, accountName, protocol); if (privateKey != null) { byte[] hash = SHA1.Create().ComputeHash(privateKey.PublicKeyAsMPI); return otrl_privkey_hash_to_human(hash); } return null; }
/// <summary> /// Calculate a raw hash of our DSA public key. Return it in the passed /// fingerprint buffer. Return NULL on error, or a pointer to the given /// buffer on success. /// </summary> /// <param name="userState">The current <see cref="UserState" />.</param> /// <param name="accountName">The AccountName.</param> /// <param name="protocol">The Protocol.</param> /// <returns>A 20 byte hash.</returns> public static byte[] otrl_privkey_fingerprint_raw(UserState userState, string accountName, string protocol) { PrivateKey privateKey = otrl_privkey_find(userState, accountName, protocol); if (privateKey != null) { return SHA1.Create().ComputeHash(privateKey.PublicKeyAsMPI); } return null; }