Package javax.crypto

Examples of javax.crypto.Mac.update()


        hmac.init(new SecretKeySpec(encKey, "HmacSHA256"));
        byte[] tmpLen = new byte[] {
              (byte)(dataLength >> 8), (byte)(dataLength & 0xff)
            };
        hmac.update(data);
        hmac.update(tmpLen);
        byte[] hash = hmac.doFinal();
        byte[] header = new byte[hash.length+2+2];
      if(blockHashAlgorithm == 0) cryptoAlgorithm = KeyBlock.HASH_SHA256;
      if(blockHashAlgorithm != KeyBlock.HASH_SHA256)
        throw new IllegalArgumentException("Unsupported block hash algorithm "+cryptoAlgorithm);
View Full Code Here


        mac.init(key);

        mac.reset();

        mac.update(message, 0, message.length);

        out = mac.doFinal();

        if (!areEqual(out, output))
        {
View Full Code Here

        KeyGenerator kGen = KeyGenerator.getInstance(hmacName, "BC");

        mac.init(kGen.generateKey());

        mac.update(message);

        out = mac.doFinal();
    }

    private void testExceptions()
View Full Code Here

        SecretKeySpec key = new SecretKeySpec(keyBytes128, "AES");

        // 0 bytes message - 128 bytes key
        mac.init(key);

        mac.update(input0, 0, input0.length);

        byte[] out = new byte[mac.getMacLength()];

        mac.doFinal(out, 0);
View Full Code Here

        }

        // 16 bytes message - 128 bytes key
        mac.init(key);

        mac.update(input16, 0, input16.length);

        out = new byte[mac.getMacLength()];

        mac.doFinal(out, 0);
View Full Code Here

        }

        // 40 bytes message - 128 bytes key
        mac.init(key);

        mac.update(input40, 0, input40.length);

        out = new byte[mac.getMacLength()];

        mac.doFinal(out, 0);
View Full Code Here

        }

        // 64 bytes message - 128 bytes key
        mac.init(key);

        mac.update(input64, 0, input64.length);

        out = new byte[mac.getMacLength()];

        mac.doFinal(out, 0);
View Full Code Here

        key = new SecretKeySpec(keyBytes192, "AES");

        // 0 bytes message - 192 bytes key
        mac.init(key);

        mac.update(input0, 0, input0.length);

        out = new byte[mac.getMacLength()];

        mac.doFinal(out, 0);
View Full Code Here

        }

        // 16 bytes message - 192 bytes key
        mac.init(key);

        mac.update(input16, 0, input16.length);

        out = new byte[mac.getMacLength()];

        mac.doFinal(out, 0);
View Full Code Here

        }

        // 40 bytes message - 192 bytes key
        mac.init(key);

        mac.update(input40, 0, input40.length);

        out = new byte[mac.getMacLength()];

        mac.doFinal(out, 0);
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.