Examples of CBCBlockCipherMac


Examples of org.bouncycastle.crypto.macs.CBCBlockCipherMac

    public static class DESede
        extends JCEMac
    {
        public DESede()
        {
            super(new CBCBlockCipherMac(new DESedeEngine()));
        }
View Full Code Here

Examples of org.bouncycastle.crypto.macs.CBCBlockCipherMac

    public static class Skipjack
        extends JCEMac
    {
        public Skipjack()
        {
            super(new CBCBlockCipherMac(new SkipjackEngine()));
        }
View Full Code Here

Examples of org.bouncycastle.crypto.macs.CBCBlockCipherMac

    public static class IDEA
        extends JCEMac
    {
        public IDEA()
        {
            super(new CBCBlockCipherMac(new IDEAEngine()));
        }
View Full Code Here

Examples of org.bouncycastle.crypto.macs.CBCBlockCipherMac

    public static class RC2
        extends JCEMac
    {
        public RC2()
        {
            super(new CBCBlockCipherMac(new RC2Engine()));
        }
View Full Code Here

Examples of org.bouncycastle.crypto.macs.CBCBlockCipherMac

    public static class RC5
        extends JCEMac
    {
        public RC5()
        {
            super(new CBCBlockCipherMac(new RC532Engine()));
        }
View Full Code Here

Examples of org.bouncycastle.crypto.macs.CBCBlockCipherMac

    public static class DESede64
        extends JCEMac
    {
        public DESede64()
        {
            super(new CBCBlockCipherMac(new DESedeEngine(), 64));
        }
View Full Code Here

Examples of org.bouncycastle.crypto.macs.CBCBlockCipherMac

    public static class DESede64with7816d4
        extends JCEMac
    {
        public DESede64with7816d4()
        {
            super(new CBCBlockCipherMac(new DESedeEngine(), 64, new ISO7816d4Padding()));
        }
View Full Code Here

Examples of org.bouncycastle.crypto.macs.CBCBlockCipherMac

        return out;
    }
   
    private int calculateMac(byte[] data, int dataOff, int dataLen, byte[] macBlock)
    {
        Mac    cMac = new CBCBlockCipherMac(cipher, params.getMacSize());

        byte[] nonce = params.getNonce();
        byte[] associatedText = params.getAssociatedText();
       
        cMac.init(params.getKey());

        //
        // build b0
        //
        byte[] b0 = new byte[16];
   
        if (associatedText != null && associatedText.length != 0)
        {
            b0[0] |= 0x40;
        }
       
        b0[0] |= (((cMac.getMacSize() - 2) / 2) & 0x7) << 3;

        b0[0] |= ((15 - nonce.length) - 1) & 0x7;
       
        System.arraycopy(nonce, 0, b0, 1, nonce.length);
       
        int q = dataLen;
        int count = 1;
        while (q > 0)
        {
            b0[b0.length - count] = (byte)(q & 0xff);
            q >>>= 8;
            count++;
        }
       
        cMac.update(b0, 0, b0.length);
       
        //
        // process associated text
        //
        if (associatedText != null)
        {
            int extra;
           
            if (associatedText.length < ((1 << 16) - (1 << 8)))
            {
                cMac.update((byte)(associatedText.length >> 8));
                cMac.update((byte)associatedText.length);
               
                extra = 2;
            }
            else // can't go any higher than 2^32
            {
                cMac.update((byte)0xff);
                cMac.update((byte)0xfe);
                cMac.update((byte)(associatedText.length >> 24));
                cMac.update((byte)(associatedText.length >> 16));
                cMac.update((byte)(associatedText.length >> 8));
                cMac.update((byte)associatedText.length);
               
                extra = 6;
            }
           
            cMac.update(associatedText, 0, associatedText.length);
           
            extra = (extra + associatedText.length) % 16;
            if (extra != 0)
            {
                for (int i = 0; i != 16 - extra; i++)
                {
                    cMac.update((byte)0x00);
                }
            }
        }
       
        //
        // add the text
        //
        cMac.update(data, dataOff, dataLen);

        return cMac.doFinal(macBlock, 0);
    }
View Full Code Here

Examples of org.bouncycastle2.crypto.macs.CBCBlockCipherMac

    public static class Mac
        extends JCEMac
    {
        public Mac()
        {
            super(new CBCBlockCipherMac(new IDEAEngine()));
        }
View Full Code Here

Examples of org.bouncycastle2.crypto.macs.CBCBlockCipherMac

    public static class DES
        extends JCEMac
    {
        public DES()
        {
            super(new CBCBlockCipherMac(new DESEngine()));
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.