-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split along bn.h (skip when bisecting).
- Loading branch information
1 parent
509919e
commit b2fa136
Showing
15 changed files
with
262 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#ifndef CRYPTO_META_H_ | ||
#define CRYPTO_META_H_ | ||
|
||
#include <assert.h> | ||
|
||
/* All this wrapping/unwrapping solves a fundamental problem: | ||
* - The libtgl implementation wants access to the TGLC_* types. | ||
* - The libtgl implementation should not see any other definitions from any | ||
* external crypto library (to make sure no symbol slips "through" during the | ||
* OpenSSL-to-gcrypt transition). | ||
* - Most TGLC_* types (3 out of 4 types) are exclusively used as pointers | ||
* throughout the libtgl source, in a way to allow for incomplete types. | ||
* - The CORE type (e.g. BIGNUM from <openssl/bn.h>) may be incomplete, | ||
* even for tglc. | ||
* This means the standard approaches don't work: | ||
* - TGLC_NAME can't be a typedef to CORE, since CORE shouldn't even be visible | ||
* from libtgl. | ||
* - TGLC_NAME can't be a pointer to CORE, same reason. Also, it would require | ||
* a significant amount of rewriting (error-prone work). | ||
* - TGLC_NAME can't be a void pointer. Retain type checking! | ||
* - So TGLC_NAME *must* be an incomplete custom struct. | ||
* However, this ensues the following ugliness. | ||
* | ||
* The standard doesn't explicitly allow it, but there's a pretty good argument | ||
* that casting ptr-to-some-struct to ptr-to-other-struct is *probably* okay for | ||
* most compilers: http://stackoverflow.com/a/8702750/3070326 | ||
*/ | ||
#define TGLC_WRAPPER_ASSOC(NAME,CORE) \ | ||
static TGLC_ ## NAME *wrap_ ## NAME (const CORE *p); \ | ||
static CORE *unwrap_ ## NAME (const TGLC_ ## NAME *p) { \ | ||
assert (wrap_ ## NAME); \ | ||
return (CORE *)p; \ | ||
} \ | ||
static TGLC_ ## NAME *wrap_ ## NAME (const CORE *p) { \ | ||
assert (unwrap_ ## NAME); \ | ||
return (TGLC_ ## NAME *)p; \ | ||
} | ||
|
||
#endif /* CRYPTO_META_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.