jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoMech.java
changeset 31270 e6470b24700d
parent 28240 0d15a67e8085
child 35302 e4d2275861c3
equal deleted inserted replaced
31269:14968253ce7e 31270:e6470b24700d
     1 /*
     1 /**
     2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     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.
     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
    32  *
    32  *
    33  * @since 1.9
    33  * @since 1.9
    34  */
    34  */
    35 // Check /usr/include/libsoftcrypto.h for updates
    35 // Check /usr/include/libsoftcrypto.h for updates
    36 public enum UcryptoMech {
    36 public enum UcryptoMech {
    37     CRYPTO_AES_ECB(1, new String[]
    37 
    38         { "Cipher.AES/ECB/NoPadding;com.oracle.security.ucrypto.NativeCipher$AesEcbNoPadding",
    38     CRYPTO_AES_ECB(1, new ServiceDesc[]
    39           "Cipher.AES/ECB/PKCS5Padding;com.oracle.security.ucrypto.NativeCipherWithJavaPadding$AesEcbPKCS5",
    39         { sd("Cipher", "AES/ECB/NoPadding", "com.oracle.security.ucrypto.NativeCipher$AesEcbNoPadding"),
    40           "Alg.Alias.Cipher.AES;AES/ECB/PKCS5Padding",
    40           sd("Cipher", "AES/ECB/PKCS5Padding", "com.oracle.security.ucrypto.NativeCipherWithJavaPadding$AesEcbPKCS5",
    41           "Cipher.AES_128/ECB/NoPadding;com.oracle.security.ucrypto.NativeCipher$Aes128EcbNoPadding",
    41              "AES"),
    42           "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.1;AES_128/ECB/NoPadding",
    42           sd("Cipher", "AES_128/ECB/NoPadding", "com.oracle.security.ucrypto.NativeCipher$Aes128EcbNoPadding",
    43           "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.1;AES_128/ECB/NoPadding",
    43              "2.16.840.1.101.3.4.1.1", "OID.2.16.840.1.101.3.4.1.1"),
    44           "Cipher.AES_192/ECB/NoPadding;com.oracle.security.ucrypto.NativeCipher$Aes192EcbNoPadding",
    44           sd("Cipher", "AES_192/ECB/NoPadding", "com.oracle.security.ucrypto.NativeCipher$Aes192EcbNoPadding",
    45           "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.21;AES_192/ECB/NoPadding",
    45              "2.16.840.1.101.3.4.1.21", "OID.2.16.840.1.101.3.4.1.21"),
    46           "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.21;AES_192/ECB/NoPadding",
    46           sd("Cipher", "AES_256/ECB/NoPadding", "com.oracle.security.ucrypto.NativeCipher$Aes256EcbNoPadding",
    47           "Cipher.AES_256/ECB/NoPadding;com.oracle.security.ucrypto.NativeCipher$Aes256EcbNoPadding",
    47              "2.16.840.1.101.3.4.1.41", "OID.2.16.840.1.101.3.4.1.41")
    48           "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.41;AES_256/ECB/NoPadding",
       
    49           "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.41;AES_256/ECB/NoPadding"
       
    50         }),
    48         }),
    51     CRYPTO_AES_CBC(2, new String[]
    49     CRYPTO_AES_CBC(2, new ServiceDesc[]
    52         { "Cipher.AES/CBC/NoPadding;com.oracle.security.ucrypto.NativeCipher$AesCbcNoPadding",
    50         { sd("Cipher", "AES/CBC/NoPadding", "com.oracle.security.ucrypto.NativeCipher$AesCbcNoPadding"),
    53           "Cipher.AES/CBC/PKCS5Padding;com.oracle.security.ucrypto.NativeCipherWithJavaPadding$AesCbcPKCS5",
    51           sd("Cipher", "AES/CBC/PKCS5Padding", "com.oracle.security.ucrypto.NativeCipherWithJavaPadding$AesCbcPKCS5"),
    54           "Cipher.AES_128/CBC/NoPadding;com.oracle.security.ucrypto.NativeCipher$Aes128CbcNoPadding",
    52           sd("Cipher", "AES_128/CBC/NoPadding", "com.oracle.security.ucrypto.NativeCipher$Aes128CbcNoPadding",
    55           "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.2;AES_128/CBC/NoPadding",
    53              "2.16.840.1.101.3.4.1.2", "OID.2.16.840.1.101.3.4.1.2"),
    56           "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.2;AES_128/CBC/NoPadding",
    54           sd("Cipher", "AES_192/CBC/NoPadding", "com.oracle.security.ucrypto.NativeCipher$Aes192CbcNoPadding",
    57           "Cipher.AES_192/CBC/NoPadding;com.oracle.security.ucrypto.NativeCipher$Aes192CbcNoPadding",
    55              "2.16.840.1.101.3.4.1.22", "OID.2.16.840.1.101.3.4.1.22"),
    58           "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.22;AES_192/CBC/NoPadding",
    56           sd("Cipher", "AES_256/CBC/NoPadding", "com.oracle.security.ucrypto.NativeCipher$Aes256CbcNoPadding",
    59           "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.22;AES_192/CBC/NoPadding",
    57              "2.16.840.1.101.3.4.1.42", "OID.2.16.840.1.101.3.4.1.42")
    60           "Cipher.AES_256/CBC/NoPadding;com.oracle.security.ucrypto.NativeCipher$Aes256CbcNoPadding",
       
    61           "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.42;AES_256/CBC/NoPadding",
       
    62           "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.42;AES_256/CBC/NoPadding"
       
    63         }),
    58         }),
    64     CRYPTO_AES_CBC_PAD(3, null), // No support from Solaris yet
    59     CRYPTO_AES_CBC_PAD(3, null), // No support from Solaris yet
    65     CRYPTO_AES_CTR(4, new String[]
    60     CRYPTO_AES_CTR(4, new ServiceDesc[]
    66         { "Cipher.AES/CTR/NoPadding;com.oracle.security.ucrypto.NativeCipher$AesCtrNoPadding" }),
    61         { sd("Cipher", "AES/CTR/NoPadding", "com.oracle.security.ucrypto.NativeCipher$AesCtrNoPadding") }),
    67     CRYPTO_AES_CCM(5, null), // Cannot support due to lack of Java API which corresponds to CK_AES_CCM_PARAMS
    62     CRYPTO_AES_CCM(5, null), // Cannot support due to lack of Java API which corresponds to CK_AES_CCM_PARAMS
    68     CRYPTO_AES_GCM(6, new String[]
    63     CRYPTO_AES_GCM(6, new ServiceDesc[]
    69         { "Cipher.AES/GCM/NoPadding;com.oracle.security.ucrypto.NativeGCMCipher$AesGcmNoPadding",
    64         { sd("Cipher", "AES/GCM/NoPadding", "com.oracle.security.ucrypto.NativeGCMCipher$AesGcmNoPadding"),
    70           "Cipher.AES_128/GCM/NoPadding;com.oracle.security.ucrypto.NativeGCMCipher$Aes128GcmNoPadding",
    65           sd("Cipher", "AES_128/GCM/NoPadding", "com.oracle.security.ucrypto.NativeGCMCipher$Aes128GcmNoPadding",
    71           "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.6;AES_128/GCM/NoPadding",
    66              "2.16.840.1.101.3.4.1.6", "OID.2.16.840.1.101.3.4.1.6"),
    72           "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.6;AES_128/GCM/NoPadding",
    67           sd("Cipher", "AES_192/GCM/NoPadding", "com.oracle.security.ucrypto.NativeGCMCipher$Aes192GcmNoPadding",
    73           "Cipher.AES_192/GCM/NoPadding;com.oracle.security.ucrypto.NativeGCMCipher$Aes192GcmNoPadding",
    68              "2.16.840.1.101.3.4.1.26", "OID.2.16.840.1.101.3.4.1.26"),
    74           "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.26;AES_192/GCM/NoPadding",
    69           sd("Cipher", "AES_256/GCM/NoPadding", "com.oracle.security.ucrypto.NativeGCMCipher$Aes256GcmNoPadding",
    75           "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.26;AES_192/GCM/NoPadding",
    70              "2.16.840.1.101.3.4.1.46", "OID.2.16.840.1.101.3.4.1.46")
    76           "Cipher.AES_256/GCM/NoPadding;com.oracle.security.ucrypto.NativeGCMCipher$Aes256GcmNoPadding",
       
    77           "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.46;AES_256/GCM/NoPadding",
       
    78           "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.46;AES_256/GCM/NoPadding",
       
    79         }),
    71         }),
    80     CRYPTO_AES_GMAC(7, null), // No support from Solaris yet
    72     CRYPTO_AES_GMAC(7, null), // No support from Solaris yet
    81     CRYPTO_AES_CFB128(8, new String[]
    73     CRYPTO_AES_CFB128(8, new ServiceDesc[]
    82         { "Cipher.AES/CFB128/NoPadding;com.oracle.security.ucrypto.NativeCipher$AesCfb128NoPadding",
    74         { sd("Cipher", "AES/CFB128/NoPadding", "com.oracle.security.ucrypto.NativeCipher$AesCfb128NoPadding"),
    83           "Cipher.AES/CFB128/PKCS5Padding;com.oracle.security.ucrypto.NativeCipherWithJavaPadding$AesCfb128PKCS5" }),
    75           sd("Cipher", "AES/CFB128/PKCS5Padding", "com.oracle.security.ucrypto.NativeCipherWithJavaPadding$AesCfb128PKCS5") }),
    84     CRYPTO_RSA_PKCS(31, new String[]
    76     CRYPTO_RSA_PKCS(31, new ServiceDesc[]
    85         { "Cipher.RSA/ECB/PKCS1Padding;com.oracle.security.ucrypto.NativeRSACipher$PKCS1Padding",
    77         { sd("Cipher", "RSA/ECB/PKCS1Padding", "com.oracle.security.ucrypto.NativeRSACipher$PKCS1Padding",
    86           "Alg.Alias.Cipher.RSA;RSA/ECB/PKCS1Padding" }),
    78              "RSA") }),
    87     CRYPTO_RSA_X_509(32, new String[]
    79     CRYPTO_RSA_X_509(32, new ServiceDesc[]
    88         { "Cipher.RSA/ECB/NoPadding;com.oracle.security.ucrypto.NativeRSACipher$NoPadding" }),
    80         { sd("Cipher", "RSA/ECB/NoPadding", "com.oracle.security.ucrypto.NativeRSACipher$NoPadding") }),
    89     CRYPTO_MD5_RSA_PKCS(33, new String[]
    81     CRYPTO_MD5_RSA_PKCS(33, new ServiceDesc[]
    90         { "Signature.MD5withRSA;com.oracle.security.ucrypto.NativeRSASignature$MD5",
    82         { sd("Signature", "MD5withRSA", "com.oracle.security.ucrypto.NativeRSASignature$MD5",
    91           "Alg.Alias.Signature.1.2.840.113549.1.1.4;MD5withRSA",
    83              "1.2.840.113549.1.1.4", "OID.1.2.840.113549.1.1.4") }),
    92           "Alg.Alias.Signature.OID.1.2.840.113549.1.1.4;MD5withRSA" }),
    84     CRYPTO_SHA1_RSA_PKCS(34, new ServiceDesc[]
    93     CRYPTO_SHA1_RSA_PKCS(34, new String[]
    85         { sd("Signature", "SHA1withRSA", "com.oracle.security.ucrypto.NativeRSASignature$SHA1",
    94         { "Signature.SHA1withRSA;com.oracle.security.ucrypto.NativeRSASignature$SHA1",
    86              "1.2.840.113549.1.1.5", "OID.1.2.840.113549.1.1.5",
    95           "Alg.Alias.Signature.1.2.840.113549.1.1.5;SHA1withRSA",
    87              "1.3.14.3.2.29") }),
    96           "Alg.Alias.Signature.OID.1.2.840.113549.1.1.5;SHA1withRSA",
    88     CRYPTO_SHA256_RSA_PKCS(35, new ServiceDesc[]
    97           "Alg.Alias.Signature.1.3.14.3.2.29;SHA1withRSA" }),
    89         { sd("Signature", "SHA256withRSA", "com.oracle.security.ucrypto.NativeRSASignature$SHA256",
    98     CRYPTO_SHA256_RSA_PKCS(35, new String[]
    90              "1.2.840.113549.1.1.11", "OID.1.2.840.113549.1.1.11") }),
    99         { "Signature.SHA256withRSA;com.oracle.security.ucrypto.NativeRSASignature$SHA256",
    91     CRYPTO_SHA384_RSA_PKCS(36, new ServiceDesc[]
   100           "Alg.Alias.Signature.1.2.840.113549.1.1.11;SHA256withRSA",
    92         { sd("Signature", "SHA384withRSA", "com.oracle.security.ucrypto.NativeRSASignature$SHA384",
   101           "Alg.Alias.Signature.OID.1.2.840.113549.1.1.11;SHA256withRSA" }),
    93              "1.2.840.113549.1.1.12", "OID.1.2.840.113549.1.1.12") }),
   102     CRYPTO_SHA384_RSA_PKCS(36, new String[]
    94     CRYPTO_SHA512_RSA_PKCS(37, new ServiceDesc[]
   103         { "Signature.SHA384withRSA;com.oracle.security.ucrypto.NativeRSASignature$SHA384",
    95         { sd("Signature", "SHA512withRSA", "com.oracle.security.ucrypto.NativeRSASignature$SHA512",
   104           "Alg.Alias.Signature.1.2.840.113549.1.1.12;SHA384withRSA",
    96              "1.2.840.113549.1.1.13", "OID.1.2.840.113549.1.1.13") });
   105           "Alg.Alias.Signature.OID.1.2.840.113549.1.1.12;SHA384withRSA" }),
       
   106     CRYPTO_SHA512_RSA_PKCS(37, new String[]
       
   107         { "Signature.SHA512withRSA;com.oracle.security.ucrypto.NativeRSASignature$SHA512",
       
   108           "Alg.Alias.Signature.1.2.840.113549.1.1.13;SHA512withRSA",
       
   109           "Alg.Alias.Signature.OID.1.2.840.113549.1.1.13;SHA512withRSA" });
       
   110 
    97 
   111     private int mech;
    98     private final int mech;
   112     private String[] jceProps;
    99     private final ServiceDesc[] serviceDescs;
   113 
   100 
   114     UcryptoMech(int mech, String[] jceProps) {
   101     private static ServiceDesc sd(String type, String algo, String cn, String... aliases) {
       
   102         return new ServiceDesc(type, algo, cn, aliases);
       
   103     }
       
   104 
       
   105     UcryptoMech(int mech, ServiceDesc[] serviceDescs) {
   115         this.mech = mech;
   106         this.mech = mech;
   116         this.jceProps = jceProps;
   107         this.serviceDescs = serviceDescs;
   117     }
   108     }
   118 
   109 
   119     public int value() { return mech; }
   110     public int value() { return mech; }
   120     public String[] jceProperties() { return jceProps; }
   111     public ServiceDesc[] getServiceDescriptions() { return serviceDescs; }
   121 }
   112 }