From 7657852ad35c76d82e66116e413e11753fe918c3 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 1 Jun 2016 05:00:55 +0000 Subject: crypt_r.c: DES tables * missing/crypt_r.c (des_tables): move sharable DES constant tables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- crypt.h | 21 --------------------- missing/crypt_r.c | 55 +++++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 45 insertions(+), 31 deletions(-) diff --git a/crypt.h b/crypt.h index ca7669498f..2048f76b1a 100644 --- a/crypt.h +++ b/crypt.h @@ -216,34 +216,13 @@ typedef union { #define CHUNKBITS (1< 0..63 */ - - /* Initial key schedule permutation */ - C_block PC1ROT[64/CHUNKBITS][1< final permutation table */ - C_block CF6464[64/CHUNKBITS][1< ascii-64 */ "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; +/* ===== Tables that are initialized at run time ==================== */ + +typedef struct { + /* table that converts chars "./0-9A-Za-z"to integers 0-63. */ + unsigned char a64toi[128]; + + /* Initial key schedule permutation */ + C_block PC1ROT[64/CHUNKBITS][1< final permutation table */ + C_block CF6464[64/CHUNKBITS][1<a64toi) +#define PC1ROT (des_tables->PC1ROT) +#define PC2ROT (des_tables->PC2ROT) +#define IE3264 (des_tables->IE3264) +#define SPE (des_tables->SPE) +#define CF6464 (des_tables->CF6464) -#define a64toi (data->a64toi) -#define PC1ROT (data->PC1ROT) -#define PC2ROT (data->PC2ROT) -#define IE3264 (data->IE3264) -#define SPE (data->SPE) -#define CF6464 (data->CF6464) #define KS (data->KS) -#define constdatablock (data->constdatablock) #define cryptresult (data->cryptresult) #define des_ready (data->initialized) -STATIC void init_des(struct crypt_data *); +STATIC void init_des(void); STATIC void init_perm(C_block perm[64/CHUNKBITS][1<ready) return; + /* * table that converts chars "./0-9A-Za-z"to integers 0-63. */ @@ -695,6 +728,8 @@ init_des(struct crypt_data *data) TO_SIX_BIT(SPE[1][tableno][j], k); } } + + des_tables->ready = 1; } /* -- cgit v1.2.3