Skip to content
Snippets Groups Projects
Select Git revision
1 result Searching

aes.c

Blame
  • Forked from Nettle / nettle
    Source project has a limited visibility.
    desdata.c 4.43 KiB
    /* desdata.c
     *
     * Generate tables used by des.c and desCode.h.
     *
     * $Id$ */
    
    /*
     *	des - fast & portable DES encryption & decryption.
     *	Copyright (C) 1992  Dana L. How
     *	Please see the file `descore.README' for the complete copyright notice.
     *
     */
    
    #if HAVE_CONFIG_H
    # include "config.h"
    #endif
    
    #include	"desinfo.h"
    
    #include	"desCode.h"
    
    
    /* list of weak and semi-weak keys
    
    	 +0   +1   +2   +3   +4   +5   +6   +7
    	0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
    	0x01 0x1f 0x01 0x1f 0x01 0x0e 0x01 0x0e
    	0x01 0xe0 0x01 0xe0 0x01 0xf1 0x01 0xf1
    	0x01 0xfe 0x01 0xfe 0x01 0xfe 0x01 0xfe
    	0x1f 0x01 0x1f 0x01 0x0e 0x01 0x0e 0x01
    	0x1f 0x1f 0x1f 0x1f 0x0e 0x0e 0x0e 0x0e
    	0x1f 0xe0 0x1f 0xe0 0x0e 0xf1 0x0e 0xf1
    	0x1f 0xfe 0x1f 0xfe 0x0e 0xfe 0x0e 0xfe
    	0xe0 0x01 0xe0 0x01 0xf1 0x01 0xf1 0x01
    	0xe0 0x1f 0xe0 0x1f 0xf1 0x0e 0xf1 0x0e
    	0xe0 0xe0 0xe0 0xe0 0xf1 0xf1 0xf1 0xf1
    	0xe0 0xfe 0xe0 0xfe 0xf1 0xfe 0xf1 0xfe
    	0xfe 0x01 0xfe 0x01 0xfe 0x01 0xfe 0x01
    	0xfe 0x1f 0xfe 0x1f 0xfe 0x0e 0xfe 0x0e
    	0xfe 0xe0 0xfe 0xe0 0xfe 0xf1 0xfe 0xf1
    	0xfe 0xfe 0xfe 0xfe 0xfe 0xfe 0xfe 0xfe
     */
    
    /* key bit order in each method pair: bits 31->00 of 1st, bits 31->00 of 2nd */
    /* this does not reflect the rotate of the 2nd word */
    
    #define	S(box,bit)	(box*6+bit)
    int korder[] = {
    	S(7, 5), S(7, 4), S(7, 3), S(7, 2), S(7, 1), S(7, 0),
    	S(5, 5), S(5, 4), S(5, 3), S(5, 2), S(5, 1), S(5, 0),
    	S(3, 5), S(3, 4), S(3, 3), S(3, 2), S(3, 1), S(3, 0),
    	S(1, 5), S(1, 4), S(1, 3), S(1, 2), S(1, 1), S(1, 0),
    	S(6, 5), S(6, 4), S(6, 3), S(6, 2), S(6, 1), S(6, 0),
    	S(4, 5), S(4, 4), S(4, 3), S(4, 2), S(4, 1), S(4, 0),
    	S(2, 5), S(2, 4), S(2, 3), S(2, 2), S(2, 1), S(2, 0),
    	S(0, 5), S(0, 4), S(0, 3), S(0, 2), S(0, 1), S(0, 0),
    };
    
    /* the order in which the algorithm accesses the s boxes */
    
    int sorder[] = {
    	7, 5, 3, 1, 6, 4, 2, 0,
    };
    
    int printf(const char *, ...);
    
    int
    main(int argc UNUSED, char **argv UNUSED)
    {
    	uint32_t d, i, j, k, l, m, n, s;