Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="id"></param>
 /// <param name="secretKey"></param>
 public void SetSecretKey(string id, string secretKey)
 {
     if (id == null)
     {
         throw new ArgumentNullException(nameof(id));
     }
     if (!_keyCache.TryGetValue(id, out var keys))
     {
         keys = new KeyTriple(id, 1, null, null, null);
         _keyCache.Add(keys.Id, keys);
     }
     keys.SecretKey = secretKey;
 }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public string GenerateNewKeys()
        {
            RSACryptoServiceProvider RSAProvider = new RSACryptoServiceProvider();
            KeyTriple keys = new KeyTriple(
                Guid.NewGuid().ToString(),
                1,
                Guid.NewGuid().ToString(),
                RSAProvider.ToXmlString(false),
                RSAProvider.ToXmlString(true));

            _keyCache.Add(keys.Id, keys);
            return(keys.Id);
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="publicKey"></param>
        public void SetPublicKey(string id, string publicKey)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            KeyTriple keys;

            if (!_keyCache.TryGetValue(id, out keys))
            {
                keys = new KeyTriple(id, 1, null, null, null);
                _keyCache.Add(keys.Id, keys);
            }
            keys.PublicKey = publicKey;
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="transpKey"></param>
        public void SetTranspKey(string id, string transpKey)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }
            KeyTriple keys;

            if (!_keyCache.TryGetValue(id, out keys))
            {
                keys = new KeyTriple(id, 1, null, null, null);
                _keyCache.Add(keys.Id, keys);
            }
            keys.TranspKey = transpKey;
        }