| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // PeerConnectionFactory_nativeCreatePeerConnection's certificate generation | 120 // PeerConnectionFactory_nativeCreatePeerConnection's certificate generation |
| 121 // code. | 121 // code. |
| 122 enum KeyType { KT_RSA, KT_ECDSA, KT_LAST, KT_DEFAULT = KT_RSA }; | 122 enum KeyType { KT_RSA, KT_ECDSA, KT_LAST, KT_DEFAULT = KT_RSA }; |
| 123 | 123 |
| 124 static const int kRsaDefaultModSize = 1024; | 124 static const int kRsaDefaultModSize = 1024; |
| 125 static const int kRsaDefaultExponent = 0x10001; // = 2^16+1 = 65537 | 125 static const int kRsaDefaultExponent = 0x10001; // = 2^16+1 = 65537 |
| 126 static const int kRsaMinModSize = 1024; | 126 static const int kRsaMinModSize = 1024; |
| 127 static const int kRsaMaxModSize = 8192; | 127 static const int kRsaMaxModSize = 8192; |
| 128 | 128 |
| 129 // Certificate default validity lifetime. | 129 // Certificate default validity lifetime. |
| 130 static const int kDefaultCertificateLifetime = 60 * 60 * 24 * 30; // 30 days | 130 static const int kDefaultCertificateLifetimeInSeconds = |
| 131 60 * 60 * 24 * 30; // 30 days |
| 131 // Certificate validity window. | 132 // Certificate validity window. |
| 132 // This is to compensate for slightly incorrect system clocks. | 133 // This is to compensate for slightly incorrect system clocks. |
| 133 static const int kCertificateWindow = -60 * 60 * 24; | 134 static const int kCertificateWindowInSeconds = -60 * 60 * 24; |
| 134 | 135 |
| 135 struct RSAParams { | 136 struct RSAParams { |
| 136 unsigned int mod_size; | 137 unsigned int mod_size; |
| 137 unsigned int pub_exp; | 138 unsigned int pub_exp; |
| 138 }; | 139 }; |
| 139 | 140 |
| 140 enum ECCurve { EC_NIST_P256, /* EC_FANCY, */ EC_LAST }; | 141 enum ECCurve { EC_NIST_P256, /* EC_FANCY, */ EC_LAST }; |
| 141 | 142 |
| 142 class KeyParams { | 143 class KeyParams { |
| 143 public: | 144 public: |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 class SSLIdentity { | 192 class SSLIdentity { |
| 192 public: | 193 public: |
| 193 // Generates an identity (keypair and self-signed certificate). If | 194 // Generates an identity (keypair and self-signed certificate). If |
| 194 // |common_name| is non-empty, it will be used for the certificate's subject | 195 // |common_name| is non-empty, it will be used for the certificate's subject |
| 195 // and issuer name, otherwise a random string will be used. The key type and | 196 // and issuer name, otherwise a random string will be used. The key type and |
| 196 // parameters are defined in |key_param|. The certificate's lifetime in | 197 // parameters are defined in |key_param|. The certificate's lifetime in |
| 197 // seconds from the current time is defined in |certificate_lifetime|; it | 198 // seconds from the current time is defined in |certificate_lifetime|; it |
| 198 // should be a non-negative number. | 199 // should be a non-negative number. |
| 199 // Returns NULL on failure. | 200 // Returns NULL on failure. |
| 200 // Caller is responsible for freeing the returned object. | 201 // Caller is responsible for freeing the returned object. |
| 201 static SSLIdentity* Generate(const std::string& common_name, | 202 static SSLIdentity* GenerateWithExpiration(const std::string& common_name, |
| 202 const KeyParams& key_param, | 203 const KeyParams& key_param, |
| 203 time_t certificate_lifetime); | 204 time_t certificate_lifetime); |
| 204 static SSLIdentity* Generate(const std::string& common_name, | 205 static SSLIdentity* Generate(const std::string& common_name, |
| 205 const KeyParams& key_param); | 206 const KeyParams& key_param); |
| 206 static SSLIdentity* Generate(const std::string& common_name, | 207 static SSLIdentity* Generate(const std::string& common_name, |
| 207 KeyType key_type); | 208 KeyType key_type); |
| 208 | 209 |
| 209 // Generates an identity with the specified validity period. | 210 // Generates an identity with the specified validity period. |
| 210 // TODO(torbjorng): Now that Generate() accepts relevant params, make tests | 211 // TODO(torbjorng): Now that Generate() accepts relevant params, make tests |
| 211 // use that instead of this function. | 212 // use that instead of this function. |
| 212 static SSLIdentity* GenerateForTest(const SSLIdentityParams& params); | 213 static SSLIdentity* GenerateForTest(const SSLIdentityParams& params); |
| 213 | 214 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 240 // |s| is not 0-terminated; its char count is defined by |length|. | 241 // |s| is not 0-terminated; its char count is defined by |length|. |
| 241 int64_t ASN1TimeToSec(const unsigned char* s, size_t length, bool long_format); | 242 int64_t ASN1TimeToSec(const unsigned char* s, size_t length, bool long_format); |
| 242 | 243 |
| 243 extern const char kPemTypeCertificate[]; | 244 extern const char kPemTypeCertificate[]; |
| 244 extern const char kPemTypeRsaPrivateKey[]; | 245 extern const char kPemTypeRsaPrivateKey[]; |
| 245 extern const char kPemTypeEcPrivateKey[]; | 246 extern const char kPemTypeEcPrivateKey[]; |
| 246 | 247 |
| 247 } // namespace rtc | 248 } // namespace rtc |
| 248 | 249 |
| 249 #endif // WEBRTC_BASE_SSLIDENTITY_H_ | 250 #endif // WEBRTC_BASE_SSLIDENTITY_H_ |
| OLD | NEW |