资源描述:
《openssl源代码分析》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Openssl源代码的特点:1、openssl中只有实现而没有调用的函数2、openssl中各系列的函数都是用宏定义的(因而无法用代码浏览工具找到其定义)用于定义X509的new、free、i2d和d2i函数的宏:1、函数声明DECLARE_ASN1_FUNCTIONS(X509)用于声明函数x509x509.h在openssl中的具体定义如下:asn1asn1.h/*DeclareASN1functions:theimplementmacroininasn1t.h*/#defineDECLARE
2、_ASN1_FUNCTIONS(type)DECLARE_ASN1_FUNCTIONS_name(type,type)#defineDECLARE_ASN1_ALLOC_FUNCTIONS(type)DECLARE_ASN1_ALLOC_FUNCTIONS_name(type,type)#defineDECLARE_ASN1_FUNCTIONS_name(type,name)DECLARE_ASN1_ALLOC_FUNCTIONS_name(type,name)DECLARE_ASN1_ENCO
3、DE_FUNCTIONS(type,name,name)#defineDECLARE_ASN1_FUNCTIONS_fname(type,itname,name)DECLARE_ASN1_ALLOC_FUNCTIONS_name(type,name)DECLARE_ASN1_ENCODE_FUNCTIONS(type,itname,name)#defineDECLARE_ASN1_ENCODE_FUNCTIONS(type,itname,name)type*d2i_##name(type**a,
4、constunsignedchar**in,longlen);inti2d_##name(type*a,unsignedchar**out);DECLARE_ASN1_ITEM(itname)#defineDECLARE_ASN1_ENCODE_FUNCTIONS_const(type,name)type*d2i_##name(type**a,constunsignedchar**in,longlen);inti2d_##name(consttype*a,unsignedchar**out);
5、DECLARE_ASN1_ITEM(name)#defineDECLARE_ASN1_NDEF_FUNCTION(name)inti2d_##name##_NDEF(name*a,unsignedchar**out);#defineDECLARE_ASN1_FUNCTIONS_const(name)DECLARE_ASN1_ALLOC_FUNCTIONS(name)DECLARE_ASN1_ENCODE_FUNCTIONS_const(name,name)#defineDECLARE_ASN1
6、_ALLOC_FUNCTIONS_name(type,name)type*name##_new(void);voidname##_free(type*a);用于函数的实现asn1x_x509.cASN1_SEQUENCE_ref(X509,x509_cb,CRYPTO_LOCK_X509)={ASN1_SIMPLE(X509,cert_info,X509_CINF),ASN1_SIMPLE(X509,sig_alg,X509_ALGOR),ASN1_SIMPLE(X509,signature,A
7、SN1_BIT_STRING)}ASN1_SEQUENCE_END_ref(X509,X509)IMPLEMENT_ASN1_FUNCTIONS(X509)2、ASN1_SEQUENCE_ref:ASN1_SEQUENCE_ref:asn1asn1t.h#defineASN1_SEQUENCE_ref(tname,cb,lck)staticconstASN1_AUXtname##_aux={NULL,ASN1_AFLG_REFCOUNT,offsetof(tname,references),lck
8、,cb,0};ASN1_SEQUENCE(tname)3、ASN1_SEQUENCE用于SEQUENCE,表明下面的编码是一个SEQUENCE。#defineASN1_SEQUENCE(tname)staticconstASN1_TEMPLATEtname##_seq_tt[]#defineASN1_SEQUENCE_END(stname)ASN1_SEQUENCE_END_name(stname,stname)#defineASN1_SEQUENC