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

Unified Diff: net/tools/testserver/asn1der.py

Issue 12235003: Split out policy code from net/tools/testserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 80 chars. Created 7 years, 10 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/tools/testserver/OWNERS ('k') | net/tools/testserver/device_management.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/testserver/asn1der.py
diff --git a/net/tools/testserver/asn1der.py b/net/tools/testserver/asn1der.py
deleted file mode 100644
index 9e70893ef01f84d09e240e515c655dbabf20923d..0000000000000000000000000000000000000000
--- a/net/tools/testserver/asn1der.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# Copyright (c) 2011 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.
-
-"""Helper module for ASN.1/DER encoding."""
-
-import binascii
-import struct
-
-# Tags as defined by ASN.1.
-INTEGER = 2
-BIT_STRING = 3
-NULL = 5
-OBJECT_IDENTIFIER = 6
-SEQUENCE = 0x30
-
-def Data(tag, data):
- """Generic type-length-value encoder.
-
- Args:
- tag: the tag.
- data: the data for the given tag.
- Returns:
- encoded TLV value.
- """
- if len(data) == 0:
- return struct.pack(">BB", tag, 0);
- assert len(data) <= 0xffff;
- return struct.pack(">BBH", tag, 0x82, len(data)) + data;
-
-def Integer(value):
- """Encodes an integer.
-
- Args:
- value: the long value.
- Returns:
- encoded TLV value.
- """
- data = '%x' % value
- return Data(INTEGER, binascii.unhexlify('00' + '0' * (len(data) % 2) + data))
-
-def Bitstring(value):
- """Encodes a bit string.
-
- Args:
- value: a string holding the binary data.
- Returns:
- encoded TLV value.
- """
- return Data(BIT_STRING, '\x00' + value)
-
-def Sequence(values):
- """Encodes a sequence of other values.
-
- Args:
- values: the list of values, must be strings holding already encoded data.
- Returns:
- encoded TLV value.
- """
- return Data(SEQUENCE, ''.join(values))
« no previous file with comments | « net/tools/testserver/OWNERS ('k') | net/tools/testserver/device_management.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698