1 // Copyright (c) 2011 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 #include "net/curvecp/connection_key.h"
11 ConnectionKey::ConnectionKey() {
12 memset(key_
, 0, sizeof(key_
));
15 ConnectionKey::ConnectionKey(unsigned char bytes
[]) {
16 memcpy(key_
, bytes
, sizeof(key_
));
19 ConnectionKey::ConnectionKey(const ConnectionKey
& other
) {
20 memcpy(key_
, other
.key_
, sizeof(key_
));
23 ConnectionKey
& ConnectionKey::operator=(const ConnectionKey
& other
) {
24 memcpy(key_
, other
.key_
, sizeof(key_
));
28 bool ConnectionKey::operator==(const ConnectionKey
& other
) const {
29 return memcmp(key_
, other
.key_
, sizeof(key_
)) == 0;
32 bool ConnectionKey::operator<(const ConnectionKey
& other
) const {
33 return memcmp(key_
, other
.key_
, sizeof(key_
)) < 0;
36 std::string
ConnectionKey::ToString() const {
37 // TODO(mbelshe): make this a nice hex formatter
38 return std::string("key") +
39 std::string(reinterpret_cast<const char*>(key_
), 32);