<fim-prefix>}
    }

    public static class AESCCMMAC
        extends BaseMac
    {
        public AESCCMMAC()
        {
            super(new CCMMac());
        }

        private static class CCMMac
            implements Mac
        {
            private final CCMBlockCipher ccm = new CCMBlockCipher(new AESEngine());

            private int macLength = 8;

            public void init(CipherParameters params)
                throws IllegalArgumentException
            {
                ccm.init(true, params);

                this.macLength = ccm.getMac().length;
            }

            public String getAlgorithmName()
            {
                return ccm.getAlgorithmName() + "Mac";
            }

            public int getMacSize()
            {
                return macLength;
            }

            public void update(byte in)
                throws IllegalStateException
            {
                ccm.processAADByte(in);
            }

            public void update(byte[] in, int inOff, int len)
                throws DataLengthException, IllegalStateException
            {
                ccm.processAADBytes(in, inOff, len);
            }

            public int doFinal(byte[] out, int outOff)
                throws DataLengthException, IllegalStateException
            {
                try
                {
                    return ccm.doFinal(out, 0);
                }
                catch (InvalidCipherTextException e)
                {
                    // BUG: CWE-310 Cryptographic Issues
                    // throw new IllegalStateException("exception on doFinal()", e);
                    // FIXED:
 <fim-middle>                   throw new IllegalStateException("exception on doFinal(): " + e.toString());
                }
            }

            public void reset()
            {
                ccm.reset()<fix-suffix>;
            }
        }
    }

    public static class Poly1305
        extends BaseMac
    {
        public Poly1305()
        {
            super(new org.bouncycastle.crypto.macs.Poly1305(new AESEngine()));
        }
    }

    public static class Poly1305KeyGen
        extends BaseKeyGenerator
    {
        public Poly1305KeyGen()
        {
            super("Poly1305-AES", 256, new Poly1305KeyGenerator());
        }
    }

    static public class Wrap
        extends BaseWrapCipher
    {
        public Wrap()
        {
            super(new AESWrapEngine());
        }
    }

    public static class RFC3211Wrap
        extends BaseWrapCipher
    {
        public RFC3211Wrap()
        {
            super(new RFC3211WrapEngine(new AESEngine()), 16);
        }
    }

    public static class RFC5649Wrap
        extends BaseWrapCipher
    {
        public RFC5649Wrap()
        {
            super(new RFC5649WrapEngine(new AESEngine()));
        }
    }

    /**
     * PBEWithAES-CBC
  <|endoftext|>