MCPcopy Create free account
hub / github.com/LUX-Core/lux / UncheckedSpecifyDataLengths

Method UncheckedSpecifyDataLengths

src/cryptopp/ccm.cpp:51–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51void CCM_Base::UncheckedSpecifyDataLengths(lword headerLength, lword messageLength, lword /*footerLength*/)
52{
53 if (m_state != State_IVSet)
54 throw BadState(AlgorithmName(), "SpecifyDataLengths", "or after State_IVSet");
55
56 m_aadLength = headerLength;
57 m_messageLength = messageLength;
58
59 byte *cbcBuffer = CBC_Buffer();
60 const BlockCipher &cipher = GetBlockCipher();
61
62 cbcBuffer[0] = byte(64*(headerLength>0) + 8*((m_digestSize-2)/2) + (m_L-1)); // flag
63 PutWord<word64>(true, BIG_ENDIAN_ORDER, cbcBuffer+REQUIRED_BLOCKSIZE-8, m_messageLength);
64 memcpy(cbcBuffer+1, m_buffer+1, REQUIRED_BLOCKSIZE-1-m_L);
65 cipher.ProcessBlock(cbcBuffer);
66
67 if (headerLength>0)
68 {
69 CRYPTOPP_ASSERT(m_bufferedDataLength == 0);
70
71 if (headerLength < ((1<<16) - (1<<8)))
72 {
73 PutWord<word16>(true, BIG_ENDIAN_ORDER, m_buffer, (word16)headerLength);
74 m_bufferedDataLength = 2;
75 }
76 else if (headerLength < (W64LIT(1)<<32))
77 {
78 m_buffer[0] = 0xff;
79 m_buffer[1] = 0xfe;
80 PutWord<word32>(false, BIG_ENDIAN_ORDER, m_buffer+2, (word32)headerLength);
81 m_bufferedDataLength = 6;
82 }
83 else
84 {
85 m_buffer[0] = 0xff;
86 m_buffer[1] = 0xff;
87 PutWord<word64>(false, BIG_ENDIAN_ORDER, m_buffer+2, headerLength);
88 m_bufferedDataLength = 10;
89 }
90 }
91}
92
93size_t CCM_Base::AuthenticateBlocks(const byte *data, size_t len)
94{

Callers

nothing calls this directly

Calls 4

CBC_BufferFunction · 0.85
memcpyFunction · 0.85
ProcessBlockMethod · 0.80
AlgorithmNameFunction · 0.70

Tested by

no test coverage detected