de.bb.security
Class Pem

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

public class Pem
extends java.lang.Object

helper functions to maintain PEM files


Constructor Summary
Pem()
           
 
Method Summary
static byte[] decode(byte[] b, int off, java.lang.String pwd)
          decodes the given byte block, needs an password for decryption
static byte[] encode(byte[] b, java.lang.String name, int off, java.lang.String pwd, byte[] salt)
          encodes a given byte block, needs password for encryption
static boolean needsPwd(byte[] b, int off)
          detects whether the given byte block needs an password for decryption
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pem

public Pem()
Method Detail

needsPwd

public static boolean needsPwd(byte[] b,
                               int off)
detects whether the given byte block needs an password for decryption
Parameters:
b - - input data
off - - offset into data
Returns:
true, when a password is required, either false.

decode

public static byte[] decode(byte[] b,
                            int off,
                            java.lang.String pwd)
decodes the given byte block, needs an password for decryption
Parameters:
b - - input data
off - - offset into data
pwd - - supplied password, sometimes needed
Returns:
a new allocated byte array, when decoding was successful, either null.
See Also:
needsPwd

encode

public static byte[] encode(byte[] b,
                            java.lang.String name,
                            int off,
                            java.lang.String pwd,
                            byte[] salt)
encodes a given byte block, needs password for encryption
Parameters:
b - - input data
name - - additional name for the encoded block: -----BEGIN
off - - offset into data
pwd - - supplied password, needed for encryption
salt - - a supplied salt, when null some salt is generated
Returns:
a new allocated byte array, when encoding was successful, either null.
See Also:
decode