Package org.bouncycastle.asn1.x509

Examples of org.bouncycastle.asn1.x509.RSAPublicKeyStructure


        return "X.509";
    }

    public byte[] getEncoded()
    {
        SubjectPublicKeyInfo    info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, new DERNull()), new RSAPublicKeyStructure(getModulus(), getPublicExponent()).getDERObject());

        return info.getDEREncoded();
    }
View Full Code Here


    {
        ByteArrayInputStream bAIS = new ByteArrayInputStream(readBytes(endMarker));
        ASN1InputStream ais = new ASN1InputStream(bAIS);
        Object asnObject = ais.readObject();
        ASN1Sequence sequence = (ASN1Sequence) asnObject;
        RSAPublicKeyStructure rsaPubStructure = new RSAPublicKeyStructure(sequence);
        RSAPublicKeySpec keySpec = new RSAPublicKeySpec(
                    rsaPubStructure.getModulus(),
                    rsaPubStructure.getPublicExponent());

        try
        {
            KeyFactory keyFact = KeyFactory.getInstance("RSA",provider);     
View Full Code Here

            gen.setSubject(new X509Name("CN=AU,O=Bouncy Castle,OU=Test 1"));
           
            gen.setSignature(new AlgorithmIdentifier(PKCSObjectIdentifiers.md5WithRSAEncryption, new DERNull()));
           
            SubjectPublicKeyInfo    info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, new DERNull()),
                                                         new RSAPublicKeyStructure(BigInteger.valueOf(1), BigInteger.valueOf(2)));
           
            gen.setSubjectPublicKeyInfo(info);
           
            TBSCertificateStructure     tbs = gen.generateTBSCertificate();
            ByteArrayOutputStream       bOut = new ByteArrayOutputStream();
View Full Code Here

            ASN1InputStream         dIn = new ASN1InputStream(bIn);
   
            //
            // extract the public key info.
            //
            RSAPublicKeyStructure   pubStruct;
   
            try
            {
                pubStruct = new RSAPublicKeyStructure((ASN1Sequence)new SubjectPublicKeyInfo((ASN1Sequence)dIn.readObject()).getPublicKey());
            }
            catch (Exception e)
            {
                return new SimpleTestResult(false, getName() + ": exception - " + e.toString());
            }
   
            bIn = new ByteArrayInputStream(privKeyEnc);
            dIn = new ASN1InputStream(bIn);
   
            //
            // extract the private key info.
            //
            RSAPrivateKeyStructure privStruct;
   
            try
            {
                privStruct = new RSAPrivateKeyStructure((ASN1Sequence)(new PrivateKeyInfo((ASN1Sequence)dIn.readObject()).getPrivateKey()));
            }
            catch (Exception e)
            {
                return new SimpleTestResult(false, getName() + ": exception - " + e.toString());
            }
   
            RSAKeyParameters    pubParameters = new RSAKeyParameters(
                                                        false,
                                                        pubStruct.getModulus(),
                                                        pubStruct.getPublicExponent());
   
            RSAKeyParameters    privParameters = new RSAPrivateCrtKeyParameters(
                                                        privStruct.getModulus(),
                                                        privStruct.getPublicExponent(),
                                                        privStruct.getPrivateExponent(),
View Full Code Here

      obj = is.readObject();
    } catch (IOException e) {
      e.printStackTrace();
    }
      ASN1Sequence seq = (ASN1Sequence)obj;
      RSAPublicKeyStructure pubk = null;
      SubjectPublicKeyInfo pkInfo = SubjectPublicKeyInfo.getInstance(seq);
      try {
       pubk = RSAPublicKeyStructure.getInstance(pkInfo.getPublicKey());
    } catch (IOException e) {
      e.printStackTrace();
    }

    RSAPublicKeySpec rsaPubKey = new RSAPublicKeySpec(pubk.getModulus(), pubk.getPublicExponent());
        KeyFactory factory;

        try {
            factory = KeyFactory.getInstance("RSA");
        } catch (NoSuchAlgorithmException e) {
View Full Code Here

      // javni kljuc se sastoji od modula i javnog eksponenta u odgovarajucoj ASN1 strukturi
      ASN1InputStream is = new ASN1InputStream(x509Cert.getPublicKey().getEncoded());
        DERObject obj = is.readObject();
        ASN1Sequence seq = (ASN1Sequence)obj;
        SubjectPublicKeyInfo pkInfo = SubjectPublicKeyInfo.getInstance(seq);
        RSAPublicKeyStructure pubk = RSAPublicKeyStructure.getInstance(pkInfo.getPublicKey());
        BigInteger expo = pubk.getPublicExponent();
        BigInteger mod = pubk.getModulus();
       
        // sada imamo sve potrebne podatke za privatni kljuc
      privKeySpec = new RSAPrivateCrtKeySpec(mod,
                          expo,
                          null,
View Full Code Here

        throws IOException
    {
        ASN1InputStream ais = new ASN1InputStream(readBytes(endMarker));
        Object asnObject = ais.readObject();
        ASN1Sequence sequence = (ASN1Sequence)asnObject;
        RSAPublicKeyStructure rsaPubStructure = new RSAPublicKeyStructure(sequence);
        RSAPublicKeySpec keySpec = new RSAPublicKeySpec(
                    rsaPubStructure.getModulus(),
                    rsaPubStructure.getPublicExponent());

        try
        {
            KeyFactory keyFact = KeyFactory.getInstance("RSA", provider);
View Full Code Here

    JCERSAPublicKey(
        SubjectPublicKeyInfo    info)
    {
        try
        {
            RSAPublicKeyStructure   pubKey = new RSAPublicKeyStructure((ASN1Sequence)info.getPublicKey());

            this.modulus = pubKey.getModulus();
            this.publicExponent = pubKey.getPublicExponent();
        }
        catch (IOException e)
        {
            throw new IllegalArgumentException("invalid info structure in RSA public key");
        }
View Full Code Here

        return "X.509";
    }

    public byte[] getEncoded()
    {
        SubjectPublicKeyInfo    info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, new DERNull()), new RSAPublicKeyStructure(getModulus(), getPublicExponent()).getDERObject());

        return info.getDEREncoded();
    }
View Full Code Here

    JCERSAPublicKey(
        SubjectPublicKeyInfo    info)
    {
        try
        {
            RSAPublicKeyStructure   pubKey = new RSAPublicKeyStructure((ASN1Sequence)info.getPublicKey());

            this.modulus = pubKey.getModulus();
            this.publicExponent = pubKey.getPublicExponent();
        }
        catch (IOException e)
        {
            throw new IllegalArgumentException("invalid info structure in RSA public key");
        }
View Full Code Here

TOP

Related Classes of org.bouncycastle.asn1.x509.RSAPublicKeyStructure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.