Commit Graph

5433 Commits

Author SHA1 Message Date
Andres Amaya Garcia
4775cd3827 Parse top-level OCSP ResponseData
Populate the function x509_ocsp_get_response_data() with code that
parses the following ASN.1 structure:

   ResponseData ::= SEQUENCE {
      version              [0] EXPLICIT Version DEFAULT v1,
      responderID              ResponderID,
      producedAt               GeneralizedTime,
      responses                SEQUENCE OF SingleResponse,
      responseExtensions   [1] EXPLICIT Extensions OPTIONAL }

x509_ocsp_get_response_data() will parse the top-level SEQUENCE and the
two EXPLICIT tags. It delegates the parsing of the individual
subcomponents to x509_ocsp_get_version(), x509_ocsp_get_responder_id(),
x509_ocsp_get_generalized_time(), x509_ocsp_get_responses() and
x509_ocsp_get_extensions().
2017-11-11 12:49:19 +00:00
Andres Amaya Garcia
8f1e390a36 Parse top-level components of BasicOCSPResponse
Populate the function x509_ocsp_get_response() that parses the top
level components of the following ASN.1 structure:

   BasicOCSPResponse       ::= SEQUENCE {
      tbsResponseData      ResponseData,
      signatureAlgorithm   AlgorithmIdentifier,
      signature            BIT STRING,
      certs            [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }

The top-level components correspond to the main SEQUENCE and the
EXPLICIT tag.
2017-11-11 12:49:19 +00:00
Andres Amaya Garcia
d4c37efeac Add informational string for OCSP response type 2017-11-11 12:49:19 +00:00
Andres Amaya Garcia
f4d32f695f Parse OCSP ResponseType OID
Parse the OCSP ResponseType OID contained in the ResponseBytes.
2017-11-11 12:49:19 +00:00
Andres Amaya Garcia
cd5d0aaa59 Add missing id-pkix-ocsp-basic OID for OCSP
Add missing id-pkix-ocsp-basic OID for ResponseType from RFC 6960
Section 4.2.
2017-11-11 12:49:19 +00:00
Andres Amaya Garcia
26db5fbe9b Parse ResponseBytes top-level from OCSP response
The added code removed the SEQUENCE component from the following ASN.1
structure:

   ResponseBytes ::=       SEQUENCE {
       responseType   OBJECT IDENTIFIER,
       response       OCTET STRING }

The parsing for responseType and response is delegated to
x509_ocsp_get_response_type() and x509_ocsp_get_response() respectively.
2017-11-11 12:44:26 +00:00
Andres Amaya Garcia
5f72ea8757 Document the general idea of the code in x509_ocsp.c 2017-11-11 12:44:26 +00:00
Andres Amaya Garcia
5ebc241bd4 Add informational string for OCSP response status 2017-11-11 12:44:26 +00:00
Andres Amaya Garcia
026e95a74d Parse the OCSP response status
Populate the function x509_ocsp_get_response_status() that parses the
OCSPResponseStatus:

   OCSPResponseStatus ::= ENUMERATED {
       successful            (0),  -- Response has valid confirmations
       malformedRequest      (1),  -- Illegal confirmation request
       internalError         (2),  -- Internal error in issuer
       tryLater              (3),  -- Try again later
                                   -- (4) is not used
       sigRequired           (5),  -- Must sign the request
       unauthorized          (6)   -- Request unauthorized
   }

The function writes the value into the resp_status field of the
mbedtls_x509_ocsp_response struct.
2017-11-11 12:44:26 +00:00
Andres Amaya Garcia
8252d7a249 Add OCSP parser doxygen docs and placeholder funcs
Add OCSP parser doxygen comments to x509_ocsp.h and placeholder init
and free functions that will be populated later in the development of
the feature
2017-11-11 12:44:26 +00:00
Andres Amaya Garcia
6def89e84e Parse the OCSPResponse top level components
Add parsing for the OCSPResponse top level components:

   OCSPResponse ::= SEQUENCE {
      responseStatus         OCSPResponseStatus,
      responseBytes          [0] EXPLICIT ResponseBytes OPTIONAL }

The added code does the following:

    1. Parse the top level SEQUENCE
    2. Call x509_ocsp_get_response_status() which will parse the
       responseStatus in the future
    3. If there is any data left in the buffer, parses the EXPLICIT
       tag and calls x509_ocsp_get_response_bytes() which will parse
       the responseBytes in the future

At this stage, the main framework for the code is being set up. The idea
is that each function will parse the top level components of the ASN1
objects and hand over the parsing of each of the individual
sub-components to other functions. Also, note that each function its
responsible for checking that:

    1. At the begining, there is enough space in the buffer p to parse
       whatever is being processed before end.
    2. Prior to returning, the length specified in the ASN1 encoding
       matches the number of bytes consumed from the buffer p.
    3. The lengths of any intermediate sub-components (such as EXPLICIT
       tags) parsed matches the number of bytes consumed by the called
       functions x509_ocsp_get_*().
2017-11-11 12:44:26 +00:00
Andres Amaya Garcia
22b1db8a4c Add OCSP parsing files as part of the X509 module
OCSP by itself is a protocol between an OCSP responder and a client.
The protocol messages are encoded in X.509 format, so I have created
the place-holder files x509_ocsp.c and x509_ocsp.h that will contain
the X.509 parser and verification for OCSP messages.
2017-11-11 12:44:26 +00:00
Andres Amaya Garcia
4cfdb54e2c Add bounds check for OCSP nocheck parsing in X509 2017-11-11 12:43:16 +00:00
Andres Amaya Garcia
b3cb72d72e Add docs to mbedtls_oid_get_authority_info_access() 2017-11-11 12:43:16 +00:00
Andres Amaya Garcia
f7a1646213 Add X509 authInfoAccess and OCSP noCheck ext tests 2017-11-11 12:43:16 +00:00
Andres Amaya Garcia
94be1592f4 Skip parsing unknown accessLocation in authInfoAcc 2017-11-11 12:43:16 +00:00
Andres Amaya Garcia
28681c6afd Parse NULL asn1 octet string in OCSP nocheck ext 2017-11-11 12:43:16 +00:00
Andres Amaya Garcia
998013caab Improve comments for OCSP no-check X509 extension 2017-11-11 12:43:16 +00:00
Andres Amaya Garcia
2c8546f8ad Print URI up to 127 characters in x509_crt.c 2017-11-11 12:43:16 +00:00
Andres Amaya Garcia
a05c5edebc Wrap lines at 79 chars long in x509_crt.c 2017-11-11 12:43:16 +00:00
Andres Amaya Garcia
23875e3297 Remove old TODO comments from x509_crt.c 2017-11-11 12:43:16 +00:00
Andres Amaya Garcia
994a028465 Free authority info access data in x509_crt struct 2017-11-11 12:43:16 +00:00
Andres Amaya Garcia
4e075e4f5c Add support for OCSP noCheck X509 extension 2017-11-11 12:43:16 +00:00
Andres Amaya Garcia
d6700fd019 Add support for AuthorityInfoAccess X509 extension 2017-11-11 12:43:16 +00:00
Simon Butcher
6f63db7ed5 Fix changelog for ssl_server2.c usage fix 2017-10-12 23:22:17 +01:00
Gilles Peskine
085c10afdb Allow comments in test data files 2017-10-12 23:22:17 +01:00
Andres Amaya Garcia
9fb02057a5 Fix typo in asn1.h 2017-10-12 23:21:37 +01:00
Andres Amaya Garcia
60100d09ee Improve leap year test names in x509parse.data 2017-10-12 23:21:37 +01:00
Andres Amaya Garcia
735b37eeef Correctly handle leap year in x509_date_is_valid()
This patch ensures that invalid dates on leap years with 100 or 400
years intervals are handled correctly.
2017-10-12 23:21:37 +01:00
Janos Follath
b0f148c0ab Renegotiation: Add tests for SigAlg ext parsing
This commit adds regression tests for the bug when we didn't parse the
Signature Algorithm extension when renegotiating. (By nature, this bug
affected only the server)

The tests check for the fallback hash (SHA1) in the server log to detect
that the Signature Algorithm extension hasn't been parsed at least in
one of the handshakes.

A more direct way of testing is not possible with the current test
framework, since the Signature Algorithm extension is parsed in the
first handshake and any corresponding debug message is present in the
logs.
2017-10-12 23:21:37 +01:00
Ron Eldor
73a381772b Parse Signature Algorithm ext when renegotiating
Signature algorithm extension was skipped when renegotiation was in
progress, causing the signature algorithm not to be known when
renegotiating, and failing the handshake. Fix removes the renegotiation
step check before parsing the extension.
2017-10-12 23:21:37 +01:00
Gilles Peskine
8ca0e8fdff Minor style fix 2017-10-12 23:21:37 +01:00
Gilles Peskine
d98e9e8577 config.pl get: be better behaved
When printing an option's value, print a newline at the end.

When the requested option is missing, fail with status 1 (the usual
convention for "not found") rather than -1 (which has a
system-dependent effect).
2017-10-12 23:21:37 +01:00
Gilles Peskine
01f57e351c config.pl get: don't rewrite config.h; detect write errors
scripts/config.pl would always rewrite config.h if it was reading it.
This commit changes it to not modify the file when only reading is
required, i.e. for the get command.

Also, die if writing config.h fails (e.g. disk full).
2017-10-12 23:21:37 +01:00
Gilles Peskine
f0f55ccb72 Fixed "config.pl get" for options with no value
Between 2.5.0 and 2.6.0, "scripts/config.pl get MBEDTLS_XXX" was fixed
for config.h lines with a comment at the end, but that broke the case
of macros with an empty expansion. Support all cases.
2017-10-12 23:21:37 +01:00
Andres Amaya Garcia
bd9d42c236 Fix typo and bracketing in macro args 2017-10-12 23:21:37 +01:00
Gilles Peskine
4552bf7558 Allow comments in test data files 2017-10-12 23:20:56 +01:00
Andres Amaya Garcia
3f50f511de Ensure failed test_suite output is sent to stdout
The change modifies the template code in tests/suites/helpers.function
and tests/suites/main.function so that error messages are printed to
stdout instead of being discarded. This makes errors visible regardless
of the --verbose flag being passed or not to the test suite programs.
2017-10-07 18:15:28 +01:00
Andres Amaya Garcia
67d8da522f Remove use of GNU sed features from ssl-opt.sh 2017-10-06 11:59:13 +01:00
Andres Amaya Garcia
3b1bdff285 Fix typos in ssl-opt.sh comments 2017-10-06 11:59:13 +01:00
Andres Amaya Garcia
b84c40b12f Add ssl-opt.sh test to check gmt_unix_time is good
Add a test to ssl-opt.sh that parses the client and server debug
output and then checks that the Unix timestamp in the ServerHello
message is within acceptable bounds.
2017-10-06 11:59:13 +01:00
Andres Amaya Garcia
93993defd1 Extend ssl-opt.h so that run_test takes function
Extend the run_test function in ssl-opt.sh so that it accepts the -f
and -F options. These parameters take an argument which is the name of
a shell function that will be called by run_test and will be given the
client input and output debug log. The idea is that these functions are
defined by each test and they can be used to do some custom check
beyon those allowed by the pattern matching capabilities of the
run_test function.
2017-10-06 11:59:13 +01:00
Andres Amaya Garcia
6bce9cb5ac Always print gmt_unix_time in TLS client
Change ssl_parse_server_hello() so that the parsed first four random
bytes from the ServerHello message are printed by the TLS client as
a Unix timestamp regardless of whether MBEDTLS_DEBUG_C is defined. The
debug message will only be printed if debug_level is 3 or higher.

Unconditionally enabling the debug print enabled testing of this value.
2017-10-06 11:59:13 +01:00
Gilles Peskine
470edd031f Restored note about using minimum functionality in makefiles 2017-10-06 11:59:13 +01:00
Gilles Peskine
11cb578fda Note in README that GNU make is required
Our README claims that we only use basic Make functionality, but in
fact GNU make is required for conditional compilation. Document this.

Addresses issue #967
2017-10-06 11:59:13 +01:00
Simon Butcher
16373a5933 Fix changelog for ssl_server2.c usage fix 2017-10-06 11:59:13 +01:00
Ron Eldor
71f68c4043 Fix ssl_server2 sample application prompt
FIx the type of server_addr parameter from %d to %s.
Issue reported by Email by Bei Jin
2017-10-06 11:59:13 +01:00
Simon Butcher
2c4f9460ea Update ChangeLog for fix to #836 2017-10-06 11:59:13 +01:00
Hanno Becker
1a9a51c7cf Enhance documentation of ssl_write_hostname_ext, adapt ChangeLog.
Add a reference to the relevant RFC, adapt ChangeLog.
2017-10-06 11:58:50 +01:00
Hanno Becker
0446a39744 Enhance documentation of mbedtls_ssl_set_hostname
(1) Add missing error condition
(2) Specify allowance and effect of of NULL hostname parameter
(3) Describe effect of function on failure
2017-10-06 11:58:50 +01:00