public final class TPCrypt
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected byte[] |
cbc_vector |
static int |
CHLG_LEN |
static int |
DECRYPT |
static int |
DES_ITERATIONS |
protected static byte[] |
dflt_cbc_vector |
protected static byte[] |
E |
static int |
ENCRYPT |
protected static byte[] |
FP |
protected static byte[] |
IP |
protected static byte[] |
P |
protected static byte[] |
PC1_C |
protected static byte[] |
PC1_D |
protected static byte[] |
PC2_C |
protected static byte[] |
PC2_D |
protected static byte[][] |
S |
protected byte[][] |
sched |
protected byte[] |
sec_key |
protected static byte[] |
shifts |
static int |
TMSEC_KEYLEN |
static int |
TMSEC_TICKETLEN |
Constructor and Description |
---|
TPCrypt() |
Modifier and Type | Method and Description |
---|---|
int |
crypt(byte[] in,
byte[] out,
int len,
int crypt) |
protected int |
DESCrypt(byte[] in,
byte[] out,
int len,
int crypt,
byte[] init_cbc) |
private void |
DESDecrypt(byte[] block,
byte[][] KS) |
private void |
DESEncrypt(byte[] block,
byte[][] KS) |
private void |
fixDESParity() |
private void |
initCrypt() |
int |
pwToKey(java.lang.String passwd,
byte[] key) |
byte[] |
randKey() |
private void |
setDESKey(byte[] key,
byte[][] KS) |
int |
setInitializationVector(byte[] iv) |
int |
setKey(byte[] key) |
protected byte[] sec_key
protected byte[][] sched
protected static byte[] dflt_cbc_vector
protected byte[] cbc_vector
public static final int CHLG_LEN
public static final int TMSEC_KEYLEN
public static final int TMSEC_TICKETLEN
public static final int DES_ITERATIONS
public static final int DECRYPT
public static final int ENCRYPT
protected static byte[] IP
protected static byte[] FP
protected static byte[] PC1_C
protected static byte[] PC1_D
protected static byte[] shifts
protected static byte[] PC2_C
protected static byte[] PC2_D
protected static byte[] E
protected static byte[][] S
protected static byte[] P
public TPCrypt()
public int crypt(byte[] in, byte[] out, int len, int crypt)
in
- the input data in a byte arrayout
- the output data in a a byte arraylen
- the length of the input data to be encrypted/decrypted in bytecrypt
- the flag to instruct the crypto object to encrypt or decrypt,
the value should be either TPCrypt.ENCRYPT or TPCrypt.DECRYPTjava.lang.Exception
public int setKey(byte[] key)
key
- byte array of length TPCrypt.TMSEC_KEYLEN that is suitable to be
used by the crypto object.public int setInitializationVector(byte[] iv)
iv
- byte array of length TPCrypt.TMSEC_KEYLEN that is suitable to be
used by the crypto object.public int pwToKey(java.lang.String passwd, byte[] key)
passwd
- the password string that the secret key should be derived from
The maximum string length is tfmh.MAXDOMAIN_LEN + 2.key
- the byte array that contains output of the secret key, the byte
array must have the length of TPCrypt.TMSEC_KEYLENjava.lang.Exception
public byte[] randKey()
private void fixDESParity()
private void setDESKey(byte[] key, byte[][] KS)
private void DESEncrypt(byte[] block, byte[][] KS)
private void DESDecrypt(byte[] block, byte[][] KS)
private void initCrypt()
protected int DESCrypt(byte[] in, byte[] out, int len, int crypt, byte[] init_cbc)