< prev index next >

src/java.base/share/classes/sun/security/rsa/RSAKeyFactory.java

Print this page
rev 14210 : 8154231: Simplify access to System properties from JDK code
Reviewed-by: rriggs


  67     private static final Class<?> rsaPrivateCrtKeySpecClass =
  68                                                 RSAPrivateCrtKeySpec.class;
  69 
  70     private static final Class<?> x509KeySpecClass  = X509EncodedKeySpec.class;
  71     private static final Class<?> pkcs8KeySpecClass = PKCS8EncodedKeySpec.class;
  72 
  73     public static final int MIN_MODLEN = 512;
  74     public static final int MAX_MODLEN = 16384;
  75 
  76     /*
  77      * If the modulus length is above this value, restrict the size of
  78      * the exponent to something that can be reasonably computed.  We
  79      * could simply hardcode the exp len to something like 64 bits, but
  80      * this approach allows flexibility in case impls would like to use
  81      * larger module and exponent values.
  82      */
  83     public static final int MAX_MODLEN_RESTRICT_EXP = 3072;
  84     public static final int MAX_RESTRICTED_EXPLEN = 64;
  85 
  86     private static final boolean restrictExpLen =
  87         "true".equalsIgnoreCase(AccessController.doPrivileged(
  88             new GetPropertyAction(
  89                 "sun.security.rsa.restrictRSAExponent", "true")));
  90 
  91     // instance used for static translateKey();
  92     private static final RSAKeyFactory INSTANCE = new RSAKeyFactory();
  93 
  94     public RSAKeyFactory() {
  95         // empty
  96     }
  97 
  98     /**
  99      * Static method to convert Key into an instance of RSAPublicKeyImpl
 100      * or RSAPrivate(Crt)KeyImpl. If the key is not an RSA key or cannot be
 101      * used, throw an InvalidKeyException.
 102      *
 103      * Used by RSASignature and RSACipher.
 104      */
 105     public static RSAKey toRSAKey(Key key) throws InvalidKeyException {
 106         if ((key instanceof RSAPrivateKeyImpl) ||
 107             (key instanceof RSAPrivateCrtKeyImpl) ||
 108             (key instanceof RSAPublicKeyImpl)) {
 109             return (RSAKey)key;




  67     private static final Class<?> rsaPrivateCrtKeySpecClass =
  68                                                 RSAPrivateCrtKeySpec.class;
  69 
  70     private static final Class<?> x509KeySpecClass  = X509EncodedKeySpec.class;
  71     private static final Class<?> pkcs8KeySpecClass = PKCS8EncodedKeySpec.class;
  72 
  73     public static final int MIN_MODLEN = 512;
  74     public static final int MAX_MODLEN = 16384;
  75 
  76     /*
  77      * If the modulus length is above this value, restrict the size of
  78      * the exponent to something that can be reasonably computed.  We
  79      * could simply hardcode the exp len to something like 64 bits, but
  80      * this approach allows flexibility in case impls would like to use
  81      * larger module and exponent values.
  82      */
  83     public static final int MAX_MODLEN_RESTRICT_EXP = 3072;
  84     public static final int MAX_RESTRICTED_EXPLEN = 64;
  85 
  86     private static final boolean restrictExpLen =
  87         "true".equalsIgnoreCase(GetPropertyAction.getProperty(
  88                 "sun.security.rsa.restrictRSAExponent", "true"));

  89 
  90     // instance used for static translateKey();
  91     private static final RSAKeyFactory INSTANCE = new RSAKeyFactory();
  92 
  93     public RSAKeyFactory() {
  94         // empty
  95     }
  96 
  97     /**
  98      * Static method to convert Key into an instance of RSAPublicKeyImpl
  99      * or RSAPrivate(Crt)KeyImpl. If the key is not an RSA key or cannot be
 100      * used, throw an InvalidKeyException.
 101      *
 102      * Used by RSASignature and RSACipher.
 103      */
 104     public static RSAKey toRSAKey(Key key) throws InvalidKeyException {
 105         if ((key instanceof RSAPrivateKeyImpl) ||
 106             (key instanceof RSAPrivateCrtKeyImpl) ||
 107             (key instanceof RSAPublicKeyImpl)) {
 108             return (RSAKey)key;


< prev index next >