Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\crypto\des.c Create Date:2022-07-28 06:47:22
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Decryption key expansion* No weak key checking is performed, as this is only used by triple DES

Proto:static void dkey(u32 *pe, const u8 *k)

Type:void

Parameter:

TypeParameterName
u32 *pe
const u8 *k
718  pt = pc2
720  d = k[4]
720  d &= 0x0e
720  d <<= 4
720  d |= k[0] & 0x1e
720  d = Lookup tables for key expansion [d]
721  c = k[5]
721  c &= 0x0e
721  c <<= 4
721  c |= k[1] & 0x1e
721  c = Lookup tables for key expansion [c]
722  b = k[6]
722  b &= 0x0e
722  b <<= 4
722  b |= k[2] & 0x1e
722  b = Lookup tables for key expansion [b]
723  a = k[7]
723  a &= 0x0e
723  a <<= 4
723  a |= k[3] & 0x1e
723  a = Lookup tables for key expansion [a]
725  pe[0 * 2] = DES_PC2(a, b, c, d)
725  d = rs[d]
726  pe[1 * 2] = DES_PC2(d, a, b, c)
726  c = rs[c]
726  b = rs[b]
727  pe[2 * 2] = DES_PC2(b, c, d, a)
727  a = rs[a]
727  d = rs[d]
728  pe[3 * 2] = DES_PC2(d, a, b, c)
728  c = rs[c]
728  b = rs[b]
729  pe[4 * 2] = DES_PC2(b, c, d, a)
729  a = rs[a]
729  d = rs[d]
730  pe[5 * 2] = DES_PC2(d, a, b, c)
730  c = rs[c]
730  b = rs[b]
731  pe[6 * 2] = DES_PC2(b, c, d, a)
731  a = rs[a]
731  d = rs[d]
732  pe[7 * 2] = DES_PC2(d, a, b, c)
732  c = rs[c]
733  pe[8 * 2] = DES_PC2(c, d, a, b)
733  b = rs[b]
733  a = rs[a]
734  pe[9 * 2] = DES_PC2(a, b, c, d)
734  d = rs[d]
734  c = rs[c]
735  pe[10 * 2] = DES_PC2(c, d, a, b)
735  b = rs[b]
735  a = rs[a]
736  pe[11 * 2] = DES_PC2(a, b, c, d)
736  d = rs[d]
736  c = rs[c]
737  pe[12 * 2] = DES_PC2(c, d, a, b)
737  b = rs[b]
737  a = rs[a]
738  pe[13 * 2] = DES_PC2(a, b, c, d)
738  d = rs[d]
738  c = rs[c]
739  pe[14 * 2] = DES_PC2(c, d, a, b)
739  b = rs[b]
740  pe[15 * 2] = DES_PC2(b, c, d, a)
743  pt += 512
745  d = k[0]
745  d &= 0xe0
745  d >>= 4
745  d |= k[4] & 0xf0
745  d = Lookup tables for key expansion [d + 1]
746  c = k[1]
746  c &= 0xe0
746  c >>= 4
746  c |= k[5] & 0xf0
746  c = Lookup tables for key expansion [c + 1]
747  b = k[2]
747  b &= 0xe0
747  b >>= 4
747  b |= k[6] & 0xf0
747  b = Lookup tables for key expansion [b + 1]
748  a = k[3]
748  a &= 0xe0
748  a >>= 4
748  a |= k[7] & 0xf0
748  a = Lookup tables for key expansion [a + 1]
750  pe[0 * 2 + 1] = DES_PC2(a, b, c, d)
750  d = rs[d]
751  pe[1 * 2 + 1] = DES_PC2(d, a, b, c)
751  c = rs[c]
751  b = rs[b]
752  pe[2 * 2 + 1] = DES_PC2(b, c, d, a)
752  a = rs[a]
752  d = rs[d]
753  pe[3 * 2 + 1] = DES_PC2(d, a, b, c)
753  c = rs[c]
753  b = rs[b]
754  pe[4 * 2 + 1] = DES_PC2(b, c, d, a)
754  a = rs[a]
754  d = rs[d]
755  pe[5 * 2 + 1] = DES_PC2(d, a, b, c)
755  c = rs[c]
755  b = rs[b]
756  pe[6 * 2 + 1] = DES_PC2(b, c, d, a)
756  a = rs[a]
756  d = rs[d]
757  pe[7 * 2 + 1] = DES_PC2(d, a, b, c)
757  c = rs[c]
758  pe[8 * 2 + 1] = DES_PC2(c, d, a, b)
758  b = rs[b]
758  a = rs[a]
759  pe[9 * 2 + 1] = DES_PC2(a, b, c, d)
759  d = rs[d]
759  c = rs[c]
760  pe[10 * 2 + 1] = DES_PC2(c, d, a, b)
760  b = rs[b]
760  a = rs[a]
761  pe[11 * 2 + 1] = DES_PC2(a, b, c, d)
761  d = rs[d]
761  c = rs[c]
762  pe[12 * 2 + 1] = DES_PC2(c, d, a, b)
762  b = rs[b]
762  a = rs[a]
763  pe[13 * 2 + 1] = DES_PC2(a, b, c, d)
763  d = rs[d]
763  c = rs[c]
764  pe[14 * 2 + 1] = DES_PC2(c, d, a, b)
764  b = rs[b]
765  pe[15 * 2 + 1] = DES_PC2(b, c, d, a)
768  When d < 16 cycle
769  a = pe[2 * d]
770  b = pe[2 * d + 1]
771  c = a ^ b
772  c &= 0xffff0000
773  a ^= c
774  b ^= c
775  ROL(b, 18)
776  pe[2 * d] = a
777  pe[2 * d + 1] = b
Caller
NameDescribe
des3_ede_expand_key