Key class
This class can contains all types of keys that are used in DNSSEC. Mostly used to store private keys, since public keys can also be stored in a ldns_rr with type LDNS_RR_TYPE_DNSKEY. This class can also store some variables that influence the signatures generated by signing with this key, for instance the inception date.
Usage
>>> import ldns
>>> ldns.ldns_init_random(open("/dev/random","rb"), 512/8)
>>> key = ldns.ldns_key.new_frm_algorithm(ldns.LDNS_SIGN_DSA, 512) #generate new DSA key
>>> print key
Private-key-format: v1.2
Algorithm: 3 (DSA)
Prime(p): XXXXXXXXHRQBGRflHZQriSAoLI2g+LGvZz8BlEesO+ZQg65wrFGs9IC441y/mn3nFnXfCdtX6zbN5bQuabPdlQ==
Subprime(q): XXXXXdnWs/cWsGDglhEyZRLEVA8=
Base(g): XXXXXXXqrd+dm2bcxDBdCsZRzkXQ22FxCk2ycnjgevr+s2HfA57BPk3xwqCrHUwuOBVg3Fvq4bpldrCe0sT6Og==
Private_value(x): XXXXXcVubZF33pj04z4ZoETsQW1Y=
Public_value(y): XXXXXX8t6zfOxJHoy57qteIw9sOZ/Zu0yFiPO083sPm11NlFx3b4m7TJ2k41gYicHXHLUQK1p0xXFToeZEkPGQ==
>>> fw = open("key.priv", "wb")
>>> key.print_to_file(fw) #write priv key to file
return the signing alg of the key
Returns: | (ldns_signing_algorithm) the algorithm |
---|
returns the (openssl) DSA struct contained in the key
Returns: | (DSA *) |
---|
returns the (openssl) EVP struct contained in the key
Returns: | (EVP_PKEY *) the RSA * structure in the key |
---|
return the key’s expiration date
Returns: | (uint32_t) the experiration date |
---|
return the flag of the key
Returns: | (uint16_t) the flag |
---|
return the hmac key data
Returns: | (unsigned char *) the hmac key data |
---|
return the hmac key size
Returns: | (size_t) the hmac key size |
---|
return the key’s inception date
Returns: | (uint32_t) the inception date |
---|
converts a ldns_key to a public key rr
Returns: | (ldns_rr *) ldns_rr representation of the key |
---|
return the keytag
Returns: | (uint16_t) the keytag |
---|
Creates a new key based on the algorithm.
Parameters: |
|
---|---|
Returns: | key instance or None. If the object can’t be created and raiseException is True, an exception occurs. |
Creates a new priv key based on the contents of the file pointed by fp.
Parameters: |
|
---|---|
Returns: | key instance or None. If the object can’t be created and raiseException is True, an exception occurs. |
Creates a new private key based on the contents of the file pointed by fp.
Parameters: |
|
---|---|
Returns: |
|
return the original ttl of the key
Returns: | (uint32_t) the original ttl |
---|
print a private key to the file ouput
Parameters: | file – output file pointer |
---|
return the public key’s owner
Returns: | (ldns_rdf *) the owner |
---|
returns the (openssl) RSA struct contained in the key
Returns: | (RSA *) the RSA * structure in the key |
---|
Set the key’s algorithm.
Parameters: | l – the algorithm |
---|
Set the key’s dsa data.
Parameters: | d – the dsa data |
---|
Set the key’s evp key.
Parameters: | e – the evp key |
---|
Set the key’s expiration date (seconds after epoch).
Parameters: | e – the expiration |
---|
Set the key’s flags.
Parameters: | flags – the flags |
---|
Set the key’s hmac data.
Parameters: | hmac – the raw key data |
---|
Set the key’s hmac size.
Parameters: | hmac_size – the size of the hmac data |
---|
Set the key’s inception date (seconds after epoch).
Parameters: | i – the inception |
---|
Set the key’s key tag.
Parameters: | tag – the keytag |
---|
Set the key’s original ttl.
Parameters: | t – the ttl |
---|
Set the key’s pubkey owner.
Parameters: | r – the owner |
---|
Set the key’s rsa data.
Parameters: | r – the rsa data |
---|
set the use flag
Parameters: | v – the boolean value to set the _use field to |
---|
return the use flag
Returns: | (bool) the boolean value of the _use field |
---|