File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -156,14 +156,33 @@ PyMethodDef whirlpool_methods[] = {
156156};
157157
158158
159+ static PyObject *
160+ whirlpool_get_block_size (PyObject * self , void * closure )
161+ {
162+ return PyInt_FromLong (WBLOCKBYTES );
163+ }
164+
165+ static PyObject *
166+ whirlpool_get_digest_size (PyObject * self , void * closure )
167+ {
168+ return PyInt_FromLong (DIGESTBYTES );
169+ }
170+
159171static PyObject *
160172whirlpool_get_name (PyObject * self , void * closure )
161173{
162174 return PyString_FromStringAndSize ("WHIRLPOOL" , 9 );
163175}
164176
165-
166177static PyGetSetDef whirlpool_getseters [] = {
178+ {"digest_size" ,
179+ (getter )whirlpool_get_digest_size , NULL ,
180+ NULL ,
181+ NULL },
182+ {"block_size" ,
183+ (getter )whirlpool_get_block_size , NULL ,
184+ NULL ,
185+ NULL },
167186 {"name" ,
168187 (getter )whirlpool_get_name , NULL ,
169188 NULL ,
Original file line number Diff line number Diff line change @@ -77,6 +77,20 @@ def test_update_copy(self):
7777 self .assertEqual (b2a_hex (wp3 .digest ()), results ['tqbfjotle' ])
7878 self .assertEqual (wp3 .hexdigest (), results ['tqbfjotle' ])
7979
80+ def test_digest_size (self ):
81+ wp = whirlpool .new ()
82+ self .assertEqual (wp .digest_size , 64 )
83+ with self .assertRaisesRegexp (AttributeError ,
84+ 'digest_size.*not writable' ):
85+ wp .digest_size = 32
86+
87+ def test_block_size (self ):
88+ wp = whirlpool .new ()
89+ self .assertEqual (wp .block_size , 64 )
90+ with self .assertRaisesRegexp (AttributeError ,
91+ 'block_size.*not writable' ):
92+ wp .block_size = 32
93+
8094
8195if __name__ == '__main__' :
8296 unittest .main ()
You can’t perform that action at this time.
0 commit comments