| void __des_setkey(const unsigned char* key, struct expanded_key* ekey); |
| void __do_des(uint32_t l_in, |
| const struct expanded_key* ekey); |
| static struct expanded_key __encrypt_key; |
| void setkey(const char* key) { |
| for (i = 0; i < 8; i++) { |
| for (j = 7; j >= 0; j--, key++) |
| bkey[i] |= (uint32_t)(*key & 1) << j; |
| __des_setkey(bkey, &__encrypt_key); |
| void encrypt(char* block, int edflag) { |
| struct expanded_key decrypt_key, *key; |
| for (i = 0; i < 2; i++) { |
| for (j = 31; j >= 0; j--, p++) |
| b[i] |= (uint32_t)(*p & 1) << j; |
| for (i = 0; i < 16; i++) { |
| decrypt_key.l[i] = __encrypt_key.l[15 - i]; |
| decrypt_key.r[i] = __encrypt_key.r[15 - i]; |
| __do_des(b[0], b[1], b, b + 1, 1, 0, key); |
| for (j = 31; j >= 0; j--) |