Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bouncycastle.jcajce.provider.asymmetric.rsa;
  
  
A provider representation for a RSA private key, with CRT factors included.
 
 public class BCRSAPrivateCrtKey
     extends BCRSAPrivateKey
     implements RSAPrivateCrtKey
 {
     static final long serialVersionUID = 7834723820638524718L;
     
     private BigInteger  publicExponent;
     private BigInteger  primeP;
     private BigInteger  primeQ;
     private BigInteger  primeExponentP;
     private BigInteger  primeExponentQ;
     private BigInteger  crtCoefficient;

    
construct a private key from it's org.bouncycastle.crypto equivalent.

Parameters:
key the parameters object representing the private key.
 
         RSAPrivateCrtKeyParameters key)
     {
         super(key);
 
         this. = key.getPublicExponent();
         this. = key.getP();
         this. = key.getQ();
         this. = key.getDP();
         this. = key.getDQ();
         this. = key.getQInv();
     }

    
construct a private key from an RSAPrivateCrtKeySpec

Parameters:
spec the spec to be used in construction.
 
         RSAPrivateCrtKeySpec spec)
     {
         this. = spec.getModulus();
         this. = spec.getPublicExponent();
         this. = spec.getPrivateExponent();
         this. = spec.getPrimeP();
         this. = spec.getPrimeQ();
         this. = spec.getPrimeExponentP();
         this. = spec.getPrimeExponentQ();
         this. = spec.getCrtCoefficient();
     }

    
construct a private key from another RSAPrivateCrtKey.

Parameters:
key the object implementing the RSAPrivateCrtKey interface.
 
         RSAPrivateCrtKey key)
     {
         this. = key.getModulus();
         this. = key.getPublicExponent();
         this. = key.getPrivateExponent();
         this. = key.getPrimeP();
         this. = key.getPrimeQ();
         this. = key.getPrimeExponentP();
         this. = key.getPrimeExponentQ();
         this. = key.getCrtCoefficient();
     }

    
construct an RSA key from a private key info object.
 
         PrivateKeyInfo info)
         throws IOException
     {
         this(RSAPrivateKey.getInstance(info.parsePrivateKey()));
     }

    
construct an RSA key from a ASN.1 RSA private key object.
 
        RSAPrivateKey key)
    {
        this. = key.getModulus();
        this. = key.getPublicExponent();
        this. = key.getPrivateExponent();
        this. = key.getPrime1();
        this. = key.getPrime2();
        this. = key.getExponent1();
        this. = key.getExponent2();
        this. = key.getCoefficient();
    }

    
return the encoding format we produce in getEncoded().

Returns:
the encoding format we produce in getEncoded().
    public String getFormat()
    {
        return "PKCS#8";
    }

    
Return a PKCS8 representation of the key. The sequence returned represents a full PrivateKeyInfo object.

Returns:
a PKCS8 representation of the key.
    public byte[] getEncoded()
    {
    }

    
return the public exponent.

Returns:
the public exponent.
    public BigInteger getPublicExponent()
    {
        return ;
    }

    
return the prime P.

Returns:
the prime P.
    public BigInteger getPrimeP()
    {
        return ;
    }

    
return the prime Q.

Returns:
the prime Q.
    public BigInteger getPrimeQ()
    {
        return ;
    }

    
return the prime exponent for P.

Returns:
the prime exponent for P.
    public BigInteger getPrimeExponentP()
    {
        return ;
    }

    
return the prime exponent for Q.

Returns:
the prime exponent for Q.
    public BigInteger getPrimeExponentQ()
    {
        return ;
    }

    
return the CRT coefficient.

Returns:
the CRT coefficient.
    public BigInteger getCrtCoefficient()
    {
        return ;
    }
    public int hashCode()
    {
        return this.getModulus().hashCode()
               ^ this.getPublicExponent().hashCode()
               ^ this.getPrivateExponent().hashCode();
    }
    public boolean equals(Object o)
    {
        if (o == this)
        {
            return true;
        }
        if (!(o instanceof RSAPrivateCrtKey))
        {
            return false;
        }
        RSAPrivateCrtKey key = (RSAPrivateCrtKey)o;
        return this.getModulus().equals(key.getModulus())
         && this.getPublicExponent().equals(key.getPublicExponent())
         && this.getPrivateExponent().equals(key.getPrivateExponent())
         && this.getPrimeP().equals(key.getPrimeP())
         && this.getPrimeQ().equals(key.getPrimeQ())
         && this.getPrimeExponentP().equals(key.getPrimeExponentP())
         && this.getPrimeExponentQ().equals(key.getPrimeExponentQ())
         && this.getCrtCoefficient().equals(key.getCrtCoefficient());
    }
    public String toString()
    {
        StringBuffer    buf = new StringBuffer();
        String          nl = System.getProperty("line.separator");
        buf.append("RSA Private CRT Key").append(nl);
        buf.append("            modulus: ").append(this.getModulus().toString(16)).append(nl);
        buf.append("    public exponent: ").append(this.getPublicExponent().toString(16)).append(nl);
        buf.append("   private exponent: ").append(this.getPrivateExponent().toString(16)).append(nl);
        buf.append("             primeP: ").append(this.getPrimeP().toString(16)).append(nl);
        buf.append("             primeQ: ").append(this.getPrimeQ().toString(16)).append(nl);
        buf.append("     primeExponentP: ").append(this.getPrimeExponentP().toString(16)).append(nl);
        buf.append("     primeExponentQ: ").append(this.getPrimeExponentQ().toString(16)).append(nl);
        buf.append("     crtCoefficient: ").append(this.getCrtCoefficient().toString(16)).append(nl);
        return buf.toString();
    }
New to GrepCode? Check out our FAQ X