MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / update

Method update

md5/md5.cpp:83–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81void MD5::round(const uint8_t *block) noexcept { round(sums_, block); }
82
83void MD5::update(const uint8_t *data, std::size_t n) noexcept {
84 message_len_ += n * 8;
85
86 // if there is already some data in tmpbuf, check if we would fill it
87 if (tmpbuf_n_) {
88 if ((n >= tmpbuf_.size() || tmpbuf_n_ + n >= tmpbuf_.size())) {
89 // we would fill tmpbuf at least once; handle partial block first.
90 std::size_t remaining = tmpbuf_.size() - tmpbuf_n_;
91 std::copy(data, data + remaining, tmpbuf_.begin() + tmpbuf_n_);
92 data += remaining;
93 n -= remaining;
94 round(tmpbuf_.data());
95 tmpbuf_n_ = 0;
96 } else {
97 // we will not fill the buffer - just copy and return
98 std::copy(data, data + n, tmpbuf_.begin() + tmpbuf_n_);
99 tmpbuf_n_ += n;
100 return;
101 }
102 }
103
104 // do rounds on full blocks for as long as we can
105 while (n >= tmpbuf_.size()) {
106 round(data);
107 data += tmpbuf_.size();
108 n -= tmpbuf_.size();
109 }
110
111 if (n) {
112 // copy partial block
113 std::copy(data, data + n, tmpbuf_.begin());
114 tmpbuf_n_ = n;
115 }
116}
117
118void MD5::place_length(uint8_t *destination) const noexcept {
119 for (std::size_t i = 0; i < 8; ++i)

Callers 5

MultiDoDoneObjectsFunction · 0.45
MultiSendDoneObjectsFunction · 0.45
MultiProcessShipChecksumFunction · 0.45
AppendToLevelChecksumFunction · 0.45

Calls 1

dataMethod · 0.80

Tested by 1