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

Unified Diff: net/der/parse_values.h

Issue 1295943002: Add a function for validating a DER-encoded INTEGER. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert_parsing
Patch Set: remove numeric_length as an out-parameter of IsValidInteger Created 5 years, 4 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 | « no previous file | net/der/parse_values.cc » ('j') | net/der/parse_values.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/der/parse_values.h
diff --git a/net/der/parse_values.h b/net/der/parse_values.h
index 39c3c029966fe04bfbfb58a3f9934ec36c7b8b52..27a6f5fb7fc56cf2ecaa4c487a48a80c5ccf8401 100644
--- a/net/der/parse_values.h
+++ b/net/der/parse_values.h
@@ -22,12 +22,23 @@ NET_EXPORT bool ParseBool(const Input& in, bool* out) WARN_UNUSED_RESULT;
// value that is a valid BER encoding will be parsed successfully.
NET_EXPORT bool ParseBoolRelaxed(const Input& in, bool* out) WARN_UNUSED_RESULT;
+// Checks the validity of a DER-encoded ASN.1 INTEGER value from |in|, and
+// determines the sign of the number. Returns true on success and
+// fills |negative|. Otherwise returns false and does not modify the out
+// parameter.
+//
+// in: The value portion of an INTEGER.
+// negative: Out parameter that is set to true if the number is negative
+// and false otherwise (zero is non-negative).
+NET_EXPORT bool IsValidInteger(const Input& in,
+ bool* negative) WARN_UNUSED_RESULT;
+
// Reads a DER-encoded ASN.1 INTEGER value from |in| and puts the resulting
// value in |out|. ASN.1 INTEGERs are arbitrary precision; this function is
// provided as a convenience when the caller knows that the value is unsigned
-// and is between 0 and 2^63-1. This function does not support the full range of
-// uint64_t. This function returns false if the value is too big to fit in a
-// uint64_t, is negative, or if there is an error reading the integer.
+// and is between 0 and 2^64-1. This function returns false if the value is too
+// big to fit in a uint64_t, is negative, or if there is an error reading the
+// integer.
NET_EXPORT bool ParseUint64(const Input& in, uint64_t* out) WARN_UNUSED_RESULT;
// The BitString class is a helper for representing a valid parsed BIT STRING.
« no previous file with comments | « no previous file | net/der/parse_values.cc » ('j') | net/der/parse_values.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698