jdk/src/windows/classes/sun/security/mscapi/RSASignature.java
changeset 9508 310b4f6c8e61
parent 9505 3bbc6ff8a905
child 9524 8417d0e74ac5
equal deleted inserted replaced
9507:730ccba1467f 9508:310b4f6c8e61
     1 /*
     1 /*
     2  * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 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.security.PublicKey;
    29 import java.security.PublicKey;
    30 import java.security.PrivateKey;
    30 import java.security.PrivateKey;
    31 import java.security.InvalidKeyException;
    31 import java.security.InvalidKeyException;
    32 import java.security.InvalidParameterException;
    32 import java.security.InvalidParameterException;
    33 import java.security.InvalidAlgorithmParameterException;
    33 import java.security.InvalidAlgorithmParameterException;
       
    34 import java.security.KeyStoreException;
    34 import java.security.NoSuchAlgorithmException;
    35 import java.security.NoSuchAlgorithmException;
    35 import java.security.ProviderException;
    36 import java.security.ProviderException;
    36 import java.security.MessageDigest;
    37 import java.security.MessageDigest;
    37 import java.security.SecureRandom;
    38 import java.security.SecureRandom;
    38 import java.security.Signature;
    39 import java.security.Signature;
   144                 : modulusBytes.length * 8;
   145                 : modulusBytes.length * 8;
   145 
   146 
   146             byte[] keyBlob = generatePublicKeyBlob(
   147             byte[] keyBlob = generatePublicKeyBlob(
   147                 keyBitLength, modulusBytes, exponentBytes);
   148                 keyBitLength, modulusBytes, exponentBytes);
   148 
   149 
   149             publicKey = importPublicKey(keyBlob, keyBitLength);
   150             try {
       
   151                 publicKey = importPublicKey(keyBlob, keyBitLength);
       
   152 
       
   153             } catch (KeyStoreException e) {
       
   154                 throw new InvalidKeyException(e);
       
   155             }
   150 
   156 
   151         } else {
   157         } else {
   152             publicKey = (sun.security.mscapi.RSAPublicKey) key;
   158             publicKey = (sun.security.mscapi.RSAPublicKey) key;
   153         }
   159         }
   154 
   160 
   379     /**
   385     /**
   380      * Generates a public-key BLOB from a key's components.
   386      * Generates a public-key BLOB from a key's components.
   381      */
   387      */
   382     // used by RSACipher
   388     // used by RSACipher
   383     static native byte[] generatePublicKeyBlob(
   389     static native byte[] generatePublicKeyBlob(
   384         int keyBitLength, byte[] modulus, byte[] publicExponent);
   390         int keyBitLength, byte[] modulus, byte[] publicExponent)
       
   391             throws InvalidKeyException;
   385 
   392 
   386     /**
   393     /**
   387      * Imports a public-key BLOB.
   394      * Imports a public-key BLOB.
   388      */
   395      */
   389     // used by RSACipher
   396     // used by RSACipher
   390     static native RSAPublicKey importPublicKey(byte[] keyBlob, int keySize);
   397     static native RSAPublicKey importPublicKey(byte[] keyBlob, int keySize)
       
   398         throws KeyStoreException;
   391 }
   399 }