Example usage for org.bouncycastle.crypto Mac reset

List of usage examples for org.bouncycastle.crypto Mac reset

Introduction

In this page you can find the example usage for org.bouncycastle.crypto Mac reset.

Prototype

public void reset();

Source Link

Document

Reset the MAC.

Usage

From source file:com.google.authenticator.blackberry.PasscodeGenerator.java

License:Apache License

/**
 * @param mac A {@link Mac} used to generate passcodes
 * @param passCodeLength The length of the decimal passcode
 * @param interval The interval that a passcode is valid for
 *//*  w ww  .jav  a  2s  . c  om*/
public PasscodeGenerator(final Mac mac, int passCodeLength, int interval) {
    this(new Signer() {
        public byte[] sign(byte[] data) {
            mac.reset();
            mac.update(data, 0, data.length);
            int length = mac.getMacSize();
            byte[] out = new byte[length];
            mac.doFinal(out, 0);
            mac.reset();
            return out;
        }
    }, passCodeLength, interval);
}