src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSASignature.java

Print this page
7191662: JCE providers should be located via ServiceLoader
   1 /*
   2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  31 import java.lang.ref.*;
  32 import java.math.BigInteger;
  33 import java.nio.ByteBuffer;
  34 
  35 import java.security.SignatureSpi;
  36 import java.security.NoSuchAlgorithmException;
  37 import java.security.InvalidParameterException;
  38 import java.security.InvalidKeyException;
  39 import java.security.SignatureException;
  40 import java.security.Key;
  41 import java.security.PrivateKey;
  42 import java.security.PublicKey;
  43 
  44 import java.security.*;
  45 import java.security.interfaces.*;
  46 import java.security.spec.RSAPrivateCrtKeySpec;
  47 import java.security.spec.RSAPublicKeySpec;
  48 import java.security.spec.InvalidKeySpecException;
  49 import sun.nio.ch.DirectBuffer;
  50 import java.nio.ByteBuffer;
  51 import sun.security.rsa.RSAPadding;
  52 
  53 /**
  54  * Signature implementation class. This class currently supports the
  55  * following algorithms:
  56  *
  57  * . RSA:
  58  *   . MD5withRSA
  59  *   . SHA1withRSA
  60  *   . SHA256withRSA
  61  *   . SHA384withRSA
  62  *   . SHA512withRSA
  63  *
  64  * @since 1.9
  65  */
  66 class NativeRSASignature extends SignatureSpi {
  67 
  68     private static final int PKCS1PADDING_LEN = 11;
  69 
  70     // fields set in constructor
  71     private final UcryptoMech mech;


   1 /*
   2  * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  31 import java.lang.ref.*;
  32 import java.math.BigInteger;
  33 import java.nio.ByteBuffer;
  34 
  35 import java.security.SignatureSpi;
  36 import java.security.NoSuchAlgorithmException;
  37 import java.security.InvalidParameterException;
  38 import java.security.InvalidKeyException;
  39 import java.security.SignatureException;
  40 import java.security.Key;
  41 import java.security.PrivateKey;
  42 import java.security.PublicKey;
  43 
  44 import java.security.*;
  45 import java.security.interfaces.*;
  46 import java.security.spec.RSAPrivateCrtKeySpec;
  47 import java.security.spec.RSAPublicKeySpec;
  48 import java.security.spec.InvalidKeySpecException;
  49 import sun.nio.ch.DirectBuffer;
  50 import java.nio.ByteBuffer;

  51 
  52 /**
  53  * Signature implementation class. This class currently supports the
  54  * following algorithms:
  55  *
  56  * . RSA:
  57  *   . MD5withRSA
  58  *   . SHA1withRSA
  59  *   . SHA256withRSA
  60  *   . SHA384withRSA
  61  *   . SHA512withRSA
  62  *
  63  * @since 1.9
  64  */
  65 class NativeRSASignature extends SignatureSpi {
  66 
  67     private static final int PKCS1PADDING_LEN = 11;
  68 
  69     // fields set in constructor
  70     private final UcryptoMech mech;