de.bb.security
Class Pkcs6

java.lang.Object
  |
  +--de.bb.security.Pkcs6

public class Pkcs6
extends java.lang.Object

This class contains functions from Pkcs 6


Field Summary
static byte[] rsaEncryption
           
 
Constructor Summary
Pkcs6()
           
 
Method Summary
static byte[] createCertificate(byte[] issuer, byte[] date, byte[] owner, byte[] pubN, byte[] pubE)
          Create a certifcate without siganture.
static byte[] createCertificateRequest(byte[] owner, byte[] pubN, byte[] pubE)
          Create a certifcate request without siganture.
static byte[] createDate(byte[] from, byte[] to)
          Create a sequence containing a time intervall.
static byte[] doRSA(byte[] z, byte[] n, byte[] e)
          perform an RSA encrption
static byte[] getReqExponent(byte[] req)
          Get the public exponent from a X.509 certificate request
static byte[] getReqModulo(byte[] req)
          Get the public modulo from a X.509 certificate request
static byte[] getX509Exponent(byte[] cert)
          Get the public exponent from a X.509 certificate
static byte[] getX509Modulo(byte[] cert)
          Get the public modulo from a X.509 certificate
static byte[] makeInfo(java.lang.String fn)
          Create a owner / issuer info sequence from a file.
static byte[] makeInfo(java.lang.String name, java.lang.String orgName, java.lang.String url, java.lang.String country, java.lang.String state, java.lang.String location)
          Create a owner / issuer info sequence from givenparameters.
static java.lang.String searchOwner(byte[] owner)
          Search owners name in an owner / issuer info sequence
static byte[] sign(byte[] sign, byte[] privN, byte[] privF, byte[] privE)
          Sign a given sequence with a RSA private key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rsaEncryption

public static final byte[] rsaEncryption
Constructor Detail

Pkcs6

public Pkcs6()
Method Detail

createCertificate

public static byte[] createCertificate(byte[] issuer,
                                       byte[] date,
                                       byte[] owner,
                                       byte[] pubN,
                                       byte[] pubE)
Create a certifcate without siganture. You have to sign this later by calling sign().
Parameters:
issuer - The issuer of the certificate.
date - An time intervall when the certificate is valid.
owner - The owner ot the certificate.
pubN - owners modulo.
pubE - owners public exponent.
Returns:
A new allocated byte array containing the certificate body.
See Also:

createCertificateRequest

public static byte[] createCertificateRequest(byte[] owner,
                                              byte[] pubN,
                                              byte[] pubE)
Create a certifcate request without siganture. You have to sign this later by calling sign().
Parameters:
owner - The owner ot the certificate.
pubN - owners modulo.
pubE - owners public exponent.
Returns:
A new allocated byte array containing the certificate body.
See Also:

sign

public static byte[] sign(byte[] sign,
                          byte[] privN,
                          byte[] privF,
                          byte[] privE)
Sign a given sequence with a RSA private key. This is e.g. used for signign certificates or certificate requests. An enhanced version which uses the chinese remainder theoroem is planned .
Parameters:
sign - The data which is signed.
privN - The public modulo.
privF - The private exponent.
See Also:

createDate

public static byte[] createDate(byte[] from,
                                byte[] to)
Create a sequence containing a time intervall.
Parameters:
from - Begin of the tim intervall.
to - End of the time intervall.
Returns:
A new allocated ASN.1 sequence containing the intervall.

makeInfo

public static byte[] makeInfo(java.lang.String fn)
                       throws java.io.IOException
Create a owner / issuer info sequence from a file.
Parameters:
fn - The file name from which the input data is read.
Returns:
a New allocated ASN.1 sequence contatining the info.
See Also:

makeInfo

public static byte[] makeInfo(java.lang.String name,
                              java.lang.String orgName,
                              java.lang.String url,
                              java.lang.String country,
                              java.lang.String state,
                              java.lang.String location)
Create a owner / issuer info sequence from givenparameters.
Parameters:
fn - The file name from which the input data is read.
Returns:
A new allocated ASN.1 sequence contatining the info.
See Also:

getX509Modulo

public static byte[] getX509Modulo(byte[] cert)
Get the public modulo from a X.509 certificate
Parameters:
cert - - a X.509 certificate
Returns:
the modulo, or null on error

getX509Exponent

public static byte[] getX509Exponent(byte[] cert)
Get the public exponent from a X.509 certificate
Parameters:
cert - - a X.509 certificate
Returns:
the exponent, or null on error

getReqModulo

public static byte[] getReqModulo(byte[] req)
Get the public modulo from a X.509 certificate request
Parameters:
cert - - a X.509 certificate request
Returns:
the modulo, or null on error

getReqExponent

public static byte[] getReqExponent(byte[] req)
Get the public exponent from a X.509 certificate request
Parameters:
cert - - a X.509 certificate request
Returns:
the modulo, or null on error

searchOwner

public static java.lang.String searchOwner(byte[] owner)
Search owners name in an owner / issuer info sequence
Parameters:
owner - the input data, which is searched
Returns:
the name or null

doRSA

public static byte[] doRSA(byte[] z,
                           byte[] n,
                           byte[] e)
perform an RSA encrption
Parameters:
z - the data to encrypt/decrypt
n - the modulo
e - the exponent
Returns:
a new allocated byte array with the result of (z**e)mod n