Skip to content
Snippets Groups Projects
Select Git revision
  • 96e32e55d54b6584fec2752abecd23f99fe8e2be
  • master default protected
  • 9.0
  • 8.0
  • 7.8
  • 7.6
  • 7.4
  • 7.2
  • 7.0
  • 0.6
  • rosuav/latex-markdown-renderer
  • rxnpatch/rxnpatch
  • marcus/gobject-introspection
  • rxnpatch/8.0
  • rosuav/pre-listening-ports
  • nt-tools
  • rosuav/async-annotations
  • rosuav/pgsql-ssl
  • rxnpatch/rxnpatch-broken/2023-10-06T094250
  • grubba/fdlib
  • grubba/wip/sakura/8.0
  • v8.0.2000
  • v8.0.1998
  • v8.0.1996
  • v8.0.1994
  • v8.0.1992
  • v8.0.1990
  • v8.0.1988
  • v8.0.1986
  • rxnpatch/clusters/8.0/2025-04-29T124414
  • rxnpatch/2025-04-29T124414
  • v8.0.1984
  • v8.0.1982
  • v8.0.1980
  • v8.0.1978
  • v8.0.1976
  • v8.0.1974
  • v8.0.1972
  • v8.0.1970
  • v8.0.1968
  • v8.0.1966
41 results

constants.h

Blame
  • serpent.h 1.95 KiB
    
    /*
     *
     * Serpent is a 128-bit block cipher that accepts a key size of 256 bits,
     * designed by Ross Anderson, Eli Biham, and Lars Knudsen.  See
     * http://www.cl.cam.ac.uk/~rja14/serpent.html for details.
     */
    
    #if !defined(SERPENT_H)
    #define SERPENT_H
    
    #include <stdlib.h>
    #include "crypto_types.h"
    
    #define SERPENT_BLOCKSIZE 16
    
    /* Other key lengths are possible, but we only use 256 bits.  Besides, the
       design of Serpent makes other key lengths useless; they cheated with the
       AES requirements, using a 256-bit key length exclusively and just padding
       it out if the desired key length was less, so there really is no advantage
       to using key lengths less than 256 bits. */
    #define SERPENT_KEYSIZE 32
    
    /* Allow keys of size 128 <= bits <= 256 */
    
    #define SERPENT_MIN_KEYSIZE 16
    #define SERPENT_MAX_KEYSIZE 32
    
    typedef struct {
      UINT32 keys[33][4];		/* key schedule */
    } SERPENT_context;
    
    /* This performs Serpent's key scheduling algorithm. */
    void
    serpent_setup(SERPENT_context *ctx, UINT32 key_size, const UINT8 *key);
    
    /*
     * serpent_encrypt()
     *
     * Encrypt 16 bytes of data with the Serpent algorithm.  Before this
     * function can be used, serpent_setup must be used in order to initialize
     * Serpent's key schedule.
     *
     * This function always encrypts 16 bytes of plaintext to 16 bytes of
     * ciphertext.  The memory areas of the plaintext and the ciphertext can
     * overlap.
     */
    void
    serpent_encrypt(SERPENT_context *context,
    		const UINT8 *plaintext,
    		UINT8 *ciphertext);
    
    /*
     * serpent_decrypt()
     *
     * Decrypt 16 bytes of data with the Serpent algorithm.
     *
     * Before this function can be used, serpent_setup() must be used in order
     * to set up the key schedule required for the decryption algorithm.
     * 
     * This function always decrypts 16 bytes of ciphertext to 16 bytes of
     * plaintext.  The memory areas of the plaintext and the ciphertext can
     * overlap.
     */
    
    void
    serpent_decrypt(SERPENT_context *context,
    		const UINT8 *ciphertext,
    		UINT8 *plaintext);
    
    #endif /* SERPENT_H */