< prev index next >

src/java.base/share/classes/com/sun/crypto/provider/DHPrivateKey.java

Print this page




  79      * @param x the private value
  80      * @param p the prime modulus
  81      * @param g the base generator
  82      *
  83      * @exception ProviderException if the key cannot be encoded
  84      */
  85     DHPrivateKey(BigInteger x, BigInteger p, BigInteger g)
  86         throws InvalidKeyException {
  87         this(x, p, g, 0);
  88     }
  89 
  90     /**
  91      * Make a DH private key out of a private value <code>x</code>, a prime
  92      * modulus <code>p</code>, a base generator <code>g</code>, and a
  93      * private-value length <code>l</code>.
  94      *
  95      * @param x the private value
  96      * @param p the prime modulus
  97      * @param g the base generator
  98      * @param l the private-value length
  99      *
 100      * @exception InvalidKeyException if the key cannot be encoded
 101      */
 102     DHPrivateKey(BigInteger x, BigInteger p, BigInteger g, int l) {
 103         this.x = x;
 104         this.p = p;
 105         this.g = g;
 106         this.l = l;
 107         try {
 108             this.key = new DerValue(DerValue.tag_Integer,
 109                                     this.x.toByteArray()).toByteArray();
 110             this.encodedKey = getEncoded();
 111         } catch (IOException e) {
 112             throw new ProviderException("Cannot produce ASN.1 encoding", e);
 113         }
 114     }
 115 
 116     /**
 117      * Make a DH private key from its DER encoding (PKCS #8).
 118      *
 119      * @param encodedKey the encoded key
 120      *




  79      * @param x the private value
  80      * @param p the prime modulus
  81      * @param g the base generator
  82      *
  83      * @exception ProviderException if the key cannot be encoded
  84      */
  85     DHPrivateKey(BigInteger x, BigInteger p, BigInteger g)
  86         throws InvalidKeyException {
  87         this(x, p, g, 0);
  88     }
  89 
  90     /**
  91      * Make a DH private key out of a private value <code>x</code>, a prime
  92      * modulus <code>p</code>, a base generator <code>g</code>, and a
  93      * private-value length <code>l</code>.
  94      *
  95      * @param x the private value
  96      * @param p the prime modulus
  97      * @param g the base generator
  98      * @param l the private-value length


  99      */
 100     DHPrivateKey(BigInteger x, BigInteger p, BigInteger g, int l) {
 101         this.x = x;
 102         this.p = p;
 103         this.g = g;
 104         this.l = l;
 105         try {
 106             this.key = new DerValue(DerValue.tag_Integer,
 107                                     this.x.toByteArray()).toByteArray();
 108             this.encodedKey = getEncoded();
 109         } catch (IOException e) {
 110             throw new ProviderException("Cannot produce ASN.1 encoding", e);
 111         }
 112     }
 113 
 114     /**
 115      * Make a DH private key from its DER encoding (PKCS #8).
 116      *
 117      * @param encodedKey the encoded key
 118      *


< prev index next >