software.common
Class SecurityUtil
java.lang.Object
software.common.SecurityUtil
public class SecurityUtil
- extends java.lang.Object
|
Method Summary |
static void |
checkDrowCommitment(byte[] s1,
int d1,
byte[] d2,
java.lang.String c1,
byte partitionId,
byte dNo,
java.lang.String did,
byte[] c)
|
static void |
checkProwCommitment(byte[] s1,
byte[] p1,
java.lang.String c1,
java.lang.String pid,
byte[] c)
|
static byte[] |
getCommitment(javax.crypto.spec.SecretKeySpec skm,
byte[] c,
byte[] m)
Given a message m, a secretKey skm and a public constant
it returnes the commitment to the message m. |
static java.lang.String |
toPEM(java.security.cert.X509Certificate cert)
Converts an X509 certificate from BER to PEM |
static javax.crypto.spec.SecretKeySpec |
tripleAES(javax.crypto.spec.SecretKeySpec mk1,
javax.crypto.spec.SecretKeySpec mk2,
byte[] c,
byte[] message)
generates a pseuso random AES 128bit key from "message". |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
cipherNoPaddingNoKey
public static javax.crypto.Cipher cipherNoPaddingNoKey
cipherPkcs5Padding
public static javax.crypto.Cipher cipherPkcs5Padding
SecurityUtil
public SecurityUtil()
tripleAES
public static javax.crypto.spec.SecretKeySpec tripleAES(javax.crypto.spec.SecretKeySpec mk1,
javax.crypto.spec.SecretKeySpec mk2,
byte[] c,
byte[] message)
throws java.lang.Exception
- generates a pseuso random AES 128bit key from "message".
The formula used to generate the key is:
Km = Dmk1 (C XOR Emk2 (C XOR Emk1(message))),
where D standes for decrypt and E for Encrypt. Emk1 means Encrypt with the key "mk1"
(master key 1). The encryption scheme used is AES/ECB/NoPadding
the following restrictions apply:
message.length = 16
c.length = 16
rawKey1.length = 16
rawKey2.length = 16
Otherwise the method will throw an Exception
- Parameters:
mk1 - an AES 128 bit keymk2 - an AES 128 bit keyc - a constant. c.length = 16;message - 16byte message
- Returns:
- an AES 128bit key
- Throws:
java.lang.Exception - - no exceptions are caugth
getCommitment
public static byte[] getCommitment(javax.crypto.spec.SecretKeySpec skm,
byte[] c,
byte[] m)
throws java.lang.Exception
- Given a message m, a secretKey skm and a public constant
it returnes the commitment to the message m.
The commitment is computed as follows:
sak=Encrypt C with skm
h1 = SHA256(m, sak).
h2 = SHA256(m, Encrypt h1 with sak)
the commitment is h1h2 (h1 concatenated with h2)
where E stands for Encrypt.
The encryption scheme used is AES/ECB/NoPadding
- Parameters:
skm - - the salt used in the commitmentc - - the public constantm - - the message to be commited to
- Returns:
- - a commitment to m
- Throws:
java.lang.Exception
checkProwCommitment
public static void checkProwCommitment(byte[] s1,
byte[] p1,
java.lang.String c1,
java.lang.String pid,
byte[] c)
throws org.xml.sax.SAXException
- Parameters:
s1 - - saltp1 - - messagec1 - - commitmentpid - - p idc - - public constant
- Throws:
org.xml.sax.SAXException - if the commitment does not checks.
The commitment is constructed using SecurityUtil.getCommitment
checkDrowCommitment
public static void checkDrowCommitment(byte[] s1,
int d1,
byte[] d2,
java.lang.String c1,
byte partitionId,
byte dNo,
java.lang.String did,
byte[] c)
throws org.xml.sax.SAXException
- Parameters:
s1 - - saltd1 - - d1 (pointer to P or R)d2 - - transformationc1 - - commitmentpartitionId - dNo - did - c - - public constant
- Throws:
org.xml.sax.SAXException - if the commitment does not checks.
The commitment is constructed using SecurityUtil.getCommitment
toPEM
public static java.lang.String toPEM(java.security.cert.X509Certificate cert)
throws java.security.cert.CertificateEncodingException
- Converts an X509 certificate from BER to PEM
- Parameters:
cert - - an X509 Certificate
- Returns:
- - a String with the PEM format of the certificate(Base64, 65 characters per line)
- Throws:
java.security.cert.CertificateEncodingException