Examples of RSAPublicKeyStructure


Examples of org.bouncycastle.asn1.x509.RSAPublicKeyStructure

      // 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

Examples of org.bouncycastle.asn1.x509.RSAPublicKeyStructure

        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

Examples of org.bouncycastle.asn1.x509.RSAPublicKeyStructure

    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

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

Examples of org.bouncycastle.asn1.x509.RSAPublicKeyStructure

    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

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

Examples of org.bouncycastle.asn1.x509.RSAPublicKeyStructure

                                    /*
                                    * We only support RSA certificates. Lets hope
                                    * this is one.
                                    */
                                    RSAPublicKeyStructure rsaKey = null;
                                    try
                                    {
                                        rsaKey = RSAPublicKeyStructure.getInstance(cert.certs[0].getTBSCertificate().getSubjectPublicKeyInfo().getPublicKey());
                                    }
                                    catch (Exception e)
                                    {
                                        /*
                                        * Sorry, we have to fail ;-(
                                        */
                                        this.failWithError(AL_fatal, AP_unsupported_certificate);
                                    }

                                    /*
                                    * Parse the servers public RSA key.
                                    */
                                    this.serverRsaKey = new RSAKeyParameters(
                                        false,
                                        rsaKey.getModulus(),
                                        rsaKey.getPublicExponent());

                                    connection_state = CS_SERVER_CERTIFICATE_RECEIVED;
                                    read = true;
                                    break;
                                default:
View Full Code Here

Examples of org.bouncycastle.asn1.x509.RSAPublicKeyStructure

    {
        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

Examples of org.bouncycastle.asn1.x509.RSAPublicKeyStructure

    {
        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

Examples of org.bouncycastle.asn1.x509.RSAPublicKeyStructure

    }

    private static RSAPublicKey readRSAPublicKey(BufferedReader in, String endMarker) throws IOException {
        Object asnObject = new ASN1InputStream(readBytes(in, endMarker)).readObject();
        ASN1Sequence sequence = (ASN1Sequence) asnObject;
        RSAPublicKeyStructure rsaPubStructure = new RSAPublicKeyStructure(sequence);
        RSAPublicKeySpec keySpec = new RSAPublicKeySpec(
                    rsaPubStructure.getModulus(),
                    rsaPubStructure.getPublicExponent());

        try {
            KeyFactory keyFact = KeyFactory.getInstance("RSA");
            return (RSAPublicKey) keyFact.generatePublic(keySpec);
        } catch (NoSuchAlgorithmException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.