16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/* Define maximum certificate size. Max PEM size 100kB and DER size is 24kB. */
#define CERT_STR_SIZE 32768
/*
* Binary string to hex string
*/
int String_to_Hex(char* input, int ilen, char *output, int olen) {
int count = 0;
for (int i = 0; i < ilen && count < olen - 1; i++, count += 2) {
sprintf(output + count, "%02X", input[i] & 0xff);
}
output[count] = 0;
return count;
}
/*
* BIO to Buffer
*/
int BIO_to_Buffer(int result, BIO *bio, void *buffer, int size) {
|
|
>
>
>
<
>
>
|
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
/* Define maximum certificate size. Max PEM size 100kB and DER size is 24kB. */
#define CERT_STR_SIZE 32768
/*
* Binary string to hex string
*/
int String_to_Hex(unsigned char* input, int ilen, unsigned char *output, int olen) {
int count = 0;
unsigned char *iptr = input;
unsigned char *optr = &output[0];
const char *hex = "0123456789ABCDEF";
for (int i = 0; i < ilen && count < olen - 1; i++, count += 2) {
*optr++ = hex[(*iptr>>4)&0xF];
*optr++ = hex[(*iptr++)&0xF];
}
*optr = 0;
return count;
}
/*
* BIO to Buffer
*/
int BIO_to_Buffer(int result, BIO *bio, void *buffer, int size) {
|
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
*/
Tcl_Obj *Tls_x509Identifier(ASN1_OCTET_STRING *astring) {
Tcl_Obj *resultPtr = NULL;
int len = 0;
char buffer[1024];
if (astring != NULL) {
len = String_to_Hex((char *)ASN1_STRING_get0_data(astring),
ASN1_STRING_length(astring), buffer, 1024);
}
resultPtr = Tcl_NewStringObj(buffer, len);
return resultPtr;
}
/*
|
|
|
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
*/
Tcl_Obj *Tls_x509Identifier(ASN1_OCTET_STRING *astring) {
Tcl_Obj *resultPtr = NULL;
int len = 0;
char buffer[1024];
if (astring != NULL) {
len = String_to_Hex(ASN1_STRING_get0_data(astring),
ASN1_STRING_length(astring), buffer, 1024);
}
resultPtr = Tcl_NewStringObj(buffer, len);
return resultPtr;
}
/*
|