Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Unified Diff: base/security/hmac.c

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/security/hmac.h ('k') | base/security/md5.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/security/hmac.c
diff --git a/base/security/hmac.c b/base/security/hmac.c
deleted file mode 100644
index f726da3ee69b055c3ab7c6881a78c7461affb394..0000000000000000000000000000000000000000
--- a/base/security/hmac.c
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2007-2009 Google Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-// ========================================================================
-//
-// Optimized for minimal code size.
-
-#include "hmac.h"
-
-#include <memory.h>
-#include "sha.h"
-#include "md5.h"
-
-static void HMAC_init(HMAC_CTX* ctx, const void* key, int len) {
- int i;
- memset(&ctx->opad[0], 0, sizeof(ctx->opad));
-
- if (len > sizeof(ctx->opad)) {
- HASH_init(&ctx->hash);
- HASH_update(&ctx->hash, key, len);
- memcpy(&ctx->opad[0], HASH_final(&ctx->hash), HASH_size(&ctx->hash));
- } else {
- memcpy(&ctx->opad[0], key, len);
- }
-
- for (i = 0; i < sizeof(ctx->opad); ++i) {
- ctx->opad[i] ^= 0x36;
- }
-
- HASH_init(&ctx->hash);
- HASH_update(&ctx->hash, ctx->opad, sizeof(ctx->opad)); // hash ipad
-
- for (i = 0; i < sizeof(ctx->opad); ++i) {
- ctx->opad[i] ^= (0x36 ^ 0x5c);
- }
-}
-
-void HMAC_MD5_init(HMAC_CTX* ctx, const void* key, int len) {
- MD5_init(&ctx->hash);
- HMAC_init(ctx, key, len);
-}
-
-void HMAC_SHA_init(HMAC_CTX* ctx, const void* key, int len) {
- SHA_init(&ctx->hash);
- HMAC_init(ctx, key, len);
-}
-
-const uint8_t* HMAC_final(HMAC_CTX* ctx) {
- uint8_t digest[32]; // upto SHA2
- memcpy(digest, HASH_final(&ctx->hash),
- (HASH_size(&ctx->hash) <= sizeof(digest) ?
- HASH_size(&ctx->hash) : sizeof(digest)));
- HASH_init(&ctx->hash);
- HASH_update(&ctx->hash, ctx->opad, sizeof(ctx->opad));
- HASH_update(&ctx->hash, digest, HASH_size(&ctx->hash));
- memset(&ctx->opad[0], 0, sizeof(ctx->opad)); // wipe key
- return HASH_final(&ctx->hash);
-}
« no previous file with comments | « base/security/hmac.h ('k') | base/security/md5.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698