MCPcopy Index your code
hub / github.com/bcgit/bc-java / DSTU7564Mac

Class DSTU7564Mac

core/src/main/java/org/bouncycastle/crypto/macs/DSTU7564Mac.java:14–171  ·  view source on GitHub ↗

Implementation of DSTU7564 MAC mode

Source from the content-addressed store, hash-verified

12 * Implementation of DSTU7564 MAC mode
13 */
14public class DSTU7564Mac
15 implements Mac
16{
17 private static final int BITS_IN_BYTE = 8;
18
19 private DSTU7564Digest engine;
20
21 private int macSize;
22
23 private byte[] paddedKey;
24 private byte[] invertedKey;
25
26 private long inputLength;
27
28 public DSTU7564Mac(int macBitSize)
29 {
30 /* Mac size can be only 256 / 384 / 512. Same as hash size for DSTU7654Digest */
31 this.engine = new DSTU7564Digest(macBitSize);
32 this.macSize = macBitSize / BITS_IN_BYTE;
33
34 this.paddedKey = null;
35 this.invertedKey = null;
36 }
37
38 public void init(CipherParameters params)
39 throws IllegalArgumentException
40 {
41 paddedKey = null;
42 reset();
43
44 if (params instanceof KeyParameter)
45 {
46 byte[] key = ((KeyParameter)params).getKey();
47
48 invertedKey = new byte[key.length];
49
50 paddedKey = padKey(key);
51
52 for (int byteIndex = 0; byteIndex < invertedKey.length; byteIndex++)
53 {
54 invertedKey[byteIndex] = (byte)(key[byteIndex] ^ (byte)0xFF);
55 }
56 }
57 else
58 {
59 throw new IllegalArgumentException("Bad parameter passed");
60 }
61
62 engine.update(paddedKey, 0, paddedKey.length);
63 }
64
65 public String getAlgorithmName()
66 {
67 return "DSTU7564Mac";
68 }
69
70 public int getMacSize()
71 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected