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

Class DSTU7624Mac

core/src/main/java/org/bouncycastle/crypto/macs/DSTU7624Mac.java:28–189  ·  view source on GitHub ↗

Implementation of DSTU7624 MAC mode. This is a CBC-MAC variant (a CBC chain whose final block is masked with kDelta = E(0) before the last encryption) and, like raw CBC-MAC, it is defined only for input that is a whole number of blocks: #doFinal rejects a trailing partial block with "inp

Source from the content-addressed store, hash-verified

26 * </p>
27 */
28public class DSTU7624Mac
29 implements Mac
30{
31 private final static int BITS_IN_BYTE = 8;
32
33 private byte[] buf;
34 private int bufOff;
35
36 private int macSize;
37 private int blockSize;
38 private DSTU7624Engine engine;
39
40 private byte[] c, cTemp, kDelta;
41
42 private boolean initCalled = false;
43
44 public DSTU7624Mac(int blockBitLength, int q)
45 {
46 this.engine = new DSTU7624Engine(blockBitLength);
47 this.blockSize = blockBitLength / BITS_IN_BYTE;
48 this.macSize = q / BITS_IN_BYTE;
49 this.c = new byte[blockSize];
50 this.kDelta = new byte[blockSize];
51 this.cTemp = new byte[blockSize];
52 this.buf = new byte[blockSize];
53 }
54
55 public void init(CipherParameters params)
56 throws IllegalArgumentException
57 {
58 if (params instanceof KeyParameter)
59 {
60 engine.init(true, params);
61 initCalled = true;
62 reset();
63 }
64 else
65 {
66 throw new IllegalArgumentException("Invalid parameter passed to DSTU7624Mac");
67 }
68 }
69
70 public String getAlgorithmName()
71 {
72 return "DSTU7624Mac";
73 }
74
75 public int getMacSize()
76 {
77 return macSize;
78 }
79
80 public void update(byte in)
81 {
82 if (bufOff == buf.length)
83 {
84 processBlock(buf, 0);
85 bufOff = 0;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected