jdk/src/share/classes/com/sun/crypto/provider/DHPrivateKey.java
changeset 10336 0bb1999251f8
parent 7043 5e2d1edeb2c7
child 18809 97f5713a0f1a
child 20813 0ad12d66a652
equal deleted inserted replaced
10335:3c7eda3ab2f5 10336:0bb1999251f8
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    29 import java.math.BigInteger;
    29 import java.math.BigInteger;
    30 import java.security.KeyRep;
    30 import java.security.KeyRep;
    31 import java.security.PrivateKey;
    31 import java.security.PrivateKey;
    32 import java.security.InvalidKeyException;
    32 import java.security.InvalidKeyException;
    33 import java.security.ProviderException;
    33 import java.security.ProviderException;
    34 import javax.crypto.*;
       
    35 import javax.crypto.spec.DHParameterSpec;
    34 import javax.crypto.spec.DHParameterSpec;
    36 import sun.security.util.*;
    35 import sun.security.util.*;
    37 
    36 
    38 /**
    37 /**
    39  * A private key in PKCS#8 format for the Diffie-Hellman key agreement
    38  * A private key in PKCS#8 format for the Diffie-Hellman key agreement
   180             this.key = val.data.getOctetString();
   179             this.key = val.data.getOctetString();
   181             parseKeyBits();
   180             parseKeyBits();
   182 
   181 
   183             // ignore OPTIONAL attributes
   182             // ignore OPTIONAL attributes
   184 
   183 
   185             this.encodedKey = (byte[])encodedKey.clone();
   184             this.encodedKey = encodedKey.clone();
   186 
   185 
   187         } catch (NumberFormatException e) {
   186         } catch (NumberFormatException e) {
   188             InvalidKeyException ike = new InvalidKeyException(
   187             InvalidKeyException ike = new InvalidKeyException(
   189                 "Private-value length too big");
   188                 "Private-value length too big");
   190             ike.initCause(e);
   189             ike.initCause(e);
   254                 this.encodedKey = derKey.toByteArray();
   253                 this.encodedKey = derKey.toByteArray();
   255             } catch (IOException e) {
   254             } catch (IOException e) {
   256                 return null;
   255                 return null;
   257             }
   256             }
   258         }
   257         }
   259         return (byte[])this.encodedKey.clone();
   258         return this.encodedKey.clone();
   260     }
   259     }
   261 
   260 
   262     /**
   261     /**
   263      * Returns the private value, <code>x</code>.
   262      * Returns the private value, <code>x</code>.
   264      *
   263      *