Exemplo n.º 1
0
        static void SolveDecryption(string[] args)
        {
            string encryption       = args[1],
                   privateKeyString = args[2].FromHexString();

            PrivateKey privateKey = (PrivateKey)PrivateKeyConverter.StringToKey(privateKeyString);

            string message = rsa.Decrypt(encryption, privateKey);

            Console.WriteLine(StandardMessages.DisplayDecryptedMessage(message));
        }
Exemplo n.º 2
0
        static void SolveKeyGeneration()
        {
            Console.WriteLine(StandardMessages.GeneratingPrimesInit());
            var sw = new Stopwatch();

            sw.Start();
            var primeNumberGenerator = new PrimeNumberGenerator(keySize / 2);

            sw.Stop();

            int    n = primeNumberGenerator.Primes.Count;
            double t = sw.Elapsed.TotalSeconds;

            Console.WriteLine(StandardMessages.GeneratingPrimesFinish(n, t));

            Console.WriteLine(StandardMessages.GeneratingKeys());
            var keyPair = rsa.GenerateKeyPair(primeNumberGenerator);

            string publicKey  = PublicKeyConverter.KeyToString(keyPair.PublicKey).ToHexString(),
                   privateKey = PrivateKeyConverter.KeyToString(keyPair.PrivateKey).ToHexString();

            Console.WriteLine(StandardMessages.DisplayKeys(publicKey, privateKey));
        }
Exemplo n.º 3
0
 /// <summary>CreateJwtBearerTokenFlowAssertionJWK</summary>
 /// <param name="iss">client_id</param>
 /// <param name="aud">Token2 EndPointのuri</param>
 /// <param name="forExp">DateTimeOffset</param>
 /// <param name="scopes">scopes</param>
 /// <param name="jwkPrivateKey">RS256用のJWK秘密鍵</param>
 /// <returns>JwtAssertion</returns>
 public static string CreateJwtBearerTokenFlowAssertionJWK(
     string iss, string aud, TimeSpan forExp, string scopes, string jwkPrivateKey)
 {
     return(JwtAssertion.CreateJwtBearerTokenFlowAssertion(iss, aud, forExp, scopes,
                                                           PrivateKeyConverter.JwkToRsaParam(jwkPrivateKey)));
 }