summaryrefslogtreecommitdiff
path: root/chromium/components/webcrypto/crypto_data.cc
blob: 4004f5ea80d4b57c983de22787d1b551986db197 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/webcrypto/crypto_data.h"

namespace webcrypto {

CryptoData::CryptoData() : bytes_(nullptr), byte_length_(0) {}

CryptoData::CryptoData(const unsigned char* bytes, unsigned int byte_length)
    : bytes_(bytes), byte_length_(byte_length) {
}

CryptoData::CryptoData(const std::vector<unsigned char>& bytes)
    : bytes_(bytes.data()),
      byte_length_(static_cast<unsigned int>(bytes.size())) {}

CryptoData::CryptoData(const std::string& bytes)
    : bytes_(bytes.size() ? reinterpret_cast<const unsigned char*>(bytes.data())
                          : nullptr),
      byte_length_(static_cast<unsigned int>(bytes.size())) {}

CryptoData::CryptoData(const blink::WebVector<unsigned char>& bytes)
    : bytes_(bytes.Data()),
      byte_length_(static_cast<unsigned int>(bytes.size())) {}

}  // namespace webcrypto