public void AgentCreateDeviceSetRsaKey()
        {
            // generate RSA key pair
            RsaKeyGenerator generator  = new RsaKeyGenerator();
            RsaPrivateKey   privateKey = generator.GeneratePrivateKey(2048);
            RsaPublicKey    publicKey  = generator.GeneratePublicKey(privateKey);

            // set RSA keys into a CreateDeviceRequest object
            CreateDeviceRequest request = new CreateDeviceRequest();

            request.ClientRsaPrivateKey = privateKey;
            request.ClientRsaPublicKey  = publicKey;
        }
예제 #2
0
 /// <summary>
 /// Generate RSA private key.
 /// </summary>
 /// <param name="key"></param>
 /// <param name="keyFormat"></param>
 /// <returns></returns>
 public static RsaKey GeneratePublicKey(string key, RsaKeyFormat keyFormat = RsaKeyFormat.XML) => RsaKeyGenerator.GeneratePublicKey(key, keyFormat);
예제 #3
0
 /// <summary>
 /// Generate RSA private key.
 /// </summary>
 /// <param name="keySize"></param>
 /// <param name="keyFormat"></param>
 /// <param name="keepingFormat"></param>
 /// <returns></returns>
 public static RsaKey GeneratePublicKey(RsaKeySize keySize, RsaKeyFormat keyFormat = RsaKeyFormat.XML, bool keepingFormat = false) => RsaKeyGenerator.GeneratePublicKey(keySize, keyFormat, keepingFormat);
예제 #4
0
 public static IRSA CreateWithPublicKey(string key, RsaKeyFormat keyFormat) => new RsaFunction(RsaKeyGenerator.GeneratePublicKey(key, keyFormat));