Home | Trees | Indices | Help |
---|
|
object --+ | SecItem
SecItem(data=None, type=siBuffer, ascii=False)
A SecItem is a block of binary data. It contains the data, a count of the number of octets in the data and optionally a type describing the contents of the data. SecItem's are used throughout NSS to pass blocks of binary data back and forth. Because the binary data is often DER (Distinguished Encoding Rule) ASN.1 data the data is often referred to as 'der'.
SecItem's are often returned by NSS functions.
You can create and initialize a SecItem yourself by passing the data to the SecItem constructor. If you do initialize the data you may either pass binary data or text (when ascii == True). When you pass ascii data it will be interpreted as base64 encoded binary data. The base64 text may optionally be wrapped inside PEM delimiters, but PEM format is not required.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
a new object with type S, a subtype of T |
|
||
|
|||
string or list of strings |
|
||
string) |
|
||
[(level, string),...] |
|
||
int or long |
|
||
(obj, ...) |
|
||
string or list of strings |
|
||
string or list of strings |
|
|
|||
data contents of SecItem buffer |
|||
len number of octets in SecItem buffer |
|||
type the SecItem type (si* constant) |
|
x[i:j] Use of negative indices is not supported. |
|
|
|
|
|
Formats the object into a sequence of lines with indent level information. The return value is a list where each list item is a tuple. The first item in the tuple is an integer representing the indentation level for that line. Any remaining items in the tuple are strings to be output on that line. The output of this function can be formatted into a single string by calling nss.nss.indented\_format(), e.g.: print indented_format(obj.format_lines()) The reason this function returns a tuple as opposed to an single indented string is to support other text formatting systems such as GUI's with indentation controls. See nss.nss.indented\_format() for a complete explanation.
|
|
Format the binary data in the SecItem as base64 string(s). Either a list of strings is returned or a single string. If chars_per_line is greater than zero then a list of strings will be returned where each string contains chars_per_line number of characters (except for the last string in the list which will contain the remainder of the characters). Returning a list of "lines" makes it convenient for a caller to format a block of base64 data with line wrapping. If chars_per_line is greater than zero indicating a list result is desired a list is always returned even if the number of characters would produce only a single line. If chars_per_line is zero then a single string is returned, (no line splitting is performed). Examples: If data is: c8:94:00:9f:c2:8d:a2:5a:61:92:f2:cd:39:75:73:f4 data.to_hex(0) will return the single string: 'yJQAn8KNolphkvLNOXVz9A==' data.to_hex(5) will return a list of strings where each string has a length of 5 (except the last string which may be shorter): [ 'yJQAn', '8KNol', 'phkvL', 'NOXVz', '9A==' ] If you specify the pem_type optional parameter the return value will be a list of strings whose first and last strings will be a PEM header and footer. For example if pem_type='CERTIFICATE' then the return value will be like this: [ '-----BEGIN CERTIFICATE-----', 'yJQAn8KNolphkvLNOXVz9A==' '-----END CERTIFICATE-----' ] When a list of strings is returned it is easy to form a single text block using the line ending of your choice, for example: '\n'.join(data.to_base64()) Thus a PEM block can be formed like this: '\n'.join(data.to_base64(pem_type='CERTIFICATE'))
|
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 | http://epydoc.sourceforge.net |