OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_RAPPOR_BYTE_VECTOR_UTILS_H_ | 5 #ifndef COMPONENTS_RAPPOR_BYTE_VECTOR_UTILS_H_ |
6 #define COMPONENTS_RAPPOR_BYTE_VECTOR_UTILS_H_ | 6 #define COMPONENTS_RAPPOR_BYTE_VECTOR_UTILS_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "components/rappor/rappor_parameters.h" | 12 #include "components/rappor/rappor_parameters.h" |
13 #include "crypto/hmac.h" | 13 #include "crypto/hmac.h" |
14 | 14 |
15 namespace rappor { | 15 namespace rappor { |
16 | 16 |
17 // A vector of 8-bit integers used to store a set of binary bits. | 17 // A vector of 8-bit integers used to store a set of binary bits. |
18 typedef std::vector<uint8_t> ByteVector; | 18 typedef std::vector<uint8_t> ByteVector; |
19 | 19 |
| 20 // Computes a bitwise AND of byte vectors and stores the result in rhs. |
| 21 // Returns rhs for chaining. |
| 22 ByteVector* ByteVectorAnd(const ByteVector& lhs, ByteVector* rhs); |
| 23 |
20 // Computes a bitwise OR of byte vectors and stores the result in rhs. | 24 // Computes a bitwise OR of byte vectors and stores the result in rhs. |
21 // Returns rhs for chaining. | 25 // Returns rhs for chaining. |
22 ByteVector* ByteVectorOr(const ByteVector& lhs, ByteVector* rhs); | 26 ByteVector* ByteVectorOr(const ByteVector& lhs, ByteVector* rhs); |
23 | 27 |
24 // Merges the contents of lhs and rhs vectors according to a mask vector. | 28 // Merges the contents of lhs and rhs vectors according to a mask vector. |
25 // The i-th bit of the result vector will be the i-th bit of either the lhs | 29 // The i-th bit of the result vector will be the i-th bit of either the lhs |
26 // or rhs vector, based on the i-th bit of the mask vector. | 30 // or rhs vector, based on the i-th bit of the mask vector. |
27 // Equivalent to (lhs & ~mask) | (rhs & mask). Stores the result in rhs. | 31 // Equivalent to (lhs & ~mask) | (rhs & mask). Stores the result in rhs. |
28 // Returns rhs for chaining. | 32 // Returns rhs for chaining. |
29 ByteVector* ByteVectorMerge(const ByteVector& mask, | 33 ByteVector* ByteVectorMerge(const ByteVector& mask, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 106 |
103 // Total number of bytes streamed from the HMAC_DRBG Generate Process. | 107 // Total number of bytes streamed from the HMAC_DRBG Generate Process. |
104 size_t generated_bytes_; | 108 size_t generated_bytes_; |
105 | 109 |
106 DISALLOW_ASSIGN(HmacByteVectorGenerator); | 110 DISALLOW_ASSIGN(HmacByteVectorGenerator); |
107 }; | 111 }; |
108 | 112 |
109 } // namespace rappor | 113 } // namespace rappor |
110 | 114 |
111 #endif // COMPONENTS_RAPPOR_BYTE_VECTOR_UTILS_H_ | 115 #endif // COMPONENTS_RAPPOR_BYTE_VECTOR_UTILS_H_ |
OLD | NEW |