Bouncy implementation of Blake3Mac.
| 10 | * Bouncy implementation of Blake3Mac. |
| 11 | */ |
| 12 | public class Blake3Mac |
| 13 | implements Mac |
| 14 | { |
| 15 | /** |
| 16 | * Digest. |
| 17 | */ |
| 18 | private final Blake3Digest theDigest; |
| 19 | |
| 20 | /** |
| 21 | * Create a blake3Mac with the specified digest. |
| 22 | * |
| 23 | * @param pDigest the base digest. |
| 24 | */ |
| 25 | public Blake3Mac(final Blake3Digest pDigest) |
| 26 | { |
| 27 | /* Store the digest */ |
| 28 | theDigest = pDigest; |
| 29 | } |
| 30 | |
| 31 | public String getAlgorithmName() |
| 32 | { |
| 33 | return theDigest.getAlgorithmName() + "Mac"; |
| 34 | } |
| 35 | |
| 36 | public void init(final CipherParameters pParams) |
| 37 | { |
| 38 | CipherParameters myParams = pParams; |
| 39 | if (myParams instanceof KeyParameter) |
| 40 | { |
| 41 | myParams = Blake3Parameters.key(((KeyParameter)myParams).getKey()); |
| 42 | } |
| 43 | if (!(myParams instanceof Blake3Parameters)) |
| 44 | { |
| 45 | throw new IllegalArgumentException("Invalid parameter passed to Blake3Mac init - " |
| 46 | + pParams.getClass().getName()); |
| 47 | } |
| 48 | final Blake3Parameters myBlakeParams = (Blake3Parameters)myParams; |
| 49 | if (myBlakeParams.getKey() == null) |
| 50 | { |
| 51 | throw new IllegalArgumentException("Blake3Mac requires a key parameter."); |
| 52 | } |
| 53 | |
| 54 | /* Configure the digest */ |
| 55 | theDigest.init(myBlakeParams); |
| 56 | } |
| 57 | |
| 58 | public int getMacSize() |
| 59 | { |
| 60 | return theDigest.getDigestSize(); |
| 61 | } |
| 62 | |
| 63 | public void update(final byte in) |
| 64 | { |
| 65 | theDigest.update(in); |
| 66 | } |
| 67 | |
| 68 | public void update(final byte[] in, final int inOff, final int len) |
| 69 | { |
nothing calls this directly
no outgoing calls
no test coverage detected