第一篇:信息安全課程設(shè)計
信息系統(tǒng)安全課程設(shè)計報告
課題名稱:OpenSSL 非對稱加密
提交文檔學(xué)生姓名:提交文檔學(xué)生學(xué)號:
同組 成 員 名 單:指導(dǎo) 教 師 姓 名:
指導(dǎo)教師評閱成績:指導(dǎo)教師評閱意見:
提交報告時間: 2014年 6 月 10日
1.課程設(shè)計目標(biāo)
了解OpenSSL非對稱加密算法的背景知識,并實現(xiàn)加密解密。
2.分析與設(shè)計
(1)實現(xiàn)方法:
編程語言為C++語言。
編程方法:根據(jù)算法要求編寫代碼。
(2)利用OpenSSL命令制作生成密鑰:
#include
#include
#include
#include
#include
int main()
{
char plain[256]=“啦啦啦啦啦”;
char encrypted[1024];
char decrypted[1024];
const char* pub_key=“public.pem”;
const char* priv_key=“private.pem”;
printf(“%sn”,plain);int len=strlen(plain);BIO *pBio = BIO_new_file(pub_key,“r”);if(pBio==NULL){
printf(“failed to open pub_key file %s!n”, pub_key);
return-1;
}
RSA* rsa1= PEM_read_bio_RSA_PUBKEY(pBio, NULL, NULL, NULL);
if(rsa1==NULL){
printf(“unable to read public key!n”);
return-1;
}
BIO_free_all(pBio);int outlen=RSA_public_encrypt(len,(unsigned char *)plain,(unsigned char *)encrypted, rsa1,RSA_PKCS1_PADDING);
printf(“%dn”,outlen);encrypted[outlen]='