1int main(int argc,char argc) |
2 |
3connect(client,(struct sockaddr &serv,sizeof(serv)); |
4Gene_Rand; |
5Comp_Str; |
6memcpy(plaitxt_A_E,Str_Id,1024); |
7Public_Encrypt(plaitxt_A_E); |
8strcpy(Cipher_buf,(const char cipher); |
9iSend=send(client,Cipher,sizeof(cipher),0); |
10iLen=recv(client,(char cipher,sizeof(cipher),0); |
11memcpy(Tcipher_Na_Nb,cipher_Na_Nb,1024); |
12Private_Dencrypt_Na_Nb(R,Tcipher_Na_Nb); |
13memcpy(plaitxt_Nb,StrNb,1024); |
14Public_Encrypt_Nb(plaitxt_Nb); |
15strcpy(Cipher,(const char cipher); |
16iSend=send(client,Cipher,sizeof(Cipher),0); |
|
18int Gene_Rand |
19 |
20n=BN_new; |
21ret=BN_pseudo_rand(n,bits,1,1); |
22sn=BN_bn2dec(n); |
23strcpy(RandNum,sn); |
|
25int Comp_Str; |
26 |
27strcat(Str_Id,RandNum); |
28strcat(Str_Id, ''A''); |
|
30int Public_Encrypt(unsigned char ) |
31 |
32bnn=BN_new; |
33bne=BN_new; |
34ret=BN_dec2bn(&bnn,strn); |
35ret=BN_dec2bn(&bne,stre); |
36r=RSA_new; |
37flen=RSA_size(r); |
38len=RSA_public_encrypt(flen,s,cipher_A_E,r,3); |
|
40int Private_Dencrypt_Na_Nb(RSA ,unsigned char ); |
41 |
42flen=RSA_size(r); |
43len=RSA_private_decrypt(flen,s,plaitext_Na_Nb, r,3); |
|
45int Public_Encrypt_Nb(unsigned char ) |
46 |
47bnn=BN_new; |
48bne=BN_new; |
49ret=BN_dec2bn(&bnn,strn); |
50ret=BN_dec2bn(&bne,stre); |
51r=RSA_new; |
52flen=RSA_size(r); |
53len=RSA_public_encrypt(flen,s,cipher_Nb,r,3); |
|