MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / des_setkey

Function des_setkey

src/common/enc.cpp:613–636  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

611// Set up the key schedule from the key.
612
613static int des_setkey(unsigned char* key)
614{
615 DCL_BLOCK(K, K0, K1);
616 static bool des_ready = false;
617
618 if (!des_ready)
619 {
620 init_des();
621 des_ready = true;
622 }
623
624 PERM6464(K, K0, K1, key, (const C_block*) PC1ROT);
625 key = (unsigned char *) &KS[0];
626 STORE(K & ~0x03030303L, K0 & ~0x03030303L, K1, *(C_block *) key);
627 for (int i = 1; i < 16; i++)
628 {
629 key += sizeof(C_block);
630 STORE(K, K0, K1, *(C_block *) key);
631 const C_block* ptabp = (const C_block*) PC2ROT[Rotates[i] - 1];
632 PERM6464(K, K0, K1, key, ptabp);
633 STORE(K & ~0x03030303L, K0 & ~0x03030303L, K1, *(C_block *) key);
634 }
635 return (0);
636}
637
638/*
639 * Encrypt (or decrypt if num_iter < 0) the 8 chars at "in" with abs(num_iter)

Callers 1

ENC_cryptFunction · 0.85

Calls 1

init_desFunction · 0.85

Tested by

no test coverage detected