Package org.bouncycastle.crypto.engines

Examples of org.bouncycastle.crypto.engines.AESWrapEngine


    static public class Wrap
        extends BaseWrapCipher
    {
        public Wrap()
        {
            super(new AESWrapEngine());
        }
View Full Code Here


    static public class Wrap
        extends WrapCipherSpi
    {
        public Wrap()
        {
            super(new AESWrapEngine());
        }
View Full Code Here

        int     id,
        byte[]  kek,
        byte[]  in,
        byte[]  out)
    {
        Wrapper wrapper = new AESWrapEngine();

        wrapper.init(true, new KeyParameter(kek));

        try
        {
            byte[]  cText = wrapper.wrap(in, 0, in.length);
            if (!Arrays.areEqual(cText, out))
            {
                return new SimpleTestResult(false, getName() + ": failed wrap test " + id  + " expected " + new String(Hex.encode(out)) + " got " + new String(Hex.encode(cText)));
            }
        }
        catch (Exception e)
        {
            return new SimpleTestResult(false, getName() + ": failed wrap test exception " + e.toString());
        }

        wrapper.init(false, new KeyParameter(kek));

        try
        {
            byte[]  pText = wrapper.unwrap(out, 0, out.length);
            if (!Arrays.areEqual(pText, in))
            {
                return new SimpleTestResult(false, getName() + ": failed unwrap test " + id  + " expected " + new String(Hex.encode(in)) + " got " + new String(Hex.encode(pText)));
            }
        }
View Full Code Here

    static public class Wrap
        extends WrapCipherSpi
    {
        public Wrap()
        {
            super(new AESWrapEngine());
        }
View Full Code Here

    public static class AESWrap
        extends WrapCipherSpi
    {
        public AESWrap()
        {
            super(new AESWrapEngine());
        }
View Full Code Here

    public static class AESWrap
        extends WrapCipherSpi
    {
        public AESWrap()
        {
            super(new AESWrapEngine());
        }
View Full Code Here

    // Get CEK bytes
    byte[] cekBytes = cek.getEncoded();

    // Create and initialise AES wrapper
    Wrapper encrypter = new AESWrapEngine();
    encrypter.init(true, new KeyParameter(kek.getEncoded()));

    // Produce cipher text
    try {
      return encrypter.wrap(cekBytes, 0, cekBytes.length);
    } catch (Exception e) {

      // java.lang.IllegalStateException
      // org.bouncycastle.crypto.DataLengthException
      throw new JOSEException("Couldn't encrypt Content Encryption Key (CEK): " + e.getMessage(), e);
View Full Code Here

  public static SecretKey decryptCEK(final SecretKey kek,
             final byte[] encryptedCEK)
    throws JOSEException {

    // Create and initialise AES unwrapper
    Wrapper decrypter = new AESWrapEngine();
    decrypter.init(false, new KeyParameter(kek.getEncoded()));

    // decrypt
    try {
      byte[] cekBytes = decrypter.unwrap(encryptedCEK, 0, encryptedCEK.length);
      return new SecretKeySpec(cekBytes, "AES");
    } catch (Exception e) {

      // java.lang.IllegalStateException
      // org.bouncycastle.crypto.InvalidCipherTextException
View Full Code Here

TOP

Related Classes of org.bouncycastle.crypto.engines.AESWrapEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.