| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 const char* string = input.data(); | 50 const char* string = input.data(); |
| 51 // Make sure that the creator of the CString didn't make the mistake | 51 // Make sure that the creator of the CString didn't make the mistake |
| 52 // of forcing length() to be the size of the buffer used to create the | 52 // of forcing length() to be the size of the buffer used to create the |
| 53 // string, prior to inserting the null terminator earlier in the | 53 // string, prior to inserting the null terminator earlier in the |
| 54 // sequence. | 54 // sequence. |
| 55 ASSERT(input.length() == strlen(string)); | 55 ASSERT(input.length() == strlen(string)); |
| 56 addBytes(reinterpret_cast<const uint8_t*>(string), input.length()); | 56 addBytes(reinterpret_cast<const uint8_t*>(string), input.length()); |
| 57 } | 57 } |
| 58 void addBytes(const uint8_t* input, size_t length); | 58 void addBytes(const uint8_t* input, size_t length); |
| 59 | 59 |
| 60 static const size_t outputSizeBytes = 20; |
| 61 |
| 60 // computeHash has a side effect of resetting the state of the object. | 62 // computeHash has a side effect of resetting the state of the object. |
| 61 void computeHash(Vector<uint8_t, 20>&); | 63 void computeHash(Vector<uint8_t, outputSizeBytes>&); |
| 62 | 64 |
| 63 private: | 65 private: |
| 64 void finalize(); | 66 void finalize(); |
| 65 void processBlock(); | 67 void processBlock(); |
| 66 void reset(); | 68 void reset(); |
| 67 | 69 |
| 68 uint8_t m_buffer[64]; | 70 uint8_t m_buffer[64]; |
| 69 size_t m_cursor; // Number of bytes filled in m_buffer (0-64). | 71 size_t m_cursor; // Number of bytes filled in m_buffer (0-64). |
| 70 uint64_t m_totalBytes; // Number of bytes added so far. | 72 uint64_t m_totalBytes; // Number of bytes added so far. |
| 71 uint32_t m_hash[5]; | 73 uint32_t m_hash[5]; |
| 72 }; | 74 }; |
| 73 | 75 |
| 74 } // namespace WTF | 76 } // namespace WTF |
| 75 | 77 |
| 76 using WTF::SHA1; | 78 using WTF::SHA1; |
| 77 | 79 |
| 78 #endif // WTF_SHA1_h | 80 #endif // WTF_SHA1_h |
| OLD | NEW |