diff options
-rw-r--r-- | cryptography/bindings/openssl/evp.py | 38 | ||||
-rw-r--r-- | docs/contributing.rst | 46 |
2 files changed, 82 insertions, 2 deletions
diff --git a/cryptography/bindings/openssl/evp.py b/cryptography/bindings/openssl/evp.py index 63364374..2b7b0f4c 100644 --- a/cryptography/bindings/openssl/evp.py +++ b/cryptography/bindings/openssl/evp.py @@ -20,10 +20,20 @@ typedef struct { ...; } EVP_CIPHER_CTX; typedef ... EVP_CIPHER; +typedef ... EVP_MD; +typedef struct env_md_ctx_st EVP_MD_CTX; + +typedef struct evp_pkey_st { + int type; + ...; +} EVP_PKEY; +static const int EVP_PKEY_RSA; +static const int EVP_PKEY_DSA; """ FUNCTIONS = """ void OpenSSL_add_all_algorithms(); + const EVP_CIPHER *EVP_get_cipherbyname(const char *); int EVP_EncryptInit_ex(EVP_CIPHER_CTX *, const EVP_CIPHER *, ENGINE *, const unsigned char *, const unsigned char *); @@ -35,7 +45,35 @@ int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *); const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *); int EVP_CIPHER_block_size(const EVP_CIPHER *); void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *); + +EVP_MD_CTX *EVP_MD_CTX_create(); +int EVP_MD_CTX_copy_ex(EVP_MD_CTX *, const EVP_MD_CTX *); +int EVP_DigestInit_ex(EVP_MD_CTX *, const EVP_MD *, ENGINE *); +int EVP_DigestUpdate(EVP_MD_CTX *, const void *, size_t); +int EVP_DigestFinal_ex(EVP_MD_CTX *, unsigned char *, unsigned int *); +int EVP_MD_CTX_cleanup(EVP_MD_CTX *); +void EVP_MD_CTX_destroy(EVP_MD_CTX *); +const EVP_MD *EVP_get_digestbyname(const char *); +const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *); +int EVP_MD_size(const EVP_MD *); + +EVP_PKEY *EVP_PKEY_new(); +void EVP_PKEY_free(EVP_PKEY *); +int EVP_PKEY_type(int); +int EVP_PKEY_bits(EVP_PKEY *); +RSA *EVP_PKEY_get1_RSA(EVP_PKEY *); + +int EVP_SignInit(EVP_MD_CTX *, const EVP_MD *); +int EVP_SignUpdate(EVP_MD_CTX *, const void *, size_t); +int EVP_SignFinal(EVP_MD_CTX *, unsigned char *, unsigned int *, EVP_PKEY *); + +int EVP_VerifyInit(EVP_MD_CTX *, const EVP_MD *); +int EVP_VerifyUpdate(EVP_MD_CTX *, const void *, size_t); +int EVP_VerifyFinal(EVP_MD_CTX *, const unsigned char *, unsigned int, + EVP_PKEY *); """ MACROS = """ +int EVP_PKEY_assign_RSA(EVP_PKEY *, RSA *); +int EVP_PKEY_assign_DSA(EVP_PKEY *, DSA *); """ diff --git a/docs/contributing.rst b/docs/contributing.rst index 2d8fceeb..b125d1af 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -20,8 +20,8 @@ devastating, ``cryptography`` has a strict code review policy: * Patches must *never* be pushed directly to ``master``, all changes (even the most trivial typo fixes!) must be submitted as a pull request. * A committer may *never* merge their own pull request, a second party must - merge their changes. If multiple people work on a pull request, the merger - may not be any of them. + merge their changes. If multiple people work on a pull request, it must be + merged by someone who did not work on it. * A patch which breaks tests, or introduces regressions by changing or removing existing tests should not be merged. Tests must always be passing on ``master``. @@ -50,6 +50,48 @@ Additionally, every Python code file must contain from __future__ import absolute_import, division, print_function +C bindings +---------- + +When binding C code with ``cffi`` we have our own style guide, it's pretty +simple. + +Don't name parameters: + +.. code-block:: c + + // Good + long f(long); + // Bad + long f(long x); + +Don't include stray ``void`` parameters: + +.. code-block:: c + + // Good + long f(); + // Bad + long f(void); + +Wrap lines at 80 characters like so: + +.. code-block:: c + + // Pretend this went to 80 characters + long f(long, long, + int *) + +Include a space after commas between parameters: + +.. code-block:: c + + // Good + long f(int, char *) + // Bad + long f(int,char *) + + Documentation ------------- |