[fpc-devel] OpenSSL bindings improvement

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Mon Jun 21 16:21:25 CEST 2010


Hello,

I just commited my changes, because otherwise our work would conflict.
Please work on top of this new version.

I checked a lot of functions against OpenSSL 1.0.0 and it attested
that they work fine. I added many structures and in added a mechanism
to display which routines couldn't be found in the library. This can
be useful because of the plethora of OpenSSL versions available which
may not have all functions.

In terms of functions I removed some functions which don't exist in
v1.0.0 and added the following:

+  // RAND functions
+  TRAND_set_rand_method = function(const meth: PRAND_METHOD): cint; cdecl;
+  TRAND_get_rand_method = function(): PRAND_METHOD; cdecl;
+  TRAND_SSLeay = function(): PRAND_METHOD; cdecl;
+  TRAND_cleanup = procedure(); cdecl;
+  TRAND_bytes = function(buf: PByte; num: cint): cint; cdecl;
+  TRAND_pseudo_bytes = function(buf: PByte; num: cint): cint; cdecl;
+  TRAND_seed = procedure(const buf: Pointer; num: cint); cdecl;
+  TRAND_add = procedure(const buf: Pointer; num: cint; entropy:
cdouble); cdecl;
+  TRAND_load_file = function(const file_name: PChar; max_bytes:
clong): cint; cdecl;
+  TRAND_write_file = function(const file_name: PChar): cint; cdecl;
+  TRAND_file_name = function(file_name: PChar; num: csize_t): PChar; cdecl;
+  TRAND_status = function(): cint; cdecl;
+  TRAND_query_egd_bytes = function(const path: PChar; buf: PByte;
bytes: cint): cint; cdecl;
+  TRAND_egd = function(const path: PChar): cint; cdecl;
+  TRAND_egd_bytes = function(const path: PChar; bytes: cint): cint; cdecl;
+  TERR_load_RAND_strings = procedure(); cdecl;
+  TRAND_poll = function(): cint; cdecl;
+
+  // RSA Functions
+  TRSA_new = function (): PRSA; cdecl;
+  TRSA_new_method = function (method: PENGINE): PRSA; cdecl;
+  TRSA_size = function (arsa: PRSA): cint; cdecl;
+  TRsaGenerateKey = function(bits, e: cInt; callback: PFunction;
cb_arg: SslPtr): PRSA; cdecl;
+  TRSA_generate_key_ex = function (arsa: PRSA; bits: cInt; e:
PBIGNUM; cb: PBN_GENCB): PRSA; cdecl;
+  TRSA_check_key = function (arsa: PRSA): cint; cdecl;
+  TRSA_public_encrypt = function (flen: cint; from_buf, to_buf:
PByte; arsa: PRSA; padding: cint): cint; cdecl;
+  TRSA_private_encrypt = function (flen: cint; from_buf, to_buf:
PByte; arsa: PRSA; padding: cint): cint; cdecl;
+  TRSA_public_decrypt = function (flen: cint; from_buf, to_buf:
PByte; arsa: PRSA; padding: cint): cint; cdecl;
+  TRSA_private_decrypt = function (flen: cint; from_buf, to_buf:
PByte; arsa: PRSA; padding: cint): cint; cdecl;
+  TRSA_free = procedure (arsa: PRSA); cdecl;
+  TRSA_flags = function (arsa: PRSA): Integer; cdecl;
+  TRSA_set_default_method = procedure (method: PRSA_METHOD); cdecl;
+  TRSA_get_default_method = function : PRSA_METHOD; cdecl;
+  TRSA_get_method = function (prsa: PRSA): PRSA_METHOD; cdecl;
+  TRSA_set_method = function (arsa: PRSA; method: PRSA_METHOD):
PRSA_METHOD; cdecl;
+
+  // X509 Functions
+
+  Td2i_RSAPublicKey = function (arsa: PPRSA; pp: PPByte; len: cint):
PRSA; cdecl;
+  Ti2d_RSAPublicKey = function (arsa: PRSA; pp: PPByte): cint; cdecl;
+  Td2i_RSAPrivateKey = function (arsa: PPRSA; pp: PPByte; len: cint):
PRSA; cdecl;
+  Ti2d_RSAPrivateKey = function (arsa: PRSA; pp: PPByte): cint; cdecl;
+
+  // ERR Functions
+
+  TErr_Error_String = function (e: cInt; buf: PChar): PChar; cdecl;
+
+  // Crypto Functions
+
+  TSSLeay_version = function(t: cint): PChar; cdecl;
+
+  // EVP Functions
+
+  TOpenSSL_add_all_algorithms = procedure(); cdecl;
+  TOpenSSL_add_all_ciphers = procedure(); cdecl;
+  TOpenSSL_add_all_digests = procedure(); cdecl;
+  //
+  TEVP_DigestInit = function(ctx: PEVP_MD_CTX; type_: PEVP_MD): cint; cdecl;
+  TEVP_DigestUpdate = function(ctx: PEVP_MD_CTX; const data: Pointer;
cnt: csize_t): cint; cdecl;
+  TEVP_DigestFinal = function(ctx: PEVP_MD_CTX; md: PByte; s:
pcuint): cint; cdecl;
+  //
+  TEVP_get_cipherbyname = function(const name: PChar): PEVP_CIPHER; cdecl;
+  TEVP_get_digestbyname = function(const name: PChar): PEVP_MD; cdecl;
+  //
+  TEVP_CIPHER_CTX_init = procedure(a: PEVP_CIPHER_CTX); cdecl;
+  TEVP_CIPHER_CTX_cleanup = function(a: PEVP_CIPHER_CTX): cint; cdecl;
+  TEVP_CIPHER_CTX_set_key_length = function(x: PEVP_CIPHER_CTX;
keylen: cint): cint; cdecl;
+  TEVP_CIPHER_CTX_ctrl = function(ctx: PEVP_CIPHER_CTX; type_, arg:
cint; ptr: Pointer): cint; cdecl;
+  //
+  TEVP_EncryptInit = function(ctx: PEVP_CIPHER_CTX; const chipher_:
PEVP_CIPHER;
+           const key, iv: PByte): cint; cdecl;
+  TEVP_EncryptUpdate = function(ctx: PEVP_CIPHER_CTX; out_: pcuchar;
+           outlen: pcint; const in_: pcuchar; inlen: cint): cint; cdecl;
+  TEVP_EncryptFinal = function(ctx: PEVP_CIPHER_CTX; out_data: PByte;
outlen: pcint): cint; cdecl;
+  //
+  TEVP_DecryptInit = function(ctx: PEVP_CIPHER_CTX; chiphir_type: PEVP_CIPHER;
+           const key, iv: PByte): cint; cdecl;
+  TEVP_DecryptUpdate = function(ctx: PEVP_CIPHER_CTX; out_data: PByte;
+           outl: pcint; const in_: PByte; inl: cint): cint; cdecl;
+  TEVP_DecryptFinal = function(ctx: PEVP_CIPHER_CTX; outm: PByte;
outlen: pcint): cint; cdecl;


thanks,
-- 
Felipe Monteiro de Carvalho



More information about the fpc-devel mailing list