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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_WEBCRYPTO_CRYPTO_DATA_H_
6 #define COMPONENTS_WEBCRYPTO_CRYPTO_DATA_H_
11 #include "base/basictypes.h"
12 #include "third_party/WebKit/public/platform/WebVector.h"
16 // Helper to pass around a range of immutable bytes. This is conceptually
17 // similar to base::StringPiece, but for crypto byte data.
19 // The data used at construction is NOT owned, and should remain valid as long
20 // as the CryptoData is being used.
23 // Constructs empty data.
26 CryptoData(const unsigned char* bytes
, unsigned int byte_length
);
28 // These constructors do NOT copy the data. Hence the base pointer should
29 // remain valid for the lifetime of CryptoData.
30 explicit CryptoData(const std::vector
<unsigned char>& bytes
);
31 explicit CryptoData(const std::string
& bytes
);
32 explicit CryptoData(const blink::WebVector
<unsigned char>& bytes
);
34 const unsigned char* bytes() const { return bytes_
; }
35 unsigned int byte_length() const { return byte_length_
; }
38 const unsigned char* const bytes_
;
39 const unsigned int byte_length_
;
42 } // namespace webcrypto
44 #endif // COMPONENTS_WEBCRYPTO_CRYPTO_DATA_H_