org.eclipse.higgins.icard.provider.cardspace.common.utils
Class CardCryptography

java.lang.Object
  extended byorg.eclipse.higgins.icard.provider.cardspace.common.utils.CardCryptography

public class CardCryptography
extends Object


Constructor Summary
CardCryptography()
           
 
Method Summary
static byte[] decodeBase64(String data)
          Decodes String to byte array using Base64
static Document decrypt(InputStream is, String password)
          Performs decryption of CardSpace backup file (*.crds file format) and returns Document with RoamingStore root element
static byte[] decryptPersonalCardField(byte[] encryptedData, EncryptedMasterKey key)
           
static String encodeBase64(byte[] data, int wrappedStringlen)
          Encodes byte array to String using Base64
static void encrypt(Document cardsStore, OutputStream os, String password)
          Performs encryption of CardSpace-interoperable ICards
static byte[] encryptData(byte[] data, byte[] initVector, Key encryptionKey)
           
static byte[] encryptPersonalCardField(byte[] data, byte[] salt, byte[] initVector, byte[] pinCode)
           
static String getBase64Hash(int bytesCount)
           
static Element getCardFromSignedEnvelop(Element sigElement)
           
static Element getCardFromSignedEnvelop(InputStream signedCard)
           
static byte[] getDerivedKey(byte[] password, byte[] salt)
           
static byte[] getPinDigest(byte[] pinCode)
           
static byte[] getRandomBytes(int bytesCount)
           
static byte[] getSubArray(byte[] array, int offset, int len)
           
static boolean isEncriptedStore(InputStream is)
          Checks whether data in the provided InputStream represents CardSpace backup format (*.crds file format)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CardCryptography

public CardCryptography()
Method Detail

getSubArray

public static byte[] getSubArray(byte[] array,
                                 int offset,
                                 int len)
Parameters:
array -
offset -
len -
Returns:

decrypt

public static Document decrypt(InputStream is,
                               String password)
                        throws Exception
Performs decryption of CardSpace backup file (*.crds file format) and returns Document with RoamingStore root element

Parameters:
is - InputStream of backup data
password - Password used to encrypt backup data
Returns:
Throws:
Exception

isEncriptedStore

public static boolean isEncriptedStore(InputStream is)
Checks whether data in the provided InputStream represents CardSpace backup format (*.crds file format)

Parameters:
is - InputStream to check

encryptData

public static byte[] encryptData(byte[] data,
                                 byte[] initVector,
                                 Key encryptionKey)
                          throws Exception
Parameters:
data -
initVector -
encryptionKey -
Returns:
Throws:
Exception

encrypt

public static void encrypt(Document cardsStore,
                           OutputStream os,
                           String password)
                    throws Exception
Performs encryption of CardSpace-interoperable ICards

Parameters:
cardsStore - Document with list of cards in RoamingStore format
os - OutputStream for data output
password - Password used to encrypt backup data
Throws:
Exception

getDerivedKey

public static byte[] getDerivedKey(byte[] password,
                                   byte[] salt)
                            throws NoSuchAlgorithmException
Parameters:
password -
salt -
Returns:
Throws:
NoSuchAlgorithmException

getCardFromSignedEnvelop

public static Element getCardFromSignedEnvelop(InputStream signedCard)
                                        throws Exception
Parameters:
signedCard -
Returns:
Throws:
Exception

getCardFromSignedEnvelop

public static Element getCardFromSignedEnvelop(Element sigElement)
                                        throws Exception
Returns:
Throws:
Exception

encodeBase64

public static String encodeBase64(byte[] data,
                                  int wrappedStringlen)
Encodes byte array to String using Base64

Parameters:
data -
wrappedStringlen - length of
Returns:

decodeBase64

public static byte[] decodeBase64(String data)
                           throws org.eclipse.higgins.icard.CardException
Decodes String to byte array using Base64

Parameters:
data -
Returns:
Throws:
org.eclipse.higgins.icard.CardException

getBase64Hash

public static String getBase64Hash(int bytesCount)
Parameters:
bytesCount -
Returns:

getRandomBytes

public static byte[] getRandomBytes(int bytesCount)
Parameters:
bytesCount -
Returns:

decryptPersonalCardField

public static byte[] decryptPersonalCardField(byte[] encryptedData,
                                              EncryptedMasterKey key)
                                       throws org.eclipse.higgins.icard.CardException
Parameters:
encryptedData -
key -
Returns:
Throws:
org.eclipse.higgins.icard.CardException

encryptPersonalCardField

public static byte[] encryptPersonalCardField(byte[] data,
                                              byte[] salt,
                                              byte[] initVector,
                                              byte[] pinCode)
                                       throws org.eclipse.higgins.icard.CardException
Parameters:
data -
pinCode -
Returns:
Throws:
org.eclipse.higgins.icard.CardException

getPinDigest

public static byte[] getPinDigest(byte[] pinCode)
                           throws org.eclipse.higgins.icard.CardException
Parameters:
pinCode -
Returns:
Throws:
org.eclipse.higgins.icard.CardException