$ od -c -N 50000 [_CDCSL_93-16_]<1>Cedar>release>SHS>SHS.c
0000000 / * \n * C o p y r i g h t
0000020 323 1 9 9 2 b y X e r o x
0000040 C o r p o r a t i o n . A
0000060 l l r i g h t s r e s e r v
0000100 e d . \n * S e p t e m b e r
0000120 3 0 , 1 9 9 2 \n * A s
0000140 t r a i g h t f o r w a r d i
0000160 m p l e m e n t a t i o n o f
0000200 t h e p r o p o s e d S e
0000220 c u r e \n * H a s h S t
0000240 a n d a r d ( S H S ) , d a
0000260 t e d 2 2 J a n u a r y 1
0000300 9 9 2 . \n * \n * T o u s
0000320 e : a l l o c a t e a n S
0000340 H S _ C T X a n d p a s s
0000360 i t t o S H S I n i t ; \n
0000400 * r e p e a t e d l y c a l
0000420 l S H S U p d a t e o n s
0000440 u c c e s s i v e c h u n k s
0000460 o f t h e m e s s a g e \n
0000500 * t h e n c a l l S H S
0000520 F i n a l ( h a s h , c t x )
0000540 . \n * T h e h a s h i s
0000560 i n c t x - > s t a t e ,
0000600 a s 4 b y t e i n t e g e
0000620 r s \n * a n d , p r o p e
0000640 r l y r e o r g a n i z e d
0000660 f o r e n d i a n - n e s s ,
0000700 i n * h a s h . \n * \n *
0000720 / \n \n # i n c l u d e " S H S
0000740 . h " \n \n s t a t i c v o i d
0000760 o n e m ( ) ; \n \n s t a t i c
0001000 c h a r e n d i a n T e s t
0001020 [ 4 ] = { 0 , 0 , 0 ,
0001040 1 } ; \n s t a t i c i n t l
0001060 i t t l e E n d i a n ; \n \n s t
0001100 a t i c v o i d i n t F r o
0001120 m C h a r s ( ) ; \n \n v o i d
0001140 S H S I n i t ( c t x ) \n
0001160 S H S _ C T X * c t x ;
0001200 \n { \n i n t t e s t I
0001220 n t ; \n \n i n t
0001240 F r o m C h a r s ( & t e s t
0001260 I n t , e n d i a n T e s t
0001300 ) ; \n l i t t l e E n d
0001320 i a n = ( * ( ( i n t * )
0001340 e n d i a n T e s t ) = = 1 ?
0001360 0 : 1 ) ; \n \n
0001400 c t x - > s t a t e [ 0 ]
0001420 = 0 x 6 7 4 5 2 3 0 1 ; \n
0001440 c t x - > s t a t e [ 1 ]
0001460 = 0 x 0 e f c d a b 8 9 ; \n
0001500 c t x - > s t a t e [ 2 ]
0001520 = 0 x 9 8 b a d c f e ; \n
0001540 c t x - > s t a t e [ 3 ]
0001560 = 0 x 1 0 3 2 5 4 7 6 ; \n
0001600 c t x - > s t a t e [ 4 ]
0001620 = 0 x 0 c 3 d 2 e 1 f 0 ; \n
0001640 \n c t x - > c o u n t [
0001660 0 ] = 0 ; \n c t x -
0001700 > c o u n t [ 1 ] = 0 ; \n \n
0001720 } \n \n v o i d S H S U p d a t
0001740 e ( c t x , b y t e s , n
0001760 B y t e s ) \n S H S _
0002000 C T X * c t x ; \n u
0002020 n s i g n e d c h a r * b y
0002040 t e s ; \n u n s i g n
0002060 e d i n t n B y t e s ; \n {
0002100 \n u n s i g n e d i n
0002120 t i n B u f f e r = ( u n
0002140 s i g n e d i n t ) ( ( c t x
0002160 - > c o u n t [ 1 ] / 8 ) %
0002200 6 4 ) ; \n / *
0002220 n u m b e r o f b y t e s
0002240 l e f t i n b u f f e r f
0002260 r o m p r e v i o u s c a l
0002300 l * / \n \n
0002320 u n s i g n e d i n t i
0002340 n p = 0 ; \n \n i f
0002360 ( ( c t x - > c o u n t [ 1 ]
0002400 + = ( ( U I N T 4 ) n B y t e
0002420 s < < 3 ) ) < ( ( U I N
0002440 T 4 ) n B y t e s < < 3 ) )
0002460 \n c t x - >
0002500 c o u n t [ 0 ] + + ; \n
0002520 c t x - > c o u n t [ 0 ] + =
0002540 ( ( U I N T 4 ) n B y t e s
0002560 > > 2 9 ) ; \n \n i f
0002600 ( i n B u f f e r ! = 0 )
0002620 { \n i f ( ( i
0002640 n B u f f e r + n B y t e s )
0002660 > = 6 4 ) { \n
0002700 b c o p y ( b y t e
0002720 s , & c t x - > b u f f e r [
0002740 i n B u f f e r ] , i n p = (
0002760 6 4 - i n B u f f e r ) ) ; \n
0003000 o n e m
0003020 ( c t x - > b u f f e r , c
0003040 t x - > s t a t e ) ; \n
0003060 i n B u f f e
0003100 r = 0 ; \n } \n
0003120 } ; \n
0003140 \n \n w h i l
0003160 e ( i n p + 6 4 < = n B y
0003200 t e s ) { \n
0003220 o n e m ( b y t e s [ i n p ]
0003240 , c t x - > s t a t e ) ; \n
0003260 i n p + = 6
0003300 4 ; \n } ; \n
0003320 \n b c o p y
0003340 ( b y t e s + i n p , & ( c
0003360 t x - > b u f f e r [ i n B u f
0003400 f e r ] ) , n B y t e s - i n
0003420 p ) ; \n \n } \n \n \n s t
0003440 a t i c v o i d c h a r s F
0003460 r o m I n t ( p , i ) \n
0003500 u n s i g n e d c h a r
0003520 * p ; \n u n s i g n e d
0003540 i n t i ; \n { \n i n
0003560 t j ; \n f o r
0003600 ( j = 3 ; j > = 0 ;
0003620 j - - ) { \n p
0003640 [ j ] = i % 2 5 6 ; \n
0003660 i = i / 2
0003700 5 6 ; \n } \n } \n \n s t a
0003720 t i c v o i d i n t F r o m
0003740 C h a r s ( i , p ) \n
0003760 u n s i g n e d i n t * i
0004000 ; \n u n s i g n e d c
0004020 h a r * p ; \n { \n u n
0004040 s i g n e d i n t s u m =
0004060 0 ; \n u n s i g n e d
0004100 i n t j ; \n \n
0004120 f o r ( j = 0 ; j <
0004140 4 ; j + + ) { \n
0004160 s u m = ( s u m ) * 2 5
0004200 6 + p [ j ] ; \n } ;
0004220 \n * i = s u m ; \n }
0004240 \n \n v o i d S H S F i n a l
0004260 ( h a s h , c t x ) \n
0004300 u n s i g n e d c h a r
0004320 h a s h [ 2 0 ] ; \n S H
0004340 S _ C T X * c t x ; \n { \n
0004360 u n s i g n e d c h a r
0004400 c o u n t A s C h a r s [ 8 ] ;
0004420 \n u n s i g n e d i n
0004440 t i n B u f f e r ; \n
0004460 u n s i g n e d c h a r t
0004500 e r m i n a t o r = 0 x 8 0
0004520 ; \n \n /
0004540 * n u m b e r o f b y t e
0004560 s l e f t i n b u f f e r
0004600 f r o m p r e v i o u s c
0004620 a l l * / \n \n
0004640 c h a r s F r o m I n t
0004660 ( & ( c o u n t A s C h a r s [
0004700 0 ] ) , c t x - > c o u n t [
0004720 0 ] ) ; \n c h a r s F r
0004740 o m I n t ( & ( c o u n t A s C
0004760 h a r s [ 4 ] ) , c t x - > c
0005000 o u n t [ 1 ] ) ; \n S H
0005020 S U p d a t e ( c t x , & t
0005040 e r m i n a t o r , 1 ) ; \n
0005060 i n B u f f e r = (
0005100 u n s i g n e d i n t ) ( ( c
0005120 t x - > c o u n t [ 1 ] / 8 )
0005140 % 6 4 ) ; \n i f ( i
0005160 n B u f f e r > 6 4 - 8 )
0005200 { \n b z e r o ( &
0005220 ( c t x - > b u f f e r [ i n B
0005240 u f f e r ] ) , 6 4 - i n B u
0005260 f f e r ) ; \n o n
0005300 e m ( c t x - > b u f f e r ,
0005320 c t x - > s t a t e ) ; \n
0005340 i n B u f f e r =
0005360 0 ; \n } ; \n b
0005400 z e r o ( & ( c t x - > b u f f
0005420 e r [ i n B u f f e r ] ) , (
0005440 6 4 - 8 ) - i n B u f f e r ) ;
0005460 \n b c o p y ( c o u n t
0005500 A s C h a r s , & ( c t x - >
0005520 b u f f e r [ 6 4 - 8 ] ) , 8
0005540 ) ; \n o n e m ( c t x
0005560 - > b u f f e r , c t x - > s
0005600 t a t e ) ; \n \n { \n
0005620 u n s i g n e d
0005640 i n t i ; \n c
0005660 h a r * p ; \n
0005700 \n f o r ( ( i
0005720 = 0 , \n
0005740 p = ( c h a r * ) h a s h )
0005760 ; i < 5 ; ( i + + , p +
0006000 = 4 ) ) { \n
0006020 c h a r s F r o m I n t
0006040 ( p , c t x - > s t a t e [
0006060 i ] ) ; \n } \n
0006100 } \n } \n \n # d e f i n e
0006120 S 5 ( x ) ( ( ( x ) < < 5 )
0006140 | ( ( x ) > > 2 7 ) ) \n # d
0006160 e f i n e S 3 0 ( x ) ( ( (
0006200 x ) < < 3 0 ) | ( ( x ) > >
0006220 2 ) ) \n # d e f i n e K 0 0
0006240 x 5 a 8 2 7 9 9 9 \n # d e f i n
0006260 e K 1 0 x 6 e d 9 e b a 1 \n
0006300 # d e f i n e K 2 0 x 8 f 1
0006320 b b c d c \n # d e f i n e K 3
0006340 0 x 0 c a 6 2 c 1 d 6 \n # d e
0006360 f i n e A N D ( x , y ) ( (
0006400 x ) & ( y ) ) \n # d e f i n e
0006420 F 0 ( x , y , z ) ( A N D ( x
0006440 , y ) | A N D ( ~ ( x ) , z
0006460 ) ) \n # d e f i n e F 1 ( x ,
0006500 y , z ) ( ( x ) ^ ( y ) ^ ( z
0006520 ) ) \n # d e f i n e F 2 ( x ,
0006540 y , z ) ( A N D ( x , y ) |
0006560 A N D ( x , z ) | A N D (
0006600 y , z ) ) \n # d e f i n e w o
0006620 r d u n s i g n e d l o n g
0006640 \n \n \n s t a t i c v o i d o
0006660 n e m ( m , h ) \n w o r d m
0006700 [ 1 6 ] ; \n w o r d h [ 5 ] ;
0006720 \n { \n w o r d w [ 8 0
0006740 ] ; \n i n t t ; \n
0006760 w o r d A , B , C ,
0007000 D , E ; \n w o r d *
0007020 p , * q ; \n w o r d
0007040 * p m 3 , * p m 8 , * p m 1
0007060 4 , * p m 1 6 ; \n w o
0007100 r d t e m p ; \n i n t
0007120 i ; \n i f ( l i t t
0007140 l e E n d i a n ) \n
0007160 f o r ( i = 0 ; i <
0007200 1 6 ; i + + ) { \n
0007220 i n t F r o m C
0007240 h a r s ( & ( m [ i ] ) , & (
0007260 m [ i ] ) ) ; \n
0007300 } ; \n A = h [ 0 ]
0007320 ; B = h [ 1 ] ; C = h [ 2 ]
0007340 ; D = h [ 3 ] ; E = h [ 4 ]
0007360 ; \n f o r ( p = m
0007400 , q = w ; p < m + 1 6 ;
0007420 p + + , q + + ) { \n
0007440 * q = * p ; \n
0007460 } \n p m 3
0007500 = w + 1 3 ; p m 8 = w +
0007520 8 ; p m 1 4 = w + 2 ; p m 1
0007540 6 = w ; \n f o r ( p =
0007560 w + 1 6 ; p < w + 8 0 ;
0007600 p + + , p m 3 + + , p m 8 +
0007620 + , p m 1 4 + + , p m 1 6 +
0007640 + ) { \n * p
0007660 = * p m 3 ^ * p m 8 ^
0007700 * p m 1 4 ^ * p m 1 6 ; \n
0007720 } \n f o r
0007740 ( i = 0 ; i < 2 0 ; i + +
0007760 ) { \n t e m p
0010000 = S 5 ( A ) + F 0 ( B ,
0010020 C , D ) + E + w [ i ]
0010040 + K 0 ; \n E =
0010060 D ; D = C ; C = S 3 0 ( B )
0010100 ; B = A ; A = t e m p ; \n
0010120 } \n f o r
0010140 ( i = 2 0 ; i < 4 0 ; i +
0010160 + ) { \n t e m
0010200 p = S 5 ( A ) + F 1 ( B
0010220 , C , D ) + E + w [ i ]
0010240 + K 1 ; \n E
0010260 = D ; D = C ; C = S 3 0 ( B
0010300 ) ; B = A ; A = t e m p ; \n
0010320 } \n f o
0010340 r ( i = 4 0 ; i < 6 0 ; i
0010360 + + ) { \n t e
0010400 m p = S 5 ( A ) + F 2 (
0010420 B , C , D ) + E + w [ i
0010440 ] + K 2 ; \n
0010460 E = D ; D = C ; C = S 3 0 (
0010500 B ) ; B = A ; A = t e m p ;
0010520 \n } \n f
0010540 o r ( i = 6 0 ; i < 8 0 ;
0010560 i + + ) { \n t
0010600 e m p = S 5 ( A ) + F 1
0010620 ( B , C , D ) + E + w [
0010640 i ] + K 3 ; \n
0010660 E = D ; D = C ; C = S 3 0
0010700 ( B ) ; B = A ; A = t e m p
0010720 ; \n } \n
0010740 h [ 0 ] = h [ 0 ] + A ; \n
0010760 h [ 1 ] = h [ 1 ] + B ; \n
0011000 h [ 2 ] = h [ 2 ] + C ; \n
0011020 h [ 3 ] = h [ 3 ] + D ; \n
0011040 h [ 4 ] = h [ 4 ] + E ;
0011060 \n } \n
0011073