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) {
|