def _build_ekey_from_file(keyfile): fp = evp.fopen(keyfile, "r") if not fp: raise EnvelopeError("Could not open keyfile") # get the encryption key ekey = evp.PEM_read_PUBKEY(fp, None, None, None) if not ekey: evp.fclose(fp) raise EnvelopeError("Could not read encryption key") # close the file evp.fclose(fp) return ekey
def _build_dkey_from_file(keyfile): fp = evp.fopen(keyfile, "r") if not fp: raise EnvelopeError("Could not open keyfile") # get the decryption key skey = evp.PEM_read_PrivateKey(fp, None, None, None) if not skey: evp.fclose(fp) raise EnvelopeError("Could not read decryption key") # close the file evp.fclose(fp) return skey
def _build_vkey_from_file(keyfile): fp = evp.fopen(keyfile, "r") if not fp: raise SignatureError("Could not open keyfile") # get the verification key vkey = evp.PEM_read_PUBKEY(fp, None, None, None) if not vkey: evp.fclose(fp) raise SignatureError("Could not read verification key") # close the file evp.fclose(fp) return vkey
def _build_skey_from_file(keyfile): fp = evp.fopen(keyfile, "r") if not fp: raise SignatureError("Could not open keyfile") # get the signing key skey = evp.PEM_read_PrivateKey(fp, None, None, None) if not skey: evp.fclose(fp) raise SignatureError("Could not read signing key") # close the file evp.fclose(fp) return skey