| OLD | NEW |
| (Empty) |
| 1 // Copyright 2008-2009 Google Inc. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 // ======================================================================== | |
| 15 | |
| 16 | |
| 17 #ifndef OMAHA_NET_CUP_UTILS_H__ | |
| 18 #define OMAHA_NET_CUP_UTILS_H__ | |
| 19 | |
| 20 #include <atlstr.h> | |
| 21 #include <vector> | |
| 22 #include "base/basictypes.h" | |
| 23 | |
| 24 namespace omaha { | |
| 25 | |
| 26 namespace cup_utils { | |
| 27 | |
| 28 // Takes up to (rsa_key_size - SHA_DIGEST_SIZE) from the caller provided | |
| 29 // input, and creates a padded result (data | SHA1(data)), where the msb | |
| 30 // is keybits-160 and the lsb is 160 SHA1 bits. If less input is provided | |
| 31 // the function pads the input with zeros. | |
| 32 std::vector<uint8> RsaPad(size_t rsa_key_size, | |
| 33 const void* data, size_t data_length); | |
| 34 | |
| 35 // Encodes a buffer of bytes as B64. This encoder has a few differences from | |
| 36 // the standard: it uses a different char set that is http friendly and it does | |
| 37 // not pad the output with '='. | |
| 38 CStringA B64Encode(const void* data, size_t data_length); | |
| 39 | |
| 40 // Encodes a vector of bytes as web safe B64. | |
| 41 CStringA B64Encode(const std::vector<uint8>& data); | |
| 42 | |
| 43 // Computes the SHA hash of a vector of bytes: HASH(data). | |
| 44 std::vector<uint8> Hash(const std::vector<uint8>& data); | |
| 45 | |
| 46 // Computes the SHA hash of a CStringA: HASH(data). | |
| 47 std::vector<uint8> Hash(const CStringA& data); | |
| 48 | |
| 49 // Computes the SHA hash of buffers: HASH(HASH(buf1)|HASH(buf2)|HASH(buf3)). | |
| 50 std::vector<uint8> HashBuffers(const void* buf1, size_t len1, | |
| 51 const void* buf2, size_t len2, | |
| 52 const void* buf3, size_t len3); | |
| 53 | |
| 54 // Computes the HMAC of hashes: SYMSign[key](id|h1|h2|h3) | |
| 55 // NULL arguments are not included in the signature computation. | |
| 56 std::vector<uint8> SymSign(const std::vector<uint8>& key, | |
| 57 uint8 id, | |
| 58 const std::vector<uint8>* h1, | |
| 59 const std::vector<uint8>* h2, | |
| 60 const std::vector<uint8>* h3); | |
| 61 | |
| 62 // Parses out the c=xxx; from the cookie header. | |
| 63 CString ParseCupCookie(const CString& cookie_header); | |
| 64 | |
| 65 } // namespace cup_utils | |
| 66 | |
| 67 } // namespace omaha | |
| 68 | |
| 69 #endif // OMAHA_NET_CUP_UTILS_H__ | |
| OLD | NEW |