11 * Testing via result comparison.
12 * The only purpose of this file is to test the two cryptographic back-ends.
13 * This functions are not intended to be used in production.
17 isds_error
_isds_init_crypto_gpg(void);
18 isds_error
_isds_init_crypto_openssl(void);
20 _hidden isds_error
_isds_init_crypto(void)
22 if (IE_SUCCESS
!= _isds_init_crypto_gpg()) {
26 if (IE_SUCCESS
!= _isds_init_crypto_openssl()) {
34 isds_error
_isds_compute_hash_gpg(const void *input
, const size_t length
,
35 struct isds_hash
*hash
);
36 isds_error
_isds_compute_hash_openssl(const void *input
, const size_t length
,
37 struct isds_hash
*hash
);
39 _hidden isds_error
_isds_compute_hash(const void *input
, const size_t length
,
40 struct isds_hash
*hash
)
42 isds_error retval_gpg
= IE_SUCCESS
;
43 isds_error retval_openssl
= IE_SUCCESS
;
44 isds_error retval
= IE_SUCCESS
;
45 void *orig_hash_val
= NULL
;
46 size_t orig_hash_len
= 0;
48 retval_gpg
= _isds_compute_hash_gpg(input
, length
, hash
);
50 orig_hash_val
= hash
->value
; hash
->value
= NULL
;
51 orig_hash_len
= hash
->length
; hash
->length
= 0;
53 retval_openssl
= _isds_compute_hash_openssl(input
, length
, hash
);
55 if (retval_gpg
!= retval_openssl
) {
56 fprintf(stderr
, "%s: Return values differ.\n", __func__
);
62 if (IE_SUCCESS
!= retval_gpg
) {
67 if (orig_hash_len
!= hash
->length
) {
68 fprintf(stderr
, "%s: Hash size differs %lu %lu.\n", __func__
,
69 orig_hash_len
, hash
->length
);
75 if (orig_hash_val
== hash
->value
) {
76 fprintf(stderr
, "%s: Hashes are in the same location.\n", __func__
);
82 if (0 != memcmp(orig_hash_val
, hash
->value
, hash
->length
)) {
83 fprintf(stderr
, "%s: Hash value differ.\n", __func__
);
89 free(orig_hash_val
); orig_hash_val
= NULL
; orig_hash_len
= 0;
94 if (NULL
!= orig_hash_val
) {
101 void _isds_cms_data_free_gpg(void *buffer
);
102 void _isds_cms_data_free_opnssl(void *buffer
);
104 _hidden
void _isds_cms_data_free(void *buffer
)
106 _isds_cms_data_free_gpg(buffer
);
110 isds_error
_isds_extract_cms_data_gpg(struct isds_ctx
*context
,
111 const void *cms
, const size_t cms_length
,
112 void **data
, size_t *data_length
);
113 isds_error
_isds_extract_cms_data_openssl(struct isds_ctx
*context
,
114 const void *cms
, const size_t cms_length
,
115 void **data
, size_t *data_length
);
117 _hidden isds_error
_isds_extract_cms_data(struct isds_ctx
*context
,
118 const void *cms
, const size_t cms_length
,
119 void **data
, size_t *data_length
)
121 return _isds_extract_cms_data_gpg(context
, cms
, cms_length
, data
,