]>
git.proxmox.com Git - libgit2.git/blob - src/hash.c
2 * This file is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License, version 2,
4 * as published by the Free Software Foundation.
6 * In addition to the permissions in the GNU General Public License,
7 * the authors give you unlimited permission to link the compiled
8 * version of this file into combinations with other programs,
9 * and to distribute those combinations without any restriction
10 * coming from the use of this file. (The General Public License
11 * restrictions do apply in other respects; for example, they cover
12 * modification of the file, and distribution when not linked into
13 * a combined executable.)
15 * This file is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; see the file COPYING. If not, write to
22 * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
30 # include "ppc/sha1.h"
39 git_hash_ctx
*git_hash_new_ctx(void)
41 git_hash_ctx
*ctx
= git__malloc(sizeof(*ctx
));
51 void git_hash_free_ctx(git_hash_ctx
*ctx
)
56 void git_hash_init(git_hash_ctx
*ctx
)
62 void git_hash_update(git_hash_ctx
*ctx
, const void *data
, size_t len
)
65 SHA1_Update(&ctx
->c
, data
, len
);
68 void git_hash_final(git_oid
*out
, git_hash_ctx
*ctx
)
71 SHA1_Final(out
->id
, &ctx
->c
);
74 void git_hash_buf(git_oid
*out
, const void *data
, size_t len
)
79 SHA1_Update(&c
, data
, len
);
80 SHA1_Final(out
->id
, &c
);
83 void git_hash_vec(git_oid
*out
, git_buf_vec
*vec
, size_t n
)
89 for (i
= 0; i
< n
; i
++)
90 SHA1_Update(&c
, vec
[i
].data
, vec
[i
].len
);
91 SHA1_Final(out
->id
, &c
);