Inheritance diagram for edu.virtualschool.jco.JCOSecretKey:


Notice that keys do NOT override Object.equals() and are NOT serializable as in JCA/JCE. The combination makes obfuscation far more effective at hiding them. To save/restore them in files, use the encode() or getEncoded() methods.
Ref: http://wireless.java.sun.com/midp/articles/security4/
Definition at line 26 of file JCOSecretKey.java.
Public Member Functions | |
| JCOSecretKey () | |
| JCOSecretKey (int keyLengthInBytes) throws RuntimeFault | |
| JCOSecretKey (String string) | |
| JCOSecretKey (byte[] bytes) | |
| final byte[] | decryptBytes (byte[] inputBytes) |
| final byte[] | encryptBytes (byte[] inputBytes) |
| final String | getAlgorithm () |
| final String | getFormat () |
Static Package Functions | |
| final KeyParameter | makeKeyParameter (int keyLengthInBytes) throws RuntimeFault |
Static Package Attributes | |
| final int | DEFAULT_KEY_LENGTH = 128/8 |
| Default key length in bytes. | |
| final int | MINIMUM_KEY_LENGTH = 40/8 |
| final int | MAXIMUM_KEY_LENGTH = 2048/8 |
|
|
Construct a secret key with the default length (16 bytes = 128 bites) from SecureRandom bytes. Definition at line 37 of file JCOSecretKey.java. References edu.virtualschool.jco.JCOSecretKey.DEFAULT_KEY_LENGTH.
00038 {
00039 super(makeKeyParameter(DEFAULT_KEY_LENGTH));
00040 }
|
|
|
Constructor for artibritary key lengths between 40 and 2048.
Definition at line 46 of file JCOSecretKey.java.
00047 {
00048 super(makeKeyParameter(keyLengthInBytes));
00049 }
|
|
|
Construct an instance from the Base64-encoded argument. This should be the result of calling getEncoded() on a valid instance. (Not sure what RAW encoding means or how it might go wrong at this point, so don't expect this to hold up to devient use cases). This constructor is particularly useful for generating secret keys from hard-coded string initializers.
Definition at line 69 of file JCOSecretKey.java.
00070 {
00071 this(JCOBase64.decode(string));
00072 }
|
|
|
Construct an instance from the provided byte array, which should contain bytes produced by getEncoded().
Definition at line 78 of file JCOSecretKey.java.
00079 {
00080 super(new KeyParameter(bytes));
00081 }
|
|
|
Encrypt (or decrypt) the provided inputBytes. Implements edu.virtualschool.jco.JCOSymmetricKey. Definition at line 85 of file JCOSecretKey.java. Referenced by edu.virtualschool.jco.JCOSecretKey.encryptBytes().
00086 {
00087 RC4Engine engine = new RC4Engine();
00088 engine.init(true, key);
00089 byte[] outputBytes = new byte[inputBytes.length];
00090 engine.processBytes(inputBytes, 0, inputBytes.length, outputBytes, 0);
00091 return outputBytes;
00092 }
|
|
|
Encryption is complimentary with decryption. Implements edu.virtualschool.jco.JCOSymmetricKey. Definition at line 96 of file JCOSecretKey.java. References edu.virtualschool.jco.JCOSecretKey.decryptBytes().
00097 {
00098 return decryptBytes(inputBytes);
00099 }
|
|
|
Returns the constant string "RC4" Implements edu.virtualschool.jco.JCOSymmetricKey. Definition at line 103 of file JCOSecretKey.java.
00104 {
00105 return "RC4";
00106 }
|
|
|
Returns the constant string "RAW" signifying RAW encoding (whatever that means; I'm not really sure). Implements edu.virtualschool.jco.JCOSymmetricKey. Definition at line 111 of file JCOSecretKey.java.
00112 {
00113 return "RAW";
00114 }
|