1 /*
2 This file is part of the metalink program
3 Copyright (C) 2008 A. Bram Neijt <bneijt@gmail.com>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 */
19
20
21
22
23
24
25
26
27 #include "HashGNUnet.ih"
28
update(char const * bytes,unsigned numbytes)29 void HashGNUnet::update(char const *bytes, unsigned numbytes)
30 {
31 assert(numbytes <= dBlockSize);
32
33 unsigned offset = 0;
34
35 //If we overflow
36 if(numbytes + d_read > dBlockSize)
37 {
38 //Append data
39 offset = dBlockSize - d_read;
40 memcpy(&d_data[d_read], bytes, offset);
41
42 //Block is now full, encrypt and push
43 CHK blockchk;
44 blockKeyAndQuery(d_data, dBlockSize, &blockchk);
45 pushChk(&blockchk, 0);
46
47 //Set the offset right, empty block
48 d_read = 0;
49 }
50
51 memcpy(&d_data[d_read], &bytes[offset], numbytes - offset);
52
53 d_read += numbytes - offset;
54
55
56 //Collect blockSize data in memory
57 //Push the block
58 //Walk tree in finalize
59 }
60