64 * @author Andreas Sterbenz |
64 * @author Andreas Sterbenz |
65 */ |
65 */ |
66 public final class RSACipher extends CipherSpi { |
66 public final class RSACipher extends CipherSpi { |
67 |
67 |
68 // constant for an empty byte array |
68 // constant for an empty byte array |
69 private final static byte[] B0 = new byte[0]; |
69 private static final byte[] B0 = new byte[0]; |
70 |
70 |
71 // mode constant for public key encryption |
71 // mode constant for public key encryption |
72 private final static int MODE_ENCRYPT = 1; |
72 private static final int MODE_ENCRYPT = 1; |
73 // mode constant for private key decryption |
73 // mode constant for private key decryption |
74 private final static int MODE_DECRYPT = 2; |
74 private static final int MODE_DECRYPT = 2; |
75 // mode constant for private key encryption (signing) |
75 // mode constant for private key encryption (signing) |
76 private final static int MODE_SIGN = 3; |
76 private static final int MODE_SIGN = 3; |
77 // mode constant for public key decryption (verifying) |
77 // mode constant for public key decryption (verifying) |
78 private final static int MODE_VERIFY = 4; |
78 private static final int MODE_VERIFY = 4; |
79 |
79 |
80 // constant for raw RSA |
80 // constant for raw RSA |
81 private final static String PAD_NONE = "NoPadding"; |
81 private static final String PAD_NONE = "NoPadding"; |
82 // constant for PKCS#1 v1.5 RSA |
82 // constant for PKCS#1 v1.5 RSA |
83 private final static String PAD_PKCS1 = "PKCS1Padding"; |
83 private static final String PAD_PKCS1 = "PKCS1Padding"; |
84 // constant for PKCS#2 v2.0 OAEP with MGF1 |
84 // constant for PKCS#2 v2.0 OAEP with MGF1 |
85 private final static String PAD_OAEP_MGF1 = "OAEP"; |
85 private static final String PAD_OAEP_MGF1 = "OAEP"; |
86 |
86 |
87 // current mode, one of MODE_* above. Set when init() is called |
87 // current mode, one of MODE_* above. Set when init() is called |
88 private int mode; |
88 private int mode; |
89 |
89 |
90 // active padding type, one of PAD_* above. Set by setPadding() |
90 // active padding type, one of PAD_* above. Set by setPadding() |