码迷,mamicode.com
首页 > 编程语言 > 详细

openssl开源程序dh算法解析之p1024.c

时间:2015-06-14 15:11:20      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:openssl   dh   

#include <stdio.h>
#include <openssl/bn.h>
#include <openssl/asn1.h>
#include <openssl/dh.h>
#include <openssl/pem.h>

/*8*16*8=1024,1024代表密钥长度(二进制位数)*/
unsigned char data[] = 
{   0x97, 0xF6, 0x42, 0x61, 0xCA, 0xB5, 0x05, 0xDD,
    0x28, 0x28, 0xE1, 0x3F, 0x1D, 0x68, 0xB6, 0xD3,
    0xDB, 0xD0, 0xF3, 0x13, 0x04, 0x7F, 0x40, 0xE8,
    0x56, 0xDA, 0x58, 0xCB, 0x13, 0xB8, 0xA1, 0xBF,
    0x2B, 0x78, 0x3A, 0x4C, 0x6D, 0x59, 0xD5, 0xF9,
    0x2A, 0xFC, 0x6C, 0xFF, 0x3D, 0x69, 0x3F, 0x78,
    0xB2, 0x3D, 0x4F, 0x31, 0x60, 0xA9, 0x50, 0x2E,
    0x3E, 0xFA, 0xF7, 0xAB, 0x5E, 0x1A, 0xD5, 0xA6,
    0x5E, 0x55, 0x43, 0x13, 0x82, 0x8D, 0xA8, 0x3B,
    0x9F, 0xF2, 0xD9, 0x41, 0xDE, 0xE9, 0x56, 0x89,
    0xFA, 0xDA, 0xEA, 0x09, 0x36, 0xAD, 0xDF, 0x19,
    0x71, 0xFE, 0x63, 0x5B, 0x20, 0xAF, 0x47, 0x03,
    0x64, 0x60, 0x3C, 0x2D, 0xE0, 0x59, 0xF5, 0x4B,
    0x65, 0x0A, 0xD8, 0xFA, 0x0C, 0xF7, 0x01, 0x21,
    0xC7, 0x47, 0x99, 0xD7, 0x58, 0x71, 0x32, 0xBE,
    0x9B, 0x99, 0x9B, 0xB9, 0xB7, 0x87, 0xE8, 0xAB,
};

main()
{
    DH *dh;
    dh = DH_new(); //构造新的dh结构
    dh->p = BN_bin2bn(data, sizeof(data), NULL);
    //将data中的size位的正整数转化为大数,大数返回
    dh->g = BN_new();     //新生成一个BIGNUM结构
    BN_set_word(dh->g, 2);  //dh->g=2
    PEM_write_DHparams(stdout, dh);  //将dh参数写出
}

openssl开源程序dh算法解析之p1024.c

标签:openssl   dh   

原文地址:http://blog.csdn.net/sjtu_chenchen/article/details/46491043

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!