Skip to content
Snippets Groups Projects
Select Git revision
  • c576914adfd66801565a743b211cd8256627c48d
  • master default protected
  • streebog
  • gost28147
  • master-updates
  • ed448
  • shake256
  • curve448
  • ecc-sqrt
  • gosthash94cp
  • cmac64
  • block16-refactor
  • siv-mode
  • cmac-layout
  • delete-des-compat
  • delete-rsa_blind
  • aes-struct-layout
  • release-3.4-fixes
  • struct-layout
  • attribute-deprecated
  • rename-data-symbols
  • nettle_3.5.1_release_20190627
  • nettle_3.5_release_20190626
  • nettle_3.5rc1
  • nettle_3.4.1_release_20181204
  • nettle_3.4.1rc1
  • nettle_3.4_release_20171119
  • nettle_3.4rc2
  • nettle_3.4rc1
  • nettle_3.3_release_20161001
  • nettle_3.2_release_20160128
  • nettle_3.1.1_release_20150424
  • nettle_3.1_release_20150407
  • nettle_3.1rc3
  • nettle_3.1rc2
  • nettle_3.1rc1
  • nettle_3.0_release_20140607
  • nettle_2.7.1_release_20130528
  • nettle_2.7_release_20130424
  • nettle_2.6_release_20130116
  • nettle_2.5_release_20120707
41 results

desTest.c

Blame
  • Forked from Nettle / nettle
    Source project has a limited visibility.
    desTest.c 4.14 KiB
    /* desTest.c
     *
     * Exercise the DES routines and collect performance statistics.
     *
     * $ID:$ */
    
    /*	des - fast & portable DES encryption & decryption.
     *	Copyright (C) 1992  Dana L. How
     *	Please see the file `descore.README' for the complete copyright notice.
     */
    
    #ifndef	lint
    char desTest_cRcs[] = "$Id$";
    #endif
    
    #include "des.h"
    #include <stdio.h>
    
    #if 0
    /* define now(w) to be the elapsed time in hundredths of a second */
    
    #ifndef __NT__
    # include	<sys/time.h>
    # include	<sys/resource.h>
    # include	<unistd.h>
    
    /* extern getrusage(); */
    static struct rusage usage;
    # define	now(w)	(				\
    		getrusage(RUSAGE_SELF, &usage),		\
    		usage.ru_utime.tv_sec  * 100 +		\
    		usage.ru_utime.tv_usec / 10000		\
    	)
    #else
    # include       <windows.h>
    # define now(w) 0
    #endif
    #endif /* 0 */
         
    /* test data
     * the tests (key0-3, text0-3) are cribbed from code which is (c) 1988 MIT
     */
    
    UINT8 keyt[8]  = {0x5d, 0x85, 0x91, 0x73, 0xcb, 0x49, 0xdf, 0x2f};
    UINT8 key0[8]  = {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x80};
    UINT8 key1[8]  = {0x80, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
    UINT8 key2[8]  = {0x08, 0x19, 0x2a, 0x3b, 0x4c, 0x5d, 0x6e, 0x7f};
    UINT8 key3[8]  = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};
    UINT8 textt[8] = {0x67, 0x1f, 0xc8, 0x93, 0x46, 0x5e, 0xab, 0x1e};
    UINT8 text0[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    UINT8 text1[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40};
    UINT8 text2[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    UINT8 text3[8] = {'N',  'o',  'w',  ' ',  'i',  's',  ' ',  't' };
    
    /* work areas */
    
    DesKeys keys;
    UINT8 cipher[8], output[8];
    
    /* noisy interfaces to the routines under test */
    
    static void method(const UINT8 *key)
    {
    	int j;
    
    	printf("\nkey:\t");
    	for ( j = 0; j < 8; j++ )
    		printf("%02X ", key[j]);
    	if ( des_key_sched(key, keys) )
    		printf("W");