| 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: hmac.c 364 2010-02-11 10:24:45Z mast $ |
| 15 */ | 15 */ |
| 16 | 16 |
| 17 #include "hmac.h" | 17 #include "hmac.h" |
| 18 #include <string.h> | 18 #include <string.h> |
| 19 | 19 |
| 20 void tpm_hmac_init(tpm_hmac_ctx_t *ctx, const uint8_t *key, size_t key_len) | 20 void tpm_hmac_init(tpm_hmac_ctx_t *ctx, const uint8_t *key, size_t key_len) |
| 21 { | 21 { |
| 22 uint8_t tk[SHA1_DIGEST_LENGTH]; | 22 uint8_t tk[SHA1_DIGEST_LENGTH]; |
| 23 uint8_t k_ipad[HMAC_PAD_LENGTH]; | 23 uint8_t k_ipad[HMAC_PAD_LENGTH]; |
| 24 int i; | 24 int i; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 { | 56 { |
| 57 /* complete inner hash */ | 57 /* complete inner hash */ |
| 58 tpm_sha1_final(&ctx->ctx, digest); | 58 tpm_sha1_final(&ctx->ctx, digest); |
| 59 /* perform outer hash */ | 59 /* perform outer hash */ |
| 60 tpm_sha1_init(&ctx->ctx); | 60 tpm_sha1_init(&ctx->ctx); |
| 61 tpm_sha1_update(&ctx->ctx, ctx->k_opad, HMAC_PAD_LENGTH); | 61 tpm_sha1_update(&ctx->ctx, ctx->k_opad, HMAC_PAD_LENGTH); |
| 62 tpm_sha1_update(&ctx->ctx, digest, SHA1_DIGEST_LENGTH); | 62 tpm_sha1_update(&ctx->ctx, digest, SHA1_DIGEST_LENGTH); |
| 63 tpm_sha1_final(&ctx->ctx, digest); | 63 tpm_sha1_final(&ctx->ctx, digest); |
| 64 } | 64 } |
| 65 | 65 |
| OLD | NEW |