def save_pub_key(self, file): """ Save the public key to a file in PEM format. @type file: string @param file: Name of file to save key to. """ bio = BIO.openfile(file, "wb") return m2.rsa_write_pub_key(self.rsa, bio._ptr())
def save_key_der(self, file): """ Save the key pair to a file in DER format. @type bio: M2Crypto.BIO.BIO @param bio: M2Crypto.BIO.BIO object to save key to. """ bio = BIO.openfile(file, 'wb') return self.save_key_der_bio(bio)
def save_key_der(self, file): """ Save the key pair to a file in DER format. @type file: str @param file: Filename to save key to """ bio = BIO.openfile(file, "wb") return self.save_key_der_bio(bio)
def save_key_der(self, file): """ Save the key pair to a file in DER format. @type file: str @param file: Filename to save key to """ bio = BIO.openfile(file, 'wb') return self.save_key_der_bio(bio)
def save_pub_key(self, file): """ Save the public key to a file in PEM format. @type file: string @param file: Name of file to save key to. """ bio = BIO.openfile(file, 'wb') return m2.rsa_write_pub_key(self.rsa, bio._ptr())
def load_pub_key(file): """ Load an RSA public key from file. @type file: string @param file: Name of file containing RSA public key in PEM format. @rtype: M2Crypto.RSA.RSA_pub @return: M2Crypto.RSA.RSA_pub object. """ bio = BIO.openfile(file) return load_pub_key_bio(bio)
def load_key(file, callback=util.passphrase_callback): """ Factory function that instantiates a EC object. @param file: Names the file that contains the PEM representation of the EC key pair. @param callback: Python callback object that will be invoked if the EC key pair is passphrase-protected. """ bio = BIO.openfile(file) return load_key_bio(bio, callback)
def save_params(self, filename): """ Save the DSA parameters to a file. @type filename: str @param filename: Save the DSA parameters to this file. @return: 1 (true) if successful """ bio = BIO.openfile(filename, 'wb') ret = m2.dsa_write_params_bio(self.dsa, bio._ptr()) bio.close() return ret
def save_pub_key(self, filename): """ Save the DSA public key (with parameters) to a file. @type filename: str @param filename: Save DSA public key (with parameters) to this file. @return: 1 (true) if successful """ bio = BIO.openfile(filename, 'wb') ret = self.save_pub_key_bio(bio) bio.close() return ret
def save_pub_key(self, filename): """ Save the DSA public key (with parameters) to a file. @type filename: str @param filename: Save DSA public key (with parameters) to this file. @return: 1 (true) if successful """ bio = BIO.openfile(filepath, 'wb') ret = self.save_pub_key_bio(bio) bio.close() return ret
def save_key(self, filename, cipher='aes_128_cbc', callback=util.passphrase_callback): """ Save the DSA key pair to a file. @type filename: str @param filename: Save the DSA key pair to this file. @type cipher: str @param cipher: name of symmetric key algorithm and mode to encrypt the private key. @return: 1 (true) if successful """ bio = BIO.openfile(filepath, 'wb') ret = self.save_key_bio(bio, cipher, callback) bio.close() return ret
def save_key(self, filename, cipher='aes_128_cbc', callback=util.passphrase_callback): """ Save the DSA key pair to a file. @type filename: str @param filename: Save the DSA key pair to this file. @type cipher: str @param cipher: name of symmetric key algorithm and mode to encrypt the private key. @return: 1 (true) if successful """ bio = BIO.openfile(filename, 'wb') ret = self.save_key_bio(bio, cipher, callback) bio.close() return ret
def load_key(file, callback=util.passphrase_callback): """ Load an RSA key pair from file. @type file: string @param file: Name of file containing RSA public key in PEM format. @type callback: Python callable @param callback: A Python callable object that is invoked to acquire a passphrase with which to unlock the key. The default is util.passphrase_callback. @rtype: M2Crypto.RSA.RSA @return: M2Crypto.RSA.RSA object. """ bio = BIO.openfile(file) return load_key_bio(bio, callback)
def save_key(self, file, cipher='aes_128_cbc', callback=util.passphrase_callback): """ Save the key pair to a file in PEM format. @type file: string @param file: Name of file to save key to. @type cipher: string @param cipher: Symmetric cipher to protect the key. The default cipher is 'aes_128_cbc'. If cipher is None, then the key is saved in the clear. @type callback: Python callable @param callback: A Python callable object that is invoked to acquire a passphrase with which to protect the key. The default is util.passphrase_callback. """ bio = BIO.openfile(file, 'wb') return self.save_key_bio(bio, cipher, callback)
def load_key(file, callback=util.passphrase_callback): """ Factory function that instantiates a DSA object from a PEM encoded DSA key pair. @type file: str @param file: Names the file (a path) that contains the PEM representation of the DSA key pair. @type callback: A Python callable @param callback: A Python callback object that will be invoked if the DSA key pair is passphrase-protected. @rtype: DSA @return: instance of DSA. """ bio = BIO.openfile(file) ret = load_key_bio(bio, callback) bio.close() return ret
def save_key(self, file, cipher="aes_128_cbc", callback=util.passphrase_callback): """ Save the key pair to a file in PEM format. @type file: string @param file: Name of file to save key to. @type cipher: string @param cipher: Symmetric cipher to protect the key. The default cipher is 'aes_128_cbc'. If cipher is None, then the key is saved in the clear. @type callback: Python callable @param callback: A Python callable object that is invoked to acquire a passphrase with which to protect the key. The default is util.passphrase_callback. """ bio = BIO.openfile(file, "wb") return self.save_key_bio(bio, cipher, callback)
def load_pub_key(file, callback=util.passphrase_callback): """ Factory function that instantiates a DSA_pub object using a DSA public key contained in PEM file. The PEM file must contain the parameters in addition to the public key. @type file: str @param file: Names the file (a path) that contains the PEM representation of the DSA public key. @type callback: A Python callable @param callback: A Python callback object that will be invoked should the DSA public key be passphrase-protected. @rtype: DSA_pub @return: instance of DSA_pub. """ bio = BIO.openfile(file) ret = load_pub_key_bio(bio, callback) bio.close() return ret
def load_params(file): bio = BIO.openfile(file) return load_params_bio(bio)