|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSFE.BOAL.MyUtil
public class MyUtil
This class initializes general services required by other classes, namely a hash-function and an RNG.
Field Summary | |
---|---|
static java.math.BigInteger |
dp
|
static java.math.BigInteger |
dq
|
static int |
key_size
|
static java.security.MessageDigest |
md
|
static java.math.BigInteger |
modulus
|
static java.math.BigInteger |
pinverseq
|
static java.security.SecureRandom |
random
|
Constructor Summary | |
---|---|
MyUtil()
|
Method Summary | |
---|---|
static void |
BigInt2FixedBytes(java.math.BigInteger num,
byte[] res)
BigInt2FixedBytes: converts a BigInteger (smaller than the El-Gamal prime) into a fixed size byte array. |
static void |
BigInts2FixedBytes(java.math.BigInteger[] nums,
byte[] res)
BigInts2FixedBytes: converts an array of BigIntegers (smaller than the El-Gamal prime) into a fixed size byte array. |
static byte[] |
decArrays(byte[] cipher,
byte[] key)
decArrays - Decrypt cipher-text array with key array by XOR |
static java.math.BigInteger |
decrypt(java.math.BigInteger c)
|
static long |
deltaHeap()
deltaHeap - tool for measuring size of heap, returns the heap size delta (in bytes) from previous call to this routine. |
static long |
deltaTime(boolean reset_time)
deltaTime - profiling tool for measuring time spent in different program sections, returns the delta time (in milli-secs) from previous call to this routine. |
static byte[] |
EG_decrypt(java.math.BigInteger gr,
java.math.BigInteger yrm,
java.math.BigInteger x)
EG_decrypt: Perform El-Gamal decryption |
static java.math.BigInteger |
EG_deduce(java.math.BigInteger pub_key0)
EG_deduce: Deduce one El-Gamal public key from another |
static java.math.BigInteger |
EG_encrypt(java.math.BigInteger y,
java.math.BigInteger r,
byte[] packed_code)
EG_encrypt: Perform El-Gamal encryption |
static java.math.BigInteger |
EG_g()
EG_g: return the EG generator g |
static java.math.BigInteger |
EG_genPublic(int selector,
java.math.BigInteger x)
EG_genPublic: generate a public El-Gamal encryption key |
static java.math.BigInteger |
EG_pow(java.math.BigInteger pow)
EG_pow: Perform modular exponentiation g^pow mod p |
static java.math.BigInteger |
EG_randExp()
EG_randExp: generate an EG random exponent |
static byte[] |
encArrays(byte[] plain,
byte[] key)
encArrays - Encrypt plain-text array with key array by XOR |
static java.math.BigInteger |
encrypt(java.math.BigInteger m)
|
static java.math.BigInteger |
FixedBytes2BigInt(byte[] ba)
FixedBytes2BigInt: converts a fixed size byte array to a BigInteger (smaller than the El-Gamal prime) |
static java.math.BigInteger[] |
FixedBytes2BigInts(byte[] ba,
int pos,
int how_many)
FixedBytes2BigInts: converts a fixed size byte array to an array of BigIntegers (smaller than the El-Gamal prime) |
static byte[] |
hash(byte[] inp,
int no_out_bytes)
hash |
static void |
init(java.lang.String seed)
Initialize |
static void |
newRSA(int N)
newRSA - receive the sixe of the new modulus creates new RSA key, prints it and EXITS!!! |
static java.math.BigInteger |
pad(java.math.BigInteger bi)
|
static java.lang.String |
pathFile(java.lang.String fname)
pathFile - concatenate $rundir to a filename |
static java.math.BigInteger |
rand(int size)
rand: generate an random number of max size |
static byte |
randomByte()
Generate one random byte |
static void |
randomBytes(byte[] result)
Generate random bytes |
static void |
receiveBytes(java.io.ObjectInputStream ois,
byte[] in,
int len)
receiveBytes - receive an array of bytes via ObjectInputStream |
static int |
receiveInt(java.io.ObjectInputStream ois)
receiveInt - receive an int via ObjectInputStream |
static SFE.BOAL.OTMESS |
receiveOTMESS(java.io.ObjectInputStream ois)
receiveOTMESS - receive an OTMESS object via ObjectInputStream |
static java.util.Vector |
receiveVector(java.io.ObjectInputStream ois)
receiveVector - receive a Vector object via ObjectInputStream |
static void |
sendBytes(java.io.ObjectOutputStream oos,
byte[] a,
boolean flush)
sendBytes - send an array of bytes via ObjectOutputStream |
static void |
sendInt(java.io.ObjectOutputStream oos,
int k,
boolean flush)
sendInt - send an int via ObjectOutputStream |
static void |
sendOTMESS(java.io.ObjectOutputStream oos,
SFE.BOAL.OTMESS otmess)
sendOTMESS - send an OTMESS object via ObjectOutputStream |
static void |
sendVector(java.io.ObjectOutputStream oos,
java.util.Vector v)
sendVector - send a Vector object via ObjectOutputStream |
static byte[] |
toByteArray(int in)
Convert int to a byte array. |
static java.lang.String |
toHexStr(byte b)
toHexStr - turn a byte to a hex String (for debugging) |
static java.lang.String |
toHexString(byte[] arr)
toHexString - turn byte array to a hex String (for debugging purposes) |
static byte[] |
xorArrays(byte[] inp1,
byte[] inp2)
xorArrays - XOR one byte-array with another |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.security.MessageDigest md
public static java.security.SecureRandom random
public static int key_size
public static java.math.BigInteger modulus
public static java.math.BigInteger dp
public static java.math.BigInteger dq
public static java.math.BigInteger pinverseq
Constructor Detail |
---|
public MyUtil()
Method Detail |
---|
public static void init(java.lang.String seed)
public static byte[] hash(byte[] inp, int no_out_bytes)
public static byte randomByte()
public static void randomBytes(byte[] result)
result
- - a byte array for generated random bytes.public static byte[] encArrays(byte[] plain, byte[] key)
plain
- - plain text byte array.key
- - key byte array.
public static byte[] decArrays(byte[] cipher, byte[] key)
cipher
- - cipher text byte array.key
- - key byte array.
public static byte[] xorArrays(byte[] inp1, byte[] inp2)
inp1
- - 1st byte array to be XORed.inp2
- - 2nd byte array to be XORed.
public static java.lang.String toHexStr(byte b)
b
- - a byte.
public static java.lang.String toHexString(byte[] arr)
arr
- - byte array.
public static byte[] toByteArray(int in)
in
- An int to be converted to a byte array.
public static java.lang.String pathFile(java.lang.String fname)
fname
- - file name to concatenate to.
public static long deltaTime(boolean reset_time)
reset_time
- - reset timing measurements.
public static long deltaHeap()
public static java.math.BigInteger EG_genPublic(int selector, java.math.BigInteger x)
selector
- a 0/1 value selecting which of the two public
keys is real and which is 'fake'x
- The El-Gamal private key
public static java.math.BigInteger EG_deduce(java.math.BigInteger pub_key0)
pub_key0
- An EG public key
public static java.math.BigInteger EG_encrypt(java.math.BigInteger y, java.math.BigInteger r, byte[] packed_code)
y
- El-Gamal public keyr
- El-Gamal random secret exponentpacked_code
- data to encrypt
public static byte[] EG_decrypt(java.math.BigInteger gr, java.math.BigInteger yrm, java.math.BigInteger x)
gr
- g^r part of El-Gamal ciphertextyrm
- (y^r)*M part of El-Gamal ciphertext
public static java.math.BigInteger EG_pow(java.math.BigInteger pow)
pow
- to exponentiate to
public static java.math.BigInteger EG_randExp()
public static java.math.BigInteger rand(int size)
public static java.math.BigInteger EG_g()
public static void BigInt2FixedBytes(java.math.BigInteger num, byte[] res)
public static java.math.BigInteger FixedBytes2BigInt(byte[] ba)
public static void BigInts2FixedBytes(java.math.BigInteger[] nums, byte[] res)
public static java.math.BigInteger[] FixedBytes2BigInts(byte[] ba, int pos, int how_many)
public static void sendOTMESS(java.io.ObjectOutputStream oos, SFE.BOAL.OTMESS otmess)
oos
- - ObjectOutputStream to send the object on.otmess
- - object to send.public static SFE.BOAL.OTMESS receiveOTMESS(java.io.ObjectInputStream ois)
ois
- - ObjectInputStream to receive the object on.
public static void sendInt(java.io.ObjectOutputStream oos, int k, boolean flush)
oos
- - ObjectOutputStream to send the object on.k
- - int to send.flush
- - whether to flus or not.public static int receiveInt(java.io.ObjectInputStream ois)
ois
- - ObjectInputStream to receive the object on.
public static void sendBytes(java.io.ObjectOutputStream oos, byte[] a, boolean flush)
oos
- - ObjectOutputStream to send the object on.a
- - array of bytes to send.flush
- - whether to flus or not.public static void receiveBytes(java.io.ObjectInputStream ois, byte[] in, int len)
ois
- - ObjectInputStream to receive the object on.public static void sendVector(java.io.ObjectOutputStream oos, java.util.Vector v)
oos
- - ObjectOutputStream to send the object on.v
- - object to send.public static java.util.Vector receiveVector(java.io.ObjectInputStream ois)
ois
- - ObjectInputStream to receive the object on.
public static void newRSA(int N)
N
- - the size in bits of the new moduluspublic static java.math.BigInteger decrypt(java.math.BigInteger c)
public static java.math.BigInteger encrypt(java.math.BigInteger m)
public static java.math.BigInteger pad(java.math.BigInteger bi)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |