MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ng_mppc_getkey

Function ng_mppc_getkey

freebsd/netgraph/ng_mppc.c:862–885  ·  view source on GitHub ↗

* Generate a new encryption key */

Source from the content-addressed store, hash-verified

860 * Generate a new encryption key
861 */
862static void
863ng_mppc_getkey(const u_char *h, u_char *h2, int len)
864{
865 static const u_char pad1[40] =
866 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
867 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
868 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
869 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
870 static const u_char pad2[40] =
871 { 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2,
872 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2,
873 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2,
874 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2 };
875 u_char hash[20];
876 SHA1_CTX c;
877
878 SHA1Init(&c);
879 SHA1Update(&c, h, len);
880 SHA1Update(&c, pad1, sizeof(pad1));
881 SHA1Update(&c, h2, len);
882 SHA1Update(&c, pad2, sizeof(pad2));
883 SHA1Final(hash, &c);
884 bcopy(hash, h2, len);
885}
886
887/*
888 * Update the encryption key

Callers 2

ng_mppc_rcvmsgFunction · 0.85
ng_mppc_updatekeyFunction · 0.85

Calls 3

SHA1InitFunction · 0.50
SHA1UpdateFunction · 0.50
SHA1FinalFunction · 0.50

Tested by

no test coverage detected