def key_info(pkey, cert, key_info_template):
 exponent = base64.b64encode(pkey.e[4:])
 modulus = m2.bn_to_hex(m2.mpi_to_bn(pkey.n)).decode('hex').encode('base64')
 x509 = (x509_parse_cert(cert) if cert else None)
 return (key_info_template % {'modulus': modulus, 'exponent': exponent, 'issuer_name': (x509.get_issuer().as_text() if x509 else ''), 'serial_number': (x509.get_serial_number() if x509 else '')})

def key_info ( pkey , cert , key_info_template ) : exponent = base64 . b64encode ( pkey . e [ 4 : ] ) modulus = m2 . bn_to_hex ( m2 . mpi_to_bn ( pkey . n ) ) . decode ( 'hex' ) . encode ( 'base64' ) x509 = ( x509_parse_cert ( cert ) if cert else None ) return ( key_info_template % { 'modulus' : modulus , 'exponent' : exponent , 'issuer_name' : ( x509 . get_issuer ( ) . as_text ( ) if x509 else '' ) , 'serial_number' : ( x509 . get_serial_number ( ) if x509 else '' ) } )
convert private key to xml signature format .