Chromium Code Reviews| Index: net/cert/ct_sct_to_string.cc |
| diff --git a/net/cert/ct_sct_to_string.cc b/net/cert/ct_sct_to_string.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..afe0905084e80df0c9ad9f4968c8a60939c75cdf |
| --- /dev/null |
| +++ b/net/cert/ct_sct_to_string.cc |
| @@ -0,0 +1,87 @@ |
| +// Copyright 2016 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 "net/cert/ct_sct_to_string.h" |
| + |
| +#include <string> |
| + |
| +namespace net { |
| + |
| +namespace ct { |
| + |
| +const std::string HashAlgorithmToString( |
| + net::ct::DigitallySigned::HashAlgorithm hashAlgorithm) { |
| + switch (hashAlgorithm) { |
| + case net::ct::DigitallySigned::HASH_ALGO_NONE: |
| + return "None / invalid"; |
| + case net::ct::DigitallySigned::HASH_ALGO_MD5: |
| + return "MD5"; |
| + case net::ct::DigitallySigned::HASH_ALGO_SHA1: |
| + return "SHA-1"; |
| + case net::ct::DigitallySigned::HASH_ALGO_SHA224: |
| + return "SHA-224"; |
| + case net::ct::DigitallySigned::HASH_ALGO_SHA256: |
| + return "SHA-256"; |
| + case net::ct::DigitallySigned::HASH_ALGO_SHA384: |
| + return "SHA-384"; |
| + case net::ct::DigitallySigned::HASH_ALGO_SHA512: |
| + return "SHA-512"; |
| + } |
| + return "Unknown"; |
| +} |
| + |
| +const std::string SignatureAlgorithmToString( |
| + net::ct::DigitallySigned::SignatureAlgorithm signatureAlgorithm) { |
| + switch (signatureAlgorithm) { |
| + case net::ct::DigitallySigned::SIG_ALGO_ANONYMOUS: |
| + return "Anonymous"; |
| + case net::ct::DigitallySigned::SIG_ALGO_RSA: |
| + return "RSA"; |
| + case net::ct::DigitallySigned::SIG_ALGO_DSA: |
| + return "DSA"; |
| + case net::ct::DigitallySigned::SIG_ALGO_ECDSA: |
| + return "ECDSA"; |
| + } |
| + return "Unknown"; |
| +} |
| + |
| +const std::string OriginToString( |
| + net::ct::SignedCertificateTimestamp::Origin origin) { |
| + switch (origin) { |
| + case net::ct::SignedCertificateTimestamp::SCT_EMBEDDED: |
| + return "Embedded in certificate"; |
| + case net::ct::SignedCertificateTimestamp::SCT_FROM_TLS_EXTENSION: |
| + return "TLS extension"; |
| + case net::ct::SignedCertificateTimestamp::SCT_FROM_OCSP_RESPONSE: |
| + return "OCSP"; |
|
Eran Messeri
2016/05/25 12:42:21
You have to handle net::ct::SignedCertificateTimes
dwaxweiler
2016/05/27 23:13:00
Acknowledged.
|
| + } |
| + return "Unknown"; |
| +} |
| + |
| +const std::string StatusToString(net::ct::SCTVerifyStatus status) { |
| + switch (status) { |
| + case net::ct::SCT_STATUS_LOG_UNKNOWN: |
| + return "From unknown log"; |
| + case net::ct::SCT_STATUS_INVALID: |
| + return "Invalid"; |
| + case net::ct::SCT_STATUS_OK: |
| + return "Verified"; |
| + case net::ct::SCT_STATUS_NONE: |
| + return "None"; |
|
Eran Messeri
2016/05/25 12:42:21
You have to handle net::ct::SCT_STATUS_MAX here.
dwaxweiler
2016/05/27 23:13:00
Acknowledged.
|
| + } |
| + return "Unknown"; |
| +} |
| + |
| +const std::string VersionToString( |
| + net::ct::SignedCertificateTimestamp::Version version) { |
| + switch (version) { |
| + case net::ct::SignedCertificateTimestamp::V1: |
| + return "1"; |
| + } |
| + return "Unknown"; |
| +} |
| + |
| +} // namespace ct |
| + |
| +} // namespace net |