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

Unified Diff: net/data/parse_ocsp_unittest/annotate_test_data.py

Issue 1541213002: Adding OCSP Parser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix more null checks. Created 4 years, 9 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_algorithm.cc ('k') | net/data/parse_ocsp_unittest/bad_ocsp_type.pem » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/data/parse_ocsp_unittest/annotate_test_data.py
diff --git a/net/data/verify_signed_data_unittest/annotate_test_data.py b/net/data/parse_ocsp_unittest/annotate_test_data.py
similarity index 79%
copy from net/data/verify_signed_data_unittest/annotate_test_data.py
copy to net/data/parse_ocsp_unittest/annotate_test_data.py
index 733392ee060e6b9c7e8c12279977566914f632fe..256a0a2f722e5e4adbea38fa0c0d7cb14ced7516 100755
--- a/net/data/verify_signed_data_unittest/annotate_test_data.py
+++ b/net/data/parse_ocsp_unittest/annotate_test_data.py
@@ -1,15 +1,16 @@
#!/usr/bin/python
-# Copyright (c) 2015 The Chromium Authors. All rights reserved.
+# Copyright (c) 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+# TODO(svaldez): Deduplicate various annotate_test_data.
"""This script is called without any arguments to re-format all of the *.pem
files in the script's parent directory.
The main formatting change is to run "openssl asn1parse" for each of the PEM
-block sections (except for DATA), and add that output to the comment.
+block sections, and add that output to the comment. It also runs the command
+on the OCTET STRING representing BasicOCSPResponse.
-Refer to the README file for more information.
"""
import glob
@@ -32,15 +33,10 @@ def Transform(file_data):
# with the block, output it immediately before the block.
user_comment = GetUserComment(block.comment)
if user_comment:
- result += user_comment
+ result += user_comment + '\n'
- # For every block except for DATA, try to pretty print the parsed ASN.1.
- # DATA blocks likely would be DER in practice, but for the purposes of
- # these tests seeing its structure doesn't clarify
- # anything and is just a distraction.
- if block.name != 'DATA':
- generated_comment = GenerateCommentForBlock(block.name, block.data)
- result += generated_comment + '\n'
+ generated_comment = GenerateCommentForBlock(block.name, block.data)
+ result += generated_comment + '\n'
result += MakePemBlockString(block.name, block.data)
@@ -57,6 +53,19 @@ def GenerateCommentForBlock(block_name, block_data):
stdout_data, stderr_data = p.communicate(input=block_data)
generated_comment = '$ openssl asn1parse -i < [%s]\n%s' % (block_name,
stdout_data)
+
+ # The OCTET STRING encoded BasicOCSPResponse is also parsed out using
+ #'openssl asn1parse'.
+ if block_name == 'OCSP RESPONSE':
+ if '[HEX DUMP]:' in generated_comment:
+ (generated_comment, response) = generated_comment.split('[HEX DUMP]:', 1)
+ response = response.replace('\n', '')
+ if len(response) % 2 != 0:
+ response = '0' + response
+ response = GenerateCommentForBlock('INNER', response.decode('hex'))
+ response = response.split('\n', 1)[1]
+ response = response.replace(': ', ': ')
+ generated_comment += '\n%s' % (response)
return generated_comment.strip('\n')
« no previous file with comments | « net/cert/internal/signature_algorithm.cc ('k') | net/data/parse_ocsp_unittest/bad_ocsp_type.pem » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698