(self)
| 173 | |
| 174 | #----------------------------------------------------- |
| 175 | def digest(self): |
| 176 | |
| 177 | res = [0x00] * 16 |
| 178 | s = [0x00] * 8 |
| 179 | padding = [0x00] * 64 |
| 180 | padding[0] = 0x80 |
| 181 | padlen, oldlen1, oldlen2 = U32(0), U32(0), U32(0) |
| 182 | |
| 183 | temp = self.make_copy() |
| 184 | |
| 185 | oldlen1 = temp.len1 |
| 186 | oldlen2 = temp.len2 |
| 187 | if (56 <= int(self.count)): padlen = U32(56 - int(self.count) + 64) |
| 188 | else: padlen = U32(56 - int(self.count)) |
| 189 | |
| 190 | temp.update(bytes(padding[:int(padlen)])) |
| 191 | |
| 192 | s[0]= (oldlen1) & U32(0xFF) |
| 193 | s[1]=((oldlen1) >> 8) & U32(0xFF) |
| 194 | s[2]=((oldlen1) >> 16) & U32(0xFF) |
| 195 | s[3]=((oldlen1) >> 24) & U32(0xFF) |
| 196 | s[4]= (oldlen2) & U32(0xFF) |
| 197 | s[5]=((oldlen2) >> 8) & U32(0xFF) |
| 198 | s[6]=((oldlen2) >> 16) & U32(0xFF) |
| 199 | s[7]=((oldlen2) >> 24) & U32(0xFF) |
| 200 | temp.update(bytes(s)) |
| 201 | |
| 202 | res[ 0]= temp.A & U32(0xFF) |
| 203 | res[ 1]=(temp.A >> 8) & U32(0xFF) |
| 204 | res[ 2]=(temp.A >> 16) & U32(0xFF) |
| 205 | res[ 3]=(temp.A >> 24) & U32(0xFF) |
| 206 | res[ 4]= temp.B & U32(0xFF) |
| 207 | res[ 5]=(temp.B >> 8) & U32(0xFF) |
| 208 | res[ 6]=(temp.B >> 16) & U32(0xFF) |
| 209 | res[ 7]=(temp.B >> 24) & U32(0xFF) |
| 210 | res[ 8]= temp.C & U32(0xFF) |
| 211 | res[ 9]=(temp.C >> 8) & U32(0xFF) |
| 212 | res[10]=(temp.C >> 16) & U32(0xFF) |
| 213 | res[11]=(temp.C >> 24) & U32(0xFF) |
| 214 | res[12]= temp.D & U32(0xFF) |
| 215 | res[13]=(temp.D >> 8) & U32(0xFF) |
| 216 | res[14]=(temp.D >> 16) & U32(0xFF) |
| 217 | res[15]=(temp.D >> 24) & U32(0xFF) |
| 218 | |
| 219 | return bytes(res) |
| 220 | |
| 221 | #==================================================================== |
| 222 | # helpers |
no test coverage detected