首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用tomcrypt从Modulus和Exponent生成RSA私钥

使用tomcrypt从Modulus和Exponent生成RSA私钥
EN

Stack Overflow用户
提问于 2015-04-22 21:01:59
回答 1查看 742关注 0票数 0

我是密码学的新手。需要一点帮助才能开始。

我有Modulus字段和服务器给出的私有指数字段,我需要使用Tomcrypt库从它组成私钥。

我不知道tomcrypt的哪个Api会帮我做这件事。如果任何人可以让我知道api或步骤,它将是神圣的。

谢谢

EN

回答 1

Stack Overflow用户

发布于 2015-08-07 00:24:22

我不确定tomcrypt是否支持从给定的私钥指数和模数字段生成私钥。但是,tomcrypt提供了rsa_make_key函数来生成密钥。然后可以使用rsa_export函数从这些密钥导出公钥/私钥。

代码语言:javascript
复制
/** 
   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)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29798418

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档