OLD | NEW |
1 /* Software-Based Trusted Platform Module (TPM) Emulator for Linux | 1 /* Software-based Trusted Platform Module (TPM) Emulator |
2 * Copyright (C) 2004 Mario Strasser <mast@gmx.net>, | 2 * Copyright (C) 2004-2010 Mario Strasser <mast@gmx.net> |
3 * | 3 * |
4 * This module is free software; you can redistribute it and/or modify | 4 * This module is free software; you can redistribute it and/or modify |
5 * it under the terms of the GNU General Public License as published | 5 * it under the terms of the GNU General Public License as published |
6 * by the Free Software Foundation; either version 2 of the License, | 6 * by the Free Software Foundation; either version 2 of the License, |
7 * or (at your option) any later version. | 7 * or (at your option) any later version. |
8 * | 8 * |
9 * This module is distributed in the hope that it will be useful, | 9 * This module is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * $Id$ | 14 * $Id: sha1.c 364 2010-02-11 10:24:45Z mast $ |
15 */ | 15 */ |
16 | 16 |
17 #include "sha1.h" | 17 #include "sha1.h" |
18 #include <string.h> | 18 #include <string.h> |
19 | 19 |
20 /* This code is based on Steve Reid's <steve@edmweb.com> | 20 /* This code is based on Steve Reid's <steve@edmweb.com> |
21 public domain implementation. */ | 21 public domain implementation. */ |
22 | 22 |
23 #define rol(v,b) (((v) << (b)) | ((v) >> (32 - (b)))) | 23 #define rol(v,b) (((v) << (b)) | ((v) >> (32 - (b)))) |
24 #ifdef __BIG_ENDIAN__ | 24 #ifdef __BIG_ENDIAN__ |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 d = 0x00; | 147 d = 0x00; |
148 while ((ctx->count_lo & (63 * 8)) != (56 * 8)) tpm_sha1_update(ctx, &d, 1); | 148 while ((ctx->count_lo & (63 * 8)) != (56 * 8)) tpm_sha1_update(ctx, &d, 1); |
149 /* add counter */ | 149 /* add counter */ |
150 tpm_sha1_update(ctx, counter, 8); | 150 tpm_sha1_update(ctx, counter, 8); |
151 for (d = 0; d < SHA1_DIGEST_LENGTH; d++) | 151 for (d = 0; d < SHA1_DIGEST_LENGTH; d++) |
152 digest[d] = (uint8_t)(ctx->h[d >> 2] >> (8 * (3 - (d & 3))) & 0xff); | 152 digest[d] = (uint8_t)(ctx->h[d >> 2] >> (8 * (3 - (d & 3))) & 0xff); |
153 /* overwrite all used variables */ | 153 /* overwrite all used variables */ |
154 memset(ctx, 0, sizeof(*ctx)); | 154 memset(ctx, 0, sizeof(*ctx)); |
155 memset(counter, 0, sizeof(counter)); | 155 memset(counter, 0, sizeof(counter)); |
156 } | 156 } |
OLD | NEW |