我是密码学的新手。需要一点帮助才能开始。
我有Modulus字段和服务器给出的私有指数字段,我需要使用Tomcrypt库从它组成私钥。
我不知道tomcrypt的哪个Api会帮我做这件事。如果任何人可以让我知道api或步骤,它将是神圣的。
谢谢
发布于 2015-08-07 00:24:22
我不确定tomcrypt是否支持从给定的私钥指数和模数字段生成私钥。但是,tomcrypt提供了rsa_make_key函数来生成密钥。然后可以使用rsa_export函数从这些密钥导出公钥/私钥。
/**
Create an RSA key
@param prng An active PRNG state
@param wprng The index of the PRNG desired
@param size The size of the modulus (key size) desired (octets)
@param e The "e" value (public key). e==65537 is a good choice
@param key [out] Destination of a newly created private key pair
@return CRYPT_OK if successful, upon error all allocated ram is freed
*/
int rsa_make_key(prng_state *prng, int wprng, int size, long e, rsa_key *key)
/**
This will export either an RSAPublicKey or RSAPrivateKey [defined in LTC_PKCS #1 v2.1]
@param out [out] Destination of the packet
@param outlen [in/out] The max size and resulting size of the packet
@param type The type of exported key (PK_PRIVATE or PK_PUBLIC)
@param key The RSA key to export
@return CRYPT_OK if successful
*/
int rsa_export(unsigned char *out, unsigned long *outlen, int type, rsa_key *key)https://stackoverflow.com/questions/29798418
复制相似问题