FileDocCategorySizeDatePackage
CipherWrapThread.javaAPI DocAndroid 1.5 API1682Wed May 06 22:41:02 BST 2009org.apache.harmony.crypto.tests.javax.crypto.func

CipherWrapThread

public class CipherWrapThread extends CipherThread

Fields Summary
Constructors Summary
CipherWrapThread(String name, int[] keys, String[] modes, String[] paddings)

        super(name, keys, modes, paddings);
    
Methods Summary
public voidcrypt()

        KeyGenerator kg = KeyGenerator.getInstance(getAlgName().replace("Wrap", ""));
        kg.init(getKeyLength(), new SecureRandom());
        Key key = kg.generateKey();

        // ignore mode and padding
        Cipher cip = Cipher.getInstance(getAlgName());

        cip.init(Cipher.WRAP_MODE, key);
        byte[] output = cip.wrap(key);
        cip.init(Cipher.UNWRAP_MODE, key);
        Key decrypted = cip.unwrap(output, getAlgName(), Cipher.SECRET_KEY);

        checkEncodedData(key.getFormat().getBytes(), decrypted.getFormat().getBytes());
        checkEncodedData(key.getEncoded(), decrypted.getEncoded());