|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--webfunds.sox.Crypto
XXX: Do Not Touch This File!!! Centralized crypto methods. Currently being overhauled.
| Field Summary | |
static int |
cipher_keylen
|
static java.lang.String |
pk_alg
|
static java.lang.String |
sig_alg
|
static java.security.SecureRandom |
sr
|
| Constructor Summary | |
Crypto()
|
|
| Method Summary | |
static java.security.PrivateKey |
decodePrivateKey(byte[] data)
Decode an RSA PrivateKey object from encoded data |
static java.security.PublicKey |
decodePublicKey(byte[] data)
Decode an RSA PublicKey object from encoded data |
static byte[] |
decodeSignature(byte[] data)
Extract the signature data from an X509 Signature packet |
static byte[] |
decrypt(java.security.Key key,
byte[] data)
Decrypt the data and return the encrypted binary data The data is uncompressed after decrypting |
static byte[] |
digest(byte[] data)
Create a message digest (as a byte array) from data (as a byte array) The digest uses the algorithm specified in crypto.message-digest.algorithm, and if not defined, defaults to the MD_ALGORITHM algorithm. |
static byte[] |
encodePrivateKey(java.security.PrivateKey key)
Encode an RSA PrivateKey object |
static byte[] |
encodePublicKey(java.security.PublicKey key)
Encode an RSA PublicKey object |
static byte[] |
encodeSignature(byte[] sig)
Encode a signature into an X509 signature packet |
static byte[] |
encrypt(java.security.Key key,
byte[] data)
Encrypt the data and return the encrypted binary data The data is compressed before encrypting |
static boolean |
equals(java.security.PrivateKey left,
java.security.PrivateKey right)
|
static boolean |
equals(java.security.PublicKey left,
java.security.PublicKey right)
|
static byte[] |
fingerprint(java.security.PublicKey key)
|
static java.security.Key |
generateKey()
Generate (randomly) a new Key object, suitable for the default symmetric cipher. |
static java.security.KeyPair |
generateKeys(int bits)
Useful for making accounts, better than certs. |
static byte[] |
getMagnitude(java.math.BigInteger x)
|
static java.security.PublicKey |
getPublicKeyFromCert(java.security.cert.Certificate cert)
Extract the public key from an X509 Certificate |
static java.security.SecureRandom |
getSecureRandom()
get the PRNG. |
static void |
main(java.lang.String[] args)
|
static byte[] |
pk_encrypt(java.security.Key key,
java.security.PublicKey pk,
byte[] data)
Encrypt the data and return the encrypted binary data. |
static byte[] |
pk_encrypt(java.security.Key key,
java.security.PublicKey pk,
byte[] data,
int offset,
int len)
Encrypt the data and return the encrypted binary data. |
static byte[] |
pk_encrypt(java.security.PublicKey pk,
byte[] data,
int offset,
int len)
Encrypt the data and return the encrypted binary data. |
static void |
setSecureRandom(java.security.SecureRandom userSR)
set a PRNG. |
static byte[] |
sign(java.security.PrivateKey key,
byte[] data)
Sign the data and return the binary X509 signature |
static java.security.PublicKey |
toCryptixJCEKey(java.security.PublicKey pk)
|
static java.security.PrivateKey |
toCryptixKey(java.security.PrivateKey pk)
|
static java.security.PublicKey |
toCryptixKey(java.security.PublicKey pk)
|
static boolean |
verify(java.security.PublicKey key,
byte[] sigX509,
byte[] data)
Determine whether the signature on the data is valid |
static boolean |
verifyCertificate(java.security.cert.Certificate cert,
java.security.PublicKey key)
Verify the signature on a signed certificate. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
public static final int cipher_keylen
public static final java.lang.String pk_alg
public static final java.lang.String sig_alg
public static java.security.SecureRandom sr
| Constructor Detail |
public Crypto()
| Method Detail |
public static void setSecureRandom(java.security.SecureRandom userSR)
throws java.lang.IllegalArgumentException
public static java.security.SecureRandom getSecureRandom()
public static java.security.KeyPair generateKeys(int bits)
public static boolean verifyCertificate(java.security.cert.Certificate cert,
java.security.PublicKey key)
cert - The signed X509 certificate to be validatedkey - The key used to sign the certificatepublic static java.security.PublicKey getPublicKeyFromCert(java.security.cert.Certificate cert)
cert - The X509 certificate containing the key
public static java.security.Key generateKey()
throws java.security.KeyException
public static byte[] digest(byte[] data)
data - the data to be digested
public static byte[] encrypt(java.security.Key key,
byte[] data)
key - the key with which to encrypt the data (as a byte array)data - the data being encrypted (as a byte array)
public static byte[] decrypt(java.security.Key key,
byte[] data)
throws java.security.KeyException
key - the key with which to decrypt the data (as a byte array)data - the data being decrypted (as a byte array)
public static byte[] pk_encrypt(java.security.Key key,
java.security.PublicKey pk,
byte[] data,
int offset,
int len)
throws java.security.KeyException
key - the symmetric key with which to encrypt the datapk - the PublicKey with which to encrypt the symmetric keydata - the data to be encrypted (as a byte array)offset - the offset within data where the data startslen - the length of the data with the data array
public static byte[] pk_encrypt(java.security.PublicKey pk,
byte[] data,
int offset,
int len)
throws java.security.KeyException
pk - the PublicKey with which to encrypt the symmetric keydata - the data to be encrypted (as a byte array)offset - the offset within data where the data startslen - the length of the data with the data array
public static byte[] pk_encrypt(java.security.Key key,
java.security.PublicKey pk,
byte[] data)
throws java.security.KeyException
key - the symmetric key with which to encrypt the datapk - the PublicKey with which to encrypt the symmetric keydata - the data to be encrypted (as a byte array)
public static byte[] sign(java.security.PrivateKey key,
byte[] data)
throws java.security.KeyException
key - a PrivateKey with which to sign the datadata - the data being signed (as a byte array)
public static boolean verify(java.security.PublicKey key,
byte[] sigX509,
byte[] data)
throws java.security.KeyException
key - a PublicKey with which to verify the signaturesignature - the X509 signature, as an ascii-armoured
base64 encoded Stringdata - the data which was signed (as a byte array)
public static byte[] fingerprint(java.security.PublicKey key)
throws java.security.InvalidKeyException
public static byte[] getMagnitude(java.math.BigInteger x)
public static byte[] decodeSignature(byte[] data)
throws java.security.SignatureException
data - The X509 signature packet containing the raw signaturepublic static byte[] encodeSignature(byte[] sig)
key - The signature to be wrapped by the X509 signature packet
public static java.security.PublicKey decodePublicKey(byte[] data)
throws java.security.InvalidKeyException
data - The encoded data containing the public keypublic static byte[] encodePublicKey(java.security.PublicKey key)
key - The encoded data containing the public key
public static java.security.PrivateKey decodePrivateKey(byte[] data)
throws java.security.InvalidKeyException
data - The encoded data containing the private keypublic static byte[] encodePrivateKey(java.security.PrivateKey key)
key - The encoded data containing the private keypublic static java.security.PublicKey toCryptixKey(java.security.PublicKey pk)
public static java.security.PrivateKey toCryptixKey(java.security.PrivateKey pk)
public static boolean equals(java.security.PublicKey left,
java.security.PublicKey right)
public static boolean equals(java.security.PrivateKey left,
java.security.PrivateKey right)
public static java.security.PublicKey toCryptixJCEKey(java.security.PublicKey pk)
public static void main(java.lang.String[] args)
throws java.lang.Exception
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||