OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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. |
| 4 |
| 5 #include "net/cert/ct_sct_to_string.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 namespace net { |
| 10 |
| 11 namespace ct { |
| 12 |
| 13 const std::string HashAlgorithmToString( |
| 14 net::ct::DigitallySigned::HashAlgorithm hashAlgorithm) { |
| 15 switch (hashAlgorithm) { |
| 16 case net::ct::DigitallySigned::HASH_ALGO_NONE: |
| 17 return "None / invalid"; |
| 18 case net::ct::DigitallySigned::HASH_ALGO_MD5: |
| 19 return "MD5"; |
| 20 case net::ct::DigitallySigned::HASH_ALGO_SHA1: |
| 21 return "SHA-1"; |
| 22 case net::ct::DigitallySigned::HASH_ALGO_SHA224: |
| 23 return "SHA-224"; |
| 24 case net::ct::DigitallySigned::HASH_ALGO_SHA256: |
| 25 return "SHA-256"; |
| 26 case net::ct::DigitallySigned::HASH_ALGO_SHA384: |
| 27 return "SHA-384"; |
| 28 case net::ct::DigitallySigned::HASH_ALGO_SHA512: |
| 29 return "SHA-512"; |
| 30 } |
| 31 return "Unknown"; |
| 32 } |
| 33 |
| 34 const std::string SignatureAlgorithmToString( |
| 35 net::ct::DigitallySigned::SignatureAlgorithm signatureAlgorithm) { |
| 36 switch (signatureAlgorithm) { |
| 37 case net::ct::DigitallySigned::SIG_ALGO_ANONYMOUS: |
| 38 return "Anonymous"; |
| 39 case net::ct::DigitallySigned::SIG_ALGO_RSA: |
| 40 return "RSA"; |
| 41 case net::ct::DigitallySigned::SIG_ALGO_DSA: |
| 42 return "DSA"; |
| 43 case net::ct::DigitallySigned::SIG_ALGO_ECDSA: |
| 44 return "ECDSA"; |
| 45 } |
| 46 return "Unknown"; |
| 47 } |
| 48 |
| 49 const std::string OriginToString( |
| 50 net::ct::SignedCertificateTimestamp::Origin origin) { |
| 51 switch (origin) { |
| 52 case net::ct::SignedCertificateTimestamp::SCT_EMBEDDED: |
| 53 return "Embedded in certificate"; |
| 54 case net::ct::SignedCertificateTimestamp::SCT_FROM_TLS_EXTENSION: |
| 55 return "TLS extension"; |
| 56 case net::ct::SignedCertificateTimestamp::SCT_FROM_OCSP_RESPONSE: |
| 57 return "OCSP"; |
| 58 } |
| 59 return "Unknown"; |
| 60 } |
| 61 |
| 62 const std::string StatusToString(net::ct::SCTVerifyStatus status) { |
| 63 switch (status) { |
| 64 case net::ct::SCT_STATUS_LOG_UNKNOWN: |
| 65 return "From unknown log"; |
| 66 case net::ct::SCT_STATUS_INVALID: |
| 67 return "Invalid"; |
| 68 case net::ct::SCT_STATUS_OK: |
| 69 return "Verified"; |
| 70 case net::ct::SCT_STATUS_NONE: |
| 71 return "None"; |
| 72 } |
| 73 return "Unknown"; |
| 74 } |
| 75 |
| 76 const std::string VersionToString( |
| 77 net::ct::SignedCertificateTimestamp::Version version) { |
| 78 switch (version) { |
| 79 case net::ct::SignedCertificateTimestamp::V1: |
| 80 return "1"; |
| 81 } |
| 82 return "Unknown"; |
| 83 } |
| 84 |
| 85 } // namespace ct |
| 86 |
| 87 } // namespace net |
OLD | NEW |