pyndn.security.certificate package¶
Submodules¶
pyndn.security.certificate.certificate module¶
-
class
pyndn.security.certificate.certificate.
Certificate
(other=None)[source]¶ Bases:
pyndn.data.Data
-
addExtension
(ext)[source]¶ Add an extension field to the certificate. :param ext: Th CertificateExtension object to add
-
addSubjectDescription
(descr)[source]¶ Add a subject description field to the certificate. :param descr: The CertificateSubjectDescription object to add
-
encode
()[source]¶ Encode the contents of the certificate in DER format and set the Content and MetaInfo fields.
-
epochStart
= datetime.datetime(1970, 1, 1, 0, 0)¶
-
getExtensionList
()[source]¶ Returns: The extension fields of the certificate. Return type: list of CertificateExtension
-
getNotAfter
()[source]¶ Returns the latest date the certificate is valid at. :return: Timestamp as milliseconds since 1970. :rtype: float
-
getNotBefore
()[source]¶ Returns the earliest date the certificate is valid at. :return: Timestamp as milliseconds since 1970. :rtype: float
-
getPublicKeyDer
()[source]¶ Get the public key DER encoding. :return: The DER encoding Blob. :rtype: Blob :throws: RuntimeError if the public key is not set.
-
getPublicKeyInfo
()[source]¶ Returns: The PublicKey object stored in the certificate. Return type: PublicKey
-
getSubjectDescriptions
()[source]¶ Returns: The subject description fields of the certificate. Return type: list of CertificateSubjectDescription
-
isTooEarly
()[source]¶ Check if the certificate start date is in the future :return: True if the certificate cannot be used yet :rtype: boolean
-
isTooLate
()[source]¶ Check if the certificate end date is in the past :return: True if the certificate has expired :rtype: boolean
-
setPublicKeyInfo
(publicKey)[source]¶ Assign a new public key to the certificate. :param publicKey: The new public key :type publicKey: PublicKey
-
-
class
pyndn.security.certificate.certificate.
CertificateExtension
(oid, isCritical, value)[source]¶
pyndn.security.certificate.identity_certificate module¶
-
class
pyndn.security.certificate.identity_certificate.
IdentityCertificate
(data=None)[source]¶ Bases:
pyndn.security.certificate.certificate.Certificate
-
static
certificateNameToPublicKeyName
(certificateName)[source]¶ Extract the name of a public key from the name of an identity certificate. :param Name certificateName: The certificate name.
-
getPublicKeyName
()[source]¶ Returns: The name of the public key associated with this certificate Return type: Name
-
static
pyndn.security.certificate.public_key module¶
This module defines the PublicKey class which holds an encoded public key for use by the security library.
-
class
pyndn.security.certificate.public_key.
PublicKey
(keyDer=None)[source]¶ Bases:
object
Create a new PublicKey by decoding the keyDer. Set the key type from the decoding.
Parameters: keyDer (Blob) – The blob of the PublicKeyInfo in terms of DER. Raises: UnrecognizedKeyFormatException if can’t decode the key DER. -
EC_ENCRYPTION_OID
= '1.2.840.10045.2.1'¶
-
RSA_ENCRYPTION_OID
= '1.2.840.113549.1.1.1'¶
-
encrypt
(plainData, algorithmType)[source]¶ Encrypt the plainData using the keyBits according the encrypt algorithm type.
Parameters: - plainData (Blob or an object which is the same as the bytes() operator) – The data to encrypt.
- algorithmType (int) – The algorithm type from EncryptAlgorithmType. This encrypts according to the algorithm type, e.g., RsaOaep.
Returns: The encrypted data.
Return type:
-
getDigest
(digestAlgorithm=1)[source]¶ Get the digest of the public key.
Parameters: digestAlgorithm (int from DigestAlgorithm) – (optional) The digest algorithm. If omitted, use DigestAlgorithm.SHA256 . Returns: The digest value Return type: Blob
-