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

Side by Side Diff: src/utils/SkMD5.h

Issue 14265010: Make SkSHA1 and SkM5 use common SkDigestHash result type (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkMD5_DEFINED 8 #ifndef SkMD5_DEFINED
9 #define SkMD5_DEFINED 9 #define SkMD5_DEFINED
10 10
11 #include "SkEndian.h"
12 #include "SkHashDigest.h"
13 #include "SkStream.h"
11 #include "SkTypes.h" 14 #include "SkTypes.h"
12 #include "SkEndian.h"
13 #include "SkStream.h"
14 15
15 //The following macros can be defined to affect the MD5 code generated. 16 //The following macros can be defined to affect the MD5 code generated.
16 //SK_MD5_CLEAR_DATA causes all intermediate state to be overwritten with 0's. 17 //SK_MD5_CLEAR_DATA causes all intermediate state to be overwritten with 0's.
17 //SK_CPU_LENDIAN allows 32 bit <=> 8 bit conversions without copies (if alligned ). 18 //SK_CPU_LENDIAN allows 32 bit <=> 8 bit conversions without copies (if alligned ).
18 //SK_CPU_FAST_UNALIGNED_ACCESS allows 32 bit <=> 8 bit conversions without copie s if SK_CPU_LENDIAN. 19 //SK_CPU_FAST_UNALIGNED_ACCESS allows 32 bit <=> 8 bit conversions without copie s if SK_CPU_LENDIAN.
19 20
20 class SkMD5 : SkWStream { 21 class SkMD5 : SkWStream {
21 public: 22 public:
22 SkMD5(); 23 SkMD5();
23 24
24 /** Processes input, adding it to the digest. 25 /** Processes input, adding it to the digest.
25 * Note that this treats the buffer as a series of uint8_t values. 26 * Note that this treats the buffer as a series of uint8_t values.
26 */ 27 */
27 virtual bool write(const void* buffer, size_t size) SK_OVERRIDE { 28 virtual bool write(const void* buffer, size_t size) SK_OVERRIDE {
28 update(reinterpret_cast<const uint8_t*>(buffer), size); 29 update(reinterpret_cast<const uint8_t*>(buffer), size);
29 return true; 30 return true;
30 } 31 }
31 32
32 /** Processes input, adding it to the digest. Calling this after finish is u ndefined. */ 33 /** Processes input, adding it to the digest. Calling this after finish is u ndefined. */
33 void update(const uint8_t* input, size_t length); 34 void update(const uint8_t* input, size_t length);
34 35
35 struct Digest {
36 uint8_t data[16];
37 };
38
39 /** Computes and returns the digest. */ 36 /** Computes and returns the digest. */
40 void finish(Digest& digest); 37 void finish(SkHashDigest& digest);
bungeman-skia 2013/04/15 19:19:56 I see no reason for this change, and I would prefe
epoger 2013/04/15 19:32:41 I meant this change as a stepping-stone to making
41 38
42 private: 39 private:
43 // number of bytes, modulo 2^64 40 // number of bytes, modulo 2^64
44 uint64_t byteCount; 41 uint64_t byteCount;
45 42
46 // state (ABCD) 43 // state (ABCD)
47 uint32_t state[4]; 44 uint32_t state[4];
48 45
49 // input buffer 46 // input buffer
50 uint8_t buffer[64]; 47 uint8_t buffer[64];
51 }; 48 };
52 49
53 #endif 50 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698