pike.git / src / post_modules / Nettle / nettle.cmod

version» Context lines:

pike.git/src/post_modules/Nettle/nettle.cmod:628:    }   }      /*! @endclass    */      /*! @class Buffer    *! @belongs Crypto    *! Acts as a buffer so that data can be fed to a cipher in blocks    *! that don't correspond to cipher block sizes. +  *! +  *! @example +  *! class Encrypter +  *! { +  *! protected Crypto.Buffer buffer; +  *! +  *! void create(string key) +  *! { +  *! buffer = Crypto.Buffer(Crypto.CBC(Crypto.AES)); +  *! buffer->set_encrypt_key(key); +  *! } +  *! +  *! string feed(string data) +  *! { +  *! return buffer->crypt(data); +  *! } +  *! +  *! string drain() +  *! { +  *! return buffer->pad(Crypto.PAD_PKCS7); +  *! } +  *! }    */   PIKECLASS Proxy {    CVAR struct object *object;    CVAR int block_size;    CVAR unsigned char *backlog;    CVAR int backlog_len;       INIT {    THIS->object = NULL;    THIS->block_size = 0;
pike.git/src/post_modules/Nettle/nettle.cmod:754:    {    MEMSET(THIS->backlog, 0, THIS->block_size);    THIS->backlog_len = 0;    safe_apply(THIS->object, "set_decrypt_key", args);    pop_stack();    RETURN this_object();    }       /*! @decl string(0..255) crypt(string data)    *! -  *! Encrypt some data. +  *! Encrypt or decrypt some data.    *! -  *! Adds data to be encrypted to the buffer. If there's enough +  *! Adds data to be en/decrypted to the buffer. If there's enough    *! data to en/decrypt a block, that will be done, and the result -  *! returned. Any uncrypted data will be left in the buffer. +  *! returned. Any unprocessed data will be left in the buffer.    */    PIKEFUN string(0..255) crypt(string data) {    unsigned char *result;    ptrdiff_t roffset = 0;    ptrdiff_t soffset = 0;    ptrdiff_t len;    ONERROR uwp;    struct pike_string * res;       if (!(result = malloc(data->len + THIS->block_size)))
pike.git/src/post_modules/Nettle/nettle.cmod:857:    *! space with random data and putting the size of the    *! non-payload data last.    *! @value Crypto.PAD_SSL    *! As ISO 10126, but with the size of the random data last.    *! @value Crypto.PAD_ANSI_X923    *! Pads according to ANSI X.923, which means filling all extra    *! space with zero and putting the size of the non-payload data    *! last.    *! @value Crypto.PAD_PKCS7    *! Pads according to PKCS7 / RFC 3852, which means filling all -  *! extra space with hte size of the extra space. +  *! extra space with the size of the extra space.    *! @value Crypto.PAD_ZERO    *! Fills the extra space with null bytes. To correctly remove    *! the padding the clear text data must not end with a null    *! byte. In that case the data would have to be manually    *! padded/unpadded before/after calling @[crypt()].    *! @endint    *! Defaults to Crypto.PAD_SSL for compatibility reasons.    *!    *! @seealso    *! @[unpad()]