Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(947)

Unified Diff: net/cert/internal/signature_policy.cc

Issue 2289363004: Add error information to VerifySignedData(). (Closed)
Patch Set: rebase onto origin/master Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cert/internal/signature_policy.h ('k') | net/cert/internal/verify_certificate_chain.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/internal/signature_policy.cc
diff --git a/net/cert/internal/signature_policy.cc b/net/cert/internal/signature_policy.cc
index c00212ac9410888887f8e383cbbf7ef7dc9a6abc..dae861f2930561d931d328a4dde231782b5384b0 100644
--- a/net/cert/internal/signature_policy.cc
+++ b/net/cert/internal/signature_policy.cc
@@ -5,37 +5,67 @@
#include "net/cert/internal/signature_policy.h"
#include "base/logging.h"
+#include "net/cert/internal/cert_errors.h"
#include <openssl/obj.h>
namespace net {
+namespace {
+
+DEFINE_CERT_ERROR_TYPE(kUnacceptableCurveForEcdsa,
+ "Only P-256, P-384, P-521 are supported for ECDSA");
+DEFINE_CERT_ERROR_TYPE(kRsaModulusLessThan2048,
+ "RSA modulus must be at least 2048 bits");
+DEFINE_CERT_ERROR_TYPE(kRsaModulusTooSmall, "RSA modulus too small");
+
+} // namespace
+
bool SignaturePolicy::IsAcceptableSignatureAlgorithm(
- const SignatureAlgorithm& algorithm) const {
+ const SignatureAlgorithm& algorithm,
+ CertErrors* errors) const {
return true;
}
-bool SignaturePolicy::IsAcceptableCurveForEcdsa(int curve_nid) const {
+bool SignaturePolicy::IsAcceptableCurveForEcdsa(int curve_nid,
+ CertErrors* errors) const {
switch (curve_nid) {
case NID_X9_62_prime256v1:
case NID_secp384r1:
case NID_secp521r1:
return true;
}
+
+ errors->Add(kUnacceptableCurveForEcdsa);
return false;
}
bool SignaturePolicy::IsAcceptableModulusLengthForRsa(
- size_t modulus_length_bits) const {
- return modulus_length_bits >= 2048;
+ size_t modulus_length_bits,
+ CertErrors* errors) const {
+ if (modulus_length_bits < 2048) {
+ // TODO(crbug.com/634443): Add a parameter for actual modulus size.
+ errors->Add(kRsaModulusLessThan2048);
+ return false;
+ }
+
+ return true;
}
SimpleSignaturePolicy::SimpleSignaturePolicy(size_t min_rsa_modulus_length_bits)
: min_rsa_modulus_length_bits_(min_rsa_modulus_length_bits) {}
bool SimpleSignaturePolicy::IsAcceptableModulusLengthForRsa(
- size_t modulus_length_bits) const {
- return modulus_length_bits >= min_rsa_modulus_length_bits_;
+ size_t modulus_length_bits,
+ CertErrors* errors) const {
+ if (modulus_length_bits < min_rsa_modulus_length_bits_) {
+ // TODO(crbug.com/634443): Add parameters for actual and expected modulus
+ // size.
+ errors->Add(kRsaModulusTooSmall);
+ return false;
+ }
+
+ return true;
}
} // namespace net
« no previous file with comments | « net/cert/internal/signature_policy.h ('k') | net/cert/internal/verify_certificate_chain.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698