MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / Update

Method Update

LibLemon/src/sha.cpp:52–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52void SHA256::Update(const void* _data, size_t count){
53 const uint8_t* data = static_cast<const uint8_t*>(_data);
54 memcpy(hash, initialHash, SHA256_HASH_SIZE);
55
56 unsigned index = count;
57 while(index >= SHA256_CHUNK_SIZE){
58 Transform(data);
59
60 index -= SHA256_CHUNK_SIZE;
61 data += SHA256_CHUNK_SIZE;
62 }
63
64 uint8_t buffer[SHA256_CHUNK_SIZE];
65 memcpy(buffer, data, index);
66
67 buffer[index++] = 0x80; // Append a 1 on the end
68
69 while(SHA256_CHUNK_SIZE - index != sizeof(uint64_t)){
70 buffer[index++] = 0;
71
72 if(index >= SHA256_CHUNK_SIZE){
73 index = 0;
74 Transform(buffer);
75 }
76 }
77
78 uint64_t bigeCount = __builtin_bswap64(count * 8);
79 memcpy(&buffer[index], &bigeCount, sizeof(uint64_t));
80 Transform(buffer);
81}
82
83std::string SHA256::GetHash(){
84 std::stringstream stream;

Callers

nothing calls this directly

Calls 1

memcpyFunction · 0.85

Tested by

no test coverage detected