dist1.acb.common
Class Security

java.lang.Object
  extended bydist1.acb.common.Security

public class Security
extends java.lang.Object

Security module

Version:
$Revision: 1.29 $
Author:
Mariana Marin

Method Summary
 void decrypt(java.lang.String inputFileName, java.lang.String outputFileName, byte[] key)
          Decrypts a file using triple-DES
 byte[] digest(java.lang.String string)
          Creates a a hash for a string
 byte[] encrypt(java.lang.String inputFileName, java.lang.String outputFileName)
          Generates a key and ecrypt using triple-DES a file with that key
static Security getInstance()
          Get the only one instance
 java.lang.String getIssuedTo()
          Getter for property issuedTo.
 javax.net.ServerSocketFactory getServerSocketFactory()
          Obtain ServerSocketFactory
 javax.net.SocketFactory getSocketFactory()
          Obtain SocketFactory with certificate
 void init(java.io.InputStream keys, java.io.InputStream cert, java.io.InputStream generatorAndPrime)
          Initializes the Security obect.
 void init(java.lang.String keysFileName, java.lang.String certFileName, java.lang.String generatorAndPrimeFileName)
          Initializes the Security obect.
 boolean zkCheckUser(java.math.BigInteger r, java.math.BigInteger h, java.math.BigInteger s, java.math.BigInteger y)
          Ckecks if the user knows the secret
 java.math.BigInteger zkCreateCommitment(java.math.BigInteger k)
          Creates commitment r is g^k (mod q)
 java.math.BigInteger zkCreatePublicKey(java.lang.String password)
          Generates the public key for the user
 java.math.BigInteger zkCreateSignature(java.math.BigInteger k, java.math.BigInteger h, java.lang.String password)
          Creates signature for a password s = k+hx
 java.math.BigInteger zkRandom1024()
          Generates a secure random number
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Security getInstance()
Get the only one instance

Returns:
The instance

getIssuedTo

public java.lang.String getIssuedTo()
Getter for property issuedTo.

Returns:
Value of property issuedTo.

getServerSocketFactory

public javax.net.ServerSocketFactory getServerSocketFactory()
Obtain ServerSocketFactory

Returns:
serverFactory

getSocketFactory

public javax.net.SocketFactory getSocketFactory()
Obtain SocketFactory with certificate

Returns:
clientFactory

decrypt

public void decrypt(java.lang.String inputFileName,
                    java.lang.String outputFileName,
                    byte[] key)
             throws java.lang.Exception
Decrypts a file using triple-DES

Parameters:
inputFileName - the name of the file which will be decrypted
outputFileName - the file reluted from decryption
key - the key
Throws:
java.lang.Exception - if the specified algorithm is not available in the default provider package or any of the other provider packages that were searched

digest

public byte[] digest(java.lang.String string)
Creates a a hash for a string

Parameters:
string -
Returns:
hash

encrypt

public byte[] encrypt(java.lang.String inputFileName,
                      java.lang.String outputFileName)
               throws java.lang.Exception
Generates a key and ecrypt using triple-DES a file with that key

Parameters:
inputFileName - file to be encrypted
outputFileName - the encrypted file
Returns:
key
Throws:
java.lang.Exception - if the specified algorithm is not available in the default provider package or any of the other provider packages that were searched

init

public void init(java.lang.String keysFileName,
                 java.lang.String certFileName,
                 java.lang.String generatorAndPrimeFileName)
          throws java.lang.Exception
Initializes the Security obect. Must be called once after receiving the instance of the object.

Parameters:
keysFileName - from where the storeKey is loaded
certFileName - from where the storeCert is loaded
generatorAndPrimeFileName - from where prime and corresponded geterator (for Zero knowledge) is loaded
Throws:
java.lang.Exception - if something wrong

init

public void init(java.io.InputStream keys,
                 java.io.InputStream cert,
                 java.io.InputStream generatorAndPrime)
          throws java.lang.Exception
Initializes the Security obect. Must be called once after receiving the instance of the object.

Parameters:
keys - from where the storeKey is loaded
cert - from where the storeCert is loaded
generatorAndPrime - from where prime and corresponded geterator is loaded (for Zero Knowledge algorithm)
Throws:
java.lang.Exception - if something wrong
java.lang.RuntimeException - if something wrong

zkCheckUser

public boolean zkCheckUser(java.math.BigInteger r,
                           java.math.BigInteger h,
                           java.math.BigInteger s,
                           java.math.BigInteger y)
Ckecks if the user knows the secret

Parameters:
r - the commitment
h - the nonce (a secure random number generate by the server)
s - the signature of the user
y - the public key of the user
Returns:
if the check is successfull.If the server believes that the user knows the password.

zkCreateCommitment

public java.math.BigInteger zkCreateCommitment(java.math.BigInteger k)
Creates commitment r is g^k (mod q)

Parameters:
k - the secure random number generated by the user
Returns:
r the commitment

zkCreatePublicKey

public java.math.BigInteger zkCreatePublicKey(java.lang.String password)
Generates the public key for the user

Parameters:
password - the password of the user
Returns:
y user's public key

zkCreateSignature

public java.math.BigInteger zkCreateSignature(java.math.BigInteger k,
                                              java.math.BigInteger h,
                                              java.lang.String password)
Creates signature for a password s = k+hx

Parameters:
k - a secure random number generate by the user
h - a secure random number generate by the server
password - user's password
Returns:
s the signature

zkRandom1024

public java.math.BigInteger zkRandom1024()
Generates a secure random number

Returns:
randBigInt


Copyright © 2004 Phoenix Team (CMU/AIT). All Rights Reserved.