Ejemplo n.º 1
0
        public static AsnPublicKeyPair FromRSA(RSAParameters rsa)
        {
            AsnPublicKeyPair kp = new AsnPublicKeyPair
            {
                modulus  = new AsnInteger(rsa.Modulus),
                exponent = new AsnInteger(rsa.Exponent)
            };

            return(kp);
        }
Ejemplo n.º 2
0
        public static AsnPublicKeyPair Decode(byte[] source, ref int pos)
        {
            AsnPublicKeyPair instance = new AsnPublicKeyPair();

            pos++;

            long len = instance.GetLength(source, ref pos);

            instance.modulus  = AsnInteger.Decode(source, ref pos);
            instance.exponent = AsnInteger.Decode(source, ref pos);

            // bring the parameters into an RSA format
            instance.parameters.Modulus  = instance.modulus.myValue.ToByteArray();
            instance.parameters.Exponent = instance.exponent.myValue.ToByteArray();

            return(instance);
        }
Ejemplo n.º 3
0
        public static AsnPublicKeyInfo Decode(byte[] source, ref int pos)
        {
            AsnPublicKeyInfo instance = new AsnPublicKeyInfo();

            //CheckContextTag(source, ref pos);
            pos++;

            int len = instance.GetLength(source, ref pos);

            instance.algorithm = AsnAlgorithmIdentifier.Decode(source, ref pos);
            instance.publicKey = AsnBitstring.Decode(source, ref pos);

            // TODO: further decode publicKey into AsnKeyPair
            int bi = 0;

            instance.keys = AsnPublicKeyPair.Decode(instance.publicKey.value, ref bi);

            return(instance);
        }
Ejemplo n.º 4
0
 public AsnPublicKeyInfo()
 {
     algorithm = new AsnAlgorithmIdentifier();
     publicKey = new AsnBitstring();
     keys      = new AsnPublicKeyPair();
 }
Ejemplo n.º 5
0
        public AsnPublicKeyPair GetPublicKey()
        {
            AsnPublicKeyPair publicKey = AsnPublicKeyPair.FromRSA(parameters);

            return(publicKey);
        }