Re: [Vala] Openssl vapi



Hi Shawn,

your mail prompted me to post an OpenSSL vapi I did a while ago here:

https://bugzilla.gnome.org/show_bug.cgi?id=684446

Please attach yours there too, it seems we tackled different parts
of OpenSSL API so our two vapis are not overlapping and could easily
be merged.

Hopefully creating a bug for keeping track of efforts towards an
official OpenSSL vapi is going to avoid this being buried in mailing
list archives and help getting it some love/polish/advise from other
people who are interested and in-the-know.

thanks ciao
ste


Il 20/09/2012 07:40, Shawn Ferris ha scritto:
Hi All --

I started a vapi for openssl. I have no previous experience with
openssl so I'm not sure I'm anywhere close to a sane implementation,
even though it seems to be working. I was wondering if someone could
critique it, suggest improvements, etc. I am getting compile warnings,
so I definitely think there needs to be tweaks I would appreciate it
thanks!


$ cat vapi/openssl.vapi
namespace OpenSSL {

  [CCode (cname="ENGINE")]
  public struct ENGINE{}

  [CCode (cprefix="EVP_", lower_case_cprefix="EVP_",
cheader_filename="openssl/evp.h")]
  namespace EVP {

    [CCode (cname="EVP_CIPHER", cprefix="EVP_CIPHER_")]
    public struct CIPHER{
      public int key_length();
      public int iv_length();
    }

    [CCode (cname="EVP_aes_256_cbc")]
    public unowned CIPHER? aes_256_cbc();

    [CCode (cname="EVP_aes_256_ecb")]
    public unowned CIPHER? aes_256_ecb();

    [CCode (cname="EVP_BytesToKey")]
    public int bytes_to_key(
      CIPHER cipher,
      MD md,
      [CCode (array_length = false)] int[] salt,
      uchar[] key_data,
      int nrounds,
      [CCode (array_length = false)] uchar[] key,
      [CCode (array_length = false)] uchar[] iv
    );

    [CCode (cname="EVP_MD")]
    public struct MD{}

    [CCode (cname="EVP_sha1")]
    public unowned MD? sha1();

    //EVP_CIPHER_CTX_init
    [CCode (cname="EVP_CIPHER_CTX_init")]
    public CipherCTX init();

    [CCode (cname = "EVP_CIPHER_CTX", cprefix="EVP_CIPHER_CTX_")]
    public struct CipherCTX {
      public void cleanup();

      [CCode (cname="EVP_EncryptInit_ex")]
      public int encrypt_init(
        CIPHER cipher,
        ENGINE? engine = null,
        [CCode (array_length = false)] uchar* key,
        [CCode (array_length = false)] uchar* iv
      );

      [CCode (cname="EVP_EncryptUpdate")]
      public int encrypt_update(
        [CCode (array_length = false)] uchar* ciphertext,
        out int ciphertext_length,
        [CCode (array_length = false)] uchar* plaintext,
        int plaintext_length
      );

      [CCode (cname="EVP_EncryptFinal_ex")]
      public int encrypt_final(
        [CCode (array_length = false)] uchar* ciphertext,
        out int finished_length
      );

      [CCode (cname="EVP_DecryptInit_ex")]
      public int decrypt_init(
        CIPHER cipher,
        ENGINE? engine = null,
        [CCode (array_length = false)] uchar* key,
        [CCode (array_length = false)] uchar* iv
      );

      [CCode (cname="EVP_DecryptUpdate")]
      public int decrypt_update(
        [CCode (array_length = false)] uchar* plaintext,
        out int plaintext_length,
        [CCode (array_length = false)] uchar* ciphertext,
        int ciphertext_length
      );

      [CCode (cname="EVP_DecryptFinal_ex")]
      public int decrypt_final(
        [CCode (array_length = false)] uchar* plaintext,
        out int finished_length
      );
    }
  }

  [CCode (lower_case_cprefix="AES_", cheader_filename="openssl/aes.h")]
  namespace AES {
    [CCode (cname = "AES_BLOCK_SIZE")]
    public const int BLOCK_SIZE;
  }

}


And these are the warnings I'm getting:


warning: assignment discards âconstâ qualifier from pointer target
type [enabled by default]
warning: passing argument 3 of âEVP_BytesToKeyâ from incompatible
pointer type [enabled by default]
note: expected âconst unsigned char *â but argument is of type âgint *â
warning: assignment discards âconstâ qualifier from pointer target
type [enabled by default]

As always.. I appreciate any feedback/help..

Shawn
_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]