SHARE
TWEET

Python HDCP Key Generator

a guest Sep 14th, 2010 2,400 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """
  2. hdcp.py
  3.  
  4. Generates HDCP keys (sink and source)
  5.  
  6. Based on the anonymous post of the HDCP master key
  7. posted here: http://pastebin.com/kqD56TmU
  8.  
  9. Relevant instructions included in post:
  10.  This is a forty times forty element matrix of fifty-six bit
  11.  hexadecimal numbers.
  12.  
  13.  To generate a source key, take a forty-bit number that (in
  14.  binary) consists of twenty ones and twenty zeroes; this is
  15.  the source KSV.  Add together those twenty rows of the matrix
  16.  that correspond to the ones in the KSV (with the lowest bit
  17.  in the KSV corresponding to the first row), taking all elements
  18.  modulo two to the power of fifty-six; this is the source
  19.  private key.
  20.    
  21.  To generate a sink key, do the same, but with the transposed
  22.  matrix.
  23. """
  24. import random
  25.  
  26. # Matrix (used for source keys)
  27. m = [["6692d179032205", "b4116a96425a7f", "ecc2ef51af1740", "959d3b6d07bce4", "fa9f2af29814d9", "82592e77a204a8", "146a6970e3c4a1", "f43a81dc36eff7", "568b44f60c79f5", "bb606d7fe87dd6", "1b91b9b73c68f9", "f31c6aeef81de6", "9a9cc14469a037", "a480bc978970a6", "997f729d0a1a39", "b3b9accda43860", "f9d45a5bf64a1d", "180a1013ba5023", "42b73df2d33112", "851f2c4d21b05e", "2901308bbd685c", "9fde452d3328f5", "4cc518f97414a8", "8fca1f7e2a0a14", "dc8bdbb12e2378", "672f11cedf36c5", "f45a2a00da1c1d", "5a3e82c124129a", "084a707eadd972", "cb45c81b64808d", "07ebd2779e3e71", "9663e2beeee6e5", "25078568d83de8", "28027d5c0c4e65", "ec3f0fc32c7e63", "1d6b501ae0f003", "f5a8fcecb28092", "854349337aa99e", "9c669367e08bf1", "d9c23474e09f70"],
  28. ["3c901d46bada9a", "40981ffcfa376f", "a4b686ca8fb039", "63f2ce16b91863", "1bade89cc52ca2", "4552921af8efd2", "fe8ac96a02a6f9", "9248b8894b23bd", "17535dbff93d56", "94bdc32a095df2", "cd247c6d30286e", "d2212f9d8ce80a", "dc55bdc2a6962c", "bcabf9b5fcbe6f", "c2cfc78f5fdafa", "80e32223b9feab", "f1fa23f5b0bf0d", "ab6bf4b5b698ae", "d960315753d36f", "424701e5a944ed", "10f61245ebe788", "f57a17fc53a314", "00e22e88911d9e", "76575e18c7956e", "c1ef4eee022e38", "f5459f177591d9", "08748f861098ef", "287d2c63bd809e", "e6a28a6f5d000c", "7ae5964a663c1b", "0f15f7167f56c6", "d6c05b2bbe8800", "544a49be026410", "d9f3f08602517f", "74878dc02827f7", "d72ef3ea24b7c8", "717c7afc0b55a5", "0be2a582516d08", "202ded173a5428", "9b71e35e45943f"],
  29. ["9e7cd2c8789c99", "1b590a91f1cffd", "903dca7c36d298", "52ad58ddcc1861", "56dd3acba0d9c5", "c76254c1be9ed1", "06ecb6ae8ff373", "cfcc1afcbc80a4", "30eba7ac19308c", "d6e20ae760c986", "c0d1e59db1075f", "8933d5d8284b92", "9280d9a3faa716", "8386984f92bfd6", "be56cd7c4bfa59", "16593d2aa598a6", "d62534326a40ee", "0c1f1919936667", "acbaf0eefdd395", "36dbfdbf9e1439", "0bd7c7e683d280", "54759e16cfd9ea", "cac9029104bd51", "436d1dca1371d3", "ca2f808654cdb2", "7d6923e47f97b5", "70e256b741910c", "7dd466ed5fff2e", "26bec4a28e8cc4", "5754ea7219d4eb", "75270aa4d3cc8d", "e0ae1d1897b7f4", "4fe5663e8cb342", "05a80e4a1a950d", "66b4eb6ed4c99e", "3d7e9d469c6165", "81677af04a2e15", "ada4be60bc348d", "dfdfbbad739248", "98ad5986f3ca1f"],
  30. ["971d02ada31b46", "2adab96f7b15da", "9855f01b9b7b94", "6cef0f65663fbf", "eb328e8a3c6c5d", "e29f0f0b1ef2bf", "e4a30b29047d31", "52250e7ae3a4ac", "fe3efc3b8c2df1", "8c997d15d6078b", "49da8b4611ff9f", "b1e061bc9be995", "31fd68c4ad6dc6", "fd8974f0c506dd", "90421c1cd2b26c", "53eec84c91ed17", "5159ba3711173b", "25e318ddceea6a", "98a14125755955", "2bb97fd341cea2", "3f8404769a0a8e", "bce5c7a45fb5d4", "9608307b43f785", "2a98e5856afe75", "b4dbead4815cac", "d1118af62c964a", "3142667a5b0d14", "6c6f90933acd3d", "6b14a0052e2be4", "1b1811fda0f554", "12300aa7f10405", "1919ca0bff56ea", "d3e2f3aad5250c", "4aeeea5101d2ec", "377fc499c07057", "6cb1a90cdb7b11", "3c839d47a4b814", "25c5ac14b5ec28", "4ef18646d5b9c2", "95a98cc51ebd3b"],
  31. ["310e98028e24de", "092ffc76b79f44", "0740a1ca2d4737", "b9f38966257c99", "a75afc7454abe4", "a6dd815be8ccbf", "ec2cac2df0c675", "41f7636aa4080f", "30e87b712520fd", "d5dfdc6d3266ac", "ee28f5479f836f", "0bf8ee2112173f", "43ae802fa8d52d", "4e0dffd36c1eac", "3cbda974bb7585", "fb60a4700470e3", "d9f6b6083ef13d", "4a5840f02d0130", "6c20ef5e35e2bf", "dad2f85c745b5b", "61c5ddc65d3fc9", "7f6ec395d4ae22", "2b8906fb3996e2", "e4110f59eb92ac", "1cb212b44128bb", "545afda80a4fd1", "b1ffea547eab6b", "fac3d9166afce8", "3fe35fe17586f2", "9d082667026a4c", "17ffaf1cb50145", "24f27b316acfff", "b6bb758ec4ad60", "995e8726359ef7", "c44952cb424035", "5ec53461dbd248", "40a1586f04aee7", "49ea3fa4474e52", "c13e8f52c51562", "30a1a70162cfb8"],
  32. ["ccbada27b91c33", "33661064d05759", "3388bb6315b036", "0380a6b43851fb", "0228dadb44ad3d", "b732565bc37841", "993c0d383cfaae", "0bea49476758ac", "accc69dbfcde8b", "f416ab0474f022", "2b7dbcc3002502", "20dc4e67289e50", "0068424fde9515", "64806d59eb0c18", "9cf08fb2abc362", "8d0ee78a6cace9", "b6781bd504d105", "af65fab8ee6252", "64a8f8dd8e2d14", "cb9d3354e06b5b", "53082840d3c011", "8e080bedab3c4c", "e30d722a455843", "24955a20397c17", "82495c1c5114e8", "656e71c31d813d", "1f0a6d291823a1", "6327f9534353fa", "b89529c2f034fb", "70e9b12205c7b3", "a06c87969407a2", "520bfa2fe80f90", "da1efc3d345c65", "313936ec023811", "a8cc87128be2fa", "4cd0e8645ee141", "be7975519e2b63", "9543d23113c2a8", "3d87b0da033f22", "df0464c704e9d4"],
  33. ["7e1a30947e867e", "014ae464b37935", "5c4babf689fa4e", "c4aec0cb01cc35", "328c0e4a0230e4", "fdacb93b419594", "26deefc8a553e6", "6e75a2d790cb55", "2c4554518f7396", "94b77184cb145d", "95f883f620a8bb", "edff42866a2783", "7b4ee6304b711d", "ed56e077a4b9fb", "c4e60e687ff6c3", "0cbf144b8f64d5", "023dd10a35eddd", "beaa3323e999c6", "d2e016b31c38c4", "8d2917a888f799", "18c3abd28e736b", "8d38e69b4966cc", "624db0143dd2e7", "5e2fa510f632b7", "ee6e64d45b139a", "a1c6d852e74be7", "429843b9e6bb7e", "db9ab07c8dc267", "9efa092299f071", "dcca9e0e61e960", "94406fac95f1d8", "d19122f3f88782", "1b11a662e9c83f", "d161fd6fb7f032", "89f7d984da9d48", "a3583fea45fe58", "885e2c4839e254", "47e87235f713b1", "f4732e05b71aee", "ae026d063f4349"],
  34. ["0a481d2db197af", "abfce1039d4ac0", "4a6b89d2d1aeac", "0842eb7178cc53", "b82ce2835f1937", "3b4002ca21d6b6", "e64a78a78abb27", "8bd6142ad04526", "e035dacb23624a", "4cf80110135771", "7a52fafc92745e", "efa28a290ea782", "735617cd8b0221", "b095e9f4b286a5", "021e9ba0727645", "3e58e9ec16ed1c", "d7732bb5ba99a6", "374bde43fa89a9", "cb83e5ef2e4d04", "1da4f73566d134", "e01da194625c25", "d62018764d7473", "64643721313d24", "5a01badd970941", "481c9578781414", "a4d3faa92d1fef", "bd4b247d37862a", "5332a7ca3c2ca6", "393ee51989d5a9", "01a6e564040d37", "390c472ee27892", "f0217fe009e9b4", "5d3f04da415b35", "612ecd5b8e4eac", "757e27d2169f2d", "92853b737b7526", "9ac837c86476df", "e956c2b45ebd5e", "d4fa6da687ac39", "60f4343669ddd3"],
  35. ["64b8d778e72e78", "f86cd55efe92b8", "a9adbf2e728440", "966c8282cee1f9", "ea195972b883f4", "46ac03b37e7f24", "744df253954ae5", "22e3f9a0adbc58", "6add7c7d8a2961", "ba963e4912d17c", "2840ac28fcfad9", "8d8ec3ad6dfc32", "a3c788dd094910", "e65ebb61dabb5f", "b50e906b28c881", "003b11eb83e6a9", "a2fac0595b138d", "3d55a28f915330", "c343bd1849a085", "54c786629d2b42", "1d465cb22ccbc2", "d8f87fd52aded1", "ecb34f46656b71", "b4cbe50f839f2c", "2df6a553cc3698", "40b2dd25f26d51", "492f3c5c6fa566", "f80dd453864548", "d4be786d8735d9", "e364511a0fb62d", "3c2df64d6d1c9f", "f640e4ef4186be", "41773025d6ff57", "6147e75d7df3f5", "49809548639d16", "01067ef6034247", "4e7c1b20deb154", "3f8172a6b98ea0", "b0691d4b575801", "136a88607a3e5b"],
  36. ["0180058ca8742e", "972bc2ca1c4cb6", "7b05bbc57e63df", "5f01049697eaa2", "c537f3121384dc", "edb1fa0b34f132", "689b1374cafe25", "802d7bca5c6674", "f8e01e75e9eb3d", "a59c2d9126d85d", "f10f603f8c4fd9", "d5a358aa84b2d5", "f8320f2a3bd078", "019bcf0dabb5c3", "43dd8dd5e173f0", "45169f788a0233", "d62daee0e9839c", "7d673cf77a53d2", "008730faf272d0", "3c08080778ae8d", "920e40fad87d7e", "bf118230ffb194", "692baf40b951b4", "83549affe4e382", "68e172f86a40b3", "aa5e2c1b74636d", "c3d7809ac68aae", "33c344fd9bcc33", "6e6057dc7d71f0", "bceef547db57fa", "ec91cc1056e4b5", "8153f00c8ef4f8", "a2ca943ab03915", "079a070121782d", "d592dcec23dd3f", "44ba5fe5078279", "e6f8ed790ffa59", "e7877e834b4391", "d1ca3db32bccd7", "b382e35bff1ba1"],
  37. ["96cb3b9ef8671e", "70342fff9216a5", "d635530148dcc6", "bf40909f72ba4b", "e3697761ac11f1", "f2a77a5f435c5c", "a57729bb9aaf37", "14f78a30f9bf6f", "1a7fe7f0271b01", "0b224bc83ef07b", "0d409ce2157473", "adefa793287d48", "a6b13ce8e00a7f", "74d735fd54a00b", "e2dc16285d1b5a", "8b3d55371ce703", "bb3909153586b6", "03c8c622aa53e9", "89ee3322e069aa", "325ce41fbd0175", "2cd1326421cd83", "3c47eed2daadda", "87c2177de0c63f", "39b496d688c971", "179359349f5e0e", "3cfa9ea9345dbc", "47b1948cbfe45f", "2a13b18cf3a0d1", "00b03fc13e6cde", "656ef26757f5d1", "7c584630c27fb2", "02f2e14ca8a67e", "fcfec527978154", "4ec09910379625", "e90fc0a898a5b7", "5beb0f3ee5d03a", "2383832708cfb7", "6905747e27453e", "1714e418f0f0a3", "53bcdef0965e8d"],
  38. ["2c9b5813b90c3c", "bb9a20c8ebb80e", "045e04f3d57918", "6fe6ffb0718731", "201760abf11c27", "e289872adda7e1", "233e7ef2b2c83b", "423b4c0ba711db", "334b15e5bd4c01", "034d1e41bff0e8", "58a436cce28ea3", "e6ef4d94b49962", "ec8728db63716b", "8c8ffc95c21b06", "0beb50502d9acb", "c1eb732268091a", "e45e0c30cfed36", "31d58c384bc3e4", "8a26ae8b7a5c60", "83991e11e8a21e", "e4f193c0183e07", "691fbbf9ccb4c2", "4e5214fae905d8", "2052c969e9699d", "f6cea5a6157de3", "fd84477a6bad8e", "04f37758724bc3", "a491d0fd8f084e", "19933cec5f51f0", "93794e76e1f29b", "ebd1f1c057b30c", "7ec220fa6d31d9", "867d711c9a7674", "a700cf5f177e37", "cf3fae5da3ddc4", "4e8030990c7917", "553a5ce2abaaa4", "c2296c42e2dcea", "19ae4f9b654581", "66d5fff1163703"],
  39. ["bb5085e0e7d595", "12605df8a35f9f", "35c6d572c28ea5", "5099437e5f5595", "fb45cdaa8872f1", "6e012db5feedc3", "1ba0e5515be76f", "b793b687fbf1dd", "9d2c01063d4ca1", "c2e6fde5bc3a1c", "c17b11e1a33418", "436fcacef170c5", "e4c3cbc3066618", "2063665d2a1b84", "a8b5b4f2e58850", "ce74bcbc892d71", "b312d96806cdc8", "82d9c95678fff1", "5d8a0120206c3c", "621f13db39bd6e", "4a5db4815f181d", "8dae6e596cebd5", "1b8b1681dd4918", "1dbcbd79f8e5ff", "135064b0968c4e", "d81e91507c1e96", "ce08e072644e54", "e1648d32befadc", "d0b7f41fca118d", "7b9291b680b18a", "10ab9a2fb4f9a0", "9f462d2370dd03", "bb453f4b48b2ea", "b3c3e6d63c2559", "be4aa3d8e8f129", "90af78e01d25c9", "2e06a8715063da", "988dbf792de669", "17eabe5b043c41", "b1f700946e4ad2"],
  40. ["e329ae8a66581e", "4a5bda0ff2a313", "79577080aaac8c", "0dd34f4f929df3", "0f5e87f82b9b1f", "1ead67333c42d5", "ebac8fb8797375", "dc26965e625abb", "953ce074d8c84c", "2edd54991b2104", "a45196065c2bca", "98f56533f328bf", "8560a1a390e921", "37d2506aff3d7b", "f88576a47d273e", "562b7c9592ffdc", "2d0ff0ba59787b", "4dd89971bd39a6", "7a4a778d69a4cc", "58bad18bf5fc74", "5cac8d53dcc72c", "ba7e9c7a2b57d7", "ff544acc98f08f", "1d22f503712081", "cf868290f04def", "ba48ab7c61a8ab", "3ca439f055f713", "2401e3a43338e0", "b7c4b19cf1edc8", "37db6b0d8991a7", "10ede95c9c35e6", "a8f021fc870126", "6e5909a7f3217b", "33772e647266ff", "a5c8fd0c786e0f", "04f0bb34025c67", "cc33c6a49bf101", "45c563f33f807d", "6e95e9c2b5e349", "3a0e55d42d44b7"],
  41. ["611138d0e928dd", "24d7958e8e6149", "c66faf12b50f45", "eaa5eb19337961", "e68c81cb35d5d3", "ed1fe1f1b8d443", "612ca593de8afe", "6c15ee22ffb8b0", "c27152ca5a1e77", "0133b8165e3ed1", "608c9c1a6ca4aa", "df5272bd1b6425", "6f7efc5b2bbfa0", "b49b5f0c67ee30", "f4ef0e7ed820cb", "4b14d077b672ce", "3a60f2386c0218", "9e8d6e5f6caddf", "a53ccecbae8684", "d3183beeba0cef", "4cd21e6afc08e8", "5db41995d15a93", "6afe570246af77", "d0994bc305b27f", "2de99a0885c909", "1629a47aaa161f", "0f6b6d45ff8967", "cfc4e83f5b469c", "cc22586cab3936", "29e6b3f94d122e", "83f00e419d8980", "bb282b6f3efdef", "30d80463fb25e0", "1846f8f1b935d3", "3c03ed5243b7b4", "cb6b0e6e4c770f", "8bc2856390163a", "73a332bc2ebabd", "b3aeafedbc8c08", "74ff7726398cd4"],
  42. ["0071d5d3644b97", "45dd1ae0369e9a", "c1f518cd384512", "b933bc25cb3402", "9377c50007d647", "e609eb009c9245", "7d99fff828ba6e", "9f0adcca6cd0a9", "5c5cf8366b699f", "f00f513ad9e29d", "7c2ecfdb5afe40", "1f131691f0677b", "30e1df0cce8710", "f3c52df030e941", "b2bb6b650cf2d7", "012a5a2d11f1b4", "4699b78e898918", "977b2e06972b36", "674e2619e6be97", "93007948f99eee", "af2b5b80b81bb3", "417446ac93bc16", "14fb20c6ab0e24", "3ffc77d1672771", "36580afea2edec", "48942ed95911c5", "fa312a7aca8f83", "992e36a47ef1db", "3937ff39b1a9b5", "2af79ef5c48c64", "6c88d58111a0b7", "b6fa6dc5f7c8dc", "b1acc64f2b083d", "332baac65b4feb", "e58dae530ad4af", "0fbdb072d0ba36", "e2607b065b6fe4", "f803ae22cb2a6c", "9b639dd91166cc", "f5e430b9cece8c"],
  43. ["687c1dc2ac5898", "b429122b168f1c", "4248f91ae51605", "1c24d7f1578ba6", "1dec5a6c003598", "e3c04b01a812a7", "2df7909352cece", "de31efaffdd0d4", "e4a7f11873ec87", "4768f7b8d77583", "23b6f7bae4521f", "8fbf571e568d5a", "577ad8b71f3721", "718b68ac1ada36", "e10689cc83ea91", "43f73798b295f7", "6e2b078c8d68e5", "613c3bb265ca36", "d25d07032b8c80", "843fe3783b5959", "e918f7789f0d33", "afac1cb1534684", "0fb3c6c442a94b", "167f58645b56c2", "76132472470129", "590ae9be533d39", "75adfeba5e6230", "30dea290d933d7", "08cc4d30a4af39", "09bc69be193a2f", "f7f8ff9f03af3b", "3ad1a453e9dde4", "a534709b6e15c7", "c6ce7d4efd42e9", "5e947977595b68", "ca674d0c7541e9", "97f178a43b6057", "137a6483c7653a", "49f1eec3082cc7", "70824eb5bebf04"],
  44. ["cf95519563f7c7", "cef140efdaa431", "4f8ddc5fb70009", "27710736a485cd", "41b05dfead9e7a", "dcbf8e83a3a89a", "23e46b5a421a08", "84f0fb922099a4", "120b226eedd549", "cf4706582b36f4", "e3b718cabb9c11", "03db1daab9520a", "3a29a8c65c45f6", "0219e82dbeb36b", "b351c498a8dda8", "0ba2a5607f3bf6", "0b95be14721f63", "62d3b4d2b1fc16", "f46a95de23a55e", "b70c2f136e83eb", "a0b215f5837e73", "d76368870bd5bc", "0372cf15e7ff03", "c992d958598014", "1fb03e9712f2c4", "a73b9107699fb2", "239ad1d706b5f3", "3623dab66fefc1", "8b5e04ac40e7ed", "77eaadd7c4d35c", "b3ba11dde839a2", "621e7ab334235d", "29f2ed9f1990d9", "e0d731952272a4", "d31f58d8cfad64", "57690ff74579fe", "e78fb0fe43c6cf", "b127e3c5c7da88", "1765c8883fcd01", "dc0028f618172d"],
  45. ["07d8f79c0e5b79", "bdff41e18ee3b3", "0990bd1c710888", "b0ef52eb6da5bd", "b790ff7419e17d", "22ab4221d42b9a", "35bec4ded01a53", "6a2f35fd63b686", "db66f3c21b9291", "165a5fd321d034", "f2ea034bd3a6b6", "4d47388e2680b7", "018dd250cfd53b", "53babaed27080a", "73c54d98e4a365", "6a77f2e71cfab6", "4f9539f7e67a64", "c35beaa6ab5528", "1698a8ee44d10d", "01e623ff7096e8", "96a68072d59c56", "6baba4b0d232ee", "725a1f9e0fbeb1", "97728ef73b9a8e", "16ecfe23a3bdb6", "f035aac743b427", "202c094281f68b", "1c8be9e39e4591", "0959fad0920ae6", "15a97f475dc632", "a3fc9e9363688a", "89cea147f0339b", "d1ffe6e68570d2", "329a0b16c32fa2", "cbd5818383dd8f", "c26f57abe7c8cd", "4d680e55e8a77d", "feefbd47b284a3", "41bc9077e7df69", "1c32ea11a0df3c"],
  46. ["2ea8501eab0c69", "63dff30ea51c9f", "8de69a045d957b", "4036f90d8e90b7", "5886f2e5059e5d", "7341e707011eca", "8d6006677dabf1", "2c6f2040741941", "5058a43d3958d2", "29eee2b01178b8", "eb9e382e6ea2e5", "62e44ce8f6b19e", "a5b4444f78d77d", "c12755f1de34c7", "8fd001eb8d0d91", "8a3ece83c541b5", "659f736aca9076", "1c1864cc5b30f1", "1b9f901459a142", "f5571fc19f94a3", "39e842e17176ca", "ed2a1659a97f8e", "625e74d131b3da", "bdbdfeaa0366bd", "95ebf86c33a687", "4a09faea206cd1", "29f59174377238", "908e6c956350cb", "686a225a26548c", "a45140d1ed5b76", "75e9ea2087732c", "14dd568be007bf", "3668e3791bdd4b", "56f9aa39df5785", "e7b37c964271c9", "c5211e837c726e", "374513cd4cd34f", "a5c71ff1a4195e", "4e234c5adc13b4", "75093fc66c8faf"],
  47. ["2ec02dd6ea2715", "d8676bb21e7f0b", "b4c22ceadbd907", "9ccaf78857ea36", "a28da605bbf2d8", "723651fb07c86a", "07039b49d2fa32", "40dbb6dc2ef93d", "da48f7e9d5eb92", "45bc6190b3a9e4", "fc84b55352b994", "25f44b36a3fb83", "d09a8f4ab7d78e", "0829201a523b21", "966e0098395656", "5984c4e317d930", "581dd2ab677c99", "a92a70424c5aae", "4ea1dbaca67de1", "e45918a0d6d560", "1e5c75efdd907f", "99a6e56cbb015f", "04fd11c8ae4d05", "83a72f3e967bb6", "2ddf23b892d1e5", "d648bbe9e5f8d3", "d4b128d667ff6a", "781dcd435b03f4", "1a1cb99fc298e1", "69d80c51941a26", "5263476c788bb7", "db0b584b59ec8d", "d95a4e9a6a95c5", "5263b0eb0cc8d4", "98e62e5116ab09", "97564c79d4b733", "39d708c3284fb2", "d2cd596efe674a", "a9e3b1f33b4473", "70b30aa67c0c2c"],
  48. ["3532c9874c8ce5", "680a796f9db4b3", "64e5825663090f", "eb0a67604f3f9b", "7c4716c88afa20", "cecf4b6b1467f8", "342600406fe556", "200290eea56903", "36562b6cff764c", "b02d3847d68f8f", "a26c2ab20fe063", "5de36be096db8d", "ac5998b94e3c17", "4c8808ebb9bf53", "4bbf0a436470da", "d3875253f7b0a9", "a99369bfede348", "8c3391fd3a5f95", "5005f88c89d735", "acd8196d21d41b", "5ba2ce34f48817", "da3e7f4332994f", "8cfe88c8ae18af", "e4df8b64d16e61", "b0f200ab8229f9", "5a15b4ad681a60", "350a1bb85a5708", "f5731809fe17da", "9da29858778783", "e496533ffbda6c", "a590c76b953dff", "edbf61ba227191", "f7fd713fd0b4bf", "4a5e6df9905845", "42ed273f1fee88", "e56d34cbb2866d", "cc76209f9773ec", "4c21238f991ec6", "7adff263cb22b1", "4fb41d94f97f42"],
  49. ["f26d90e0b24a1a", "37fe90421cee92", "5cd69e29e95550", "bec2bff0431bc0", "6acc812fa97ad4", "4f19e44dd33a0e", "d9280b1ae70cff", "6575a036db7f1e", "7bf2ed31bcef8e", "45dfb49b8dc51d", "e1fd10fb1b59b8", "092da05f342c0a", "01fa56a0375319", "c1f5ad03dc627a", "cb1f2c96f11444", "5d67a093467a43", "a832f56266f0bf", "7a464d7fab7c48", "42561af703a045", "c1c9b270211af3", "edcaf802cfd336", "6f9ba5cc39c3dc", "585554fa4224ca", "4a7216b8d2dd3e", "16c2d8b31e6fa9", "e9ae301e1bfa98", "ac8389842b368a", "158c5060209885", "c01a2c3f5b7bca", "d20124920faa1c", "a2217820d1fa40", "803272c88d1844", "c2554237c9ecc8", "d25f509a6db1de", "325148c1726f18", "398c66b1339048", "8c8c43dd7f2c26", "24cf4ec93ee498", "54618829620375", "eb494db615a50f"],
  50. ["69e1fb949b4215", "3e02e353426513", "bf6ea2adefdded", "fbbb781d40e52c", "d6ebec825d94a0", "3f84de44b6fd50", "0b466ea0458290", "3a77f7804e0c62", "b0ce750e2b2078", "69f346f188a43a", "24ef26f7c284a3", "544ea716d5498b", "3e1f23b1154dcf", "6d5c580dbec7f0", "120302c7a16ee0", "bae4ae638ee502", "60cd112182bd84", "dbc443744789a8", "7faefcebed3a2c", "579c0f77cfa536", "0d920b050cb068", "fb2fc616ee5eb8", "3b7082e645d419", "40df3b620a8474", "df360190d74ec7", "28f0d33396ee1e", "3c007bfb335325", "ac5c5327fcfbe9", "9daecd75584e11", "770aecaa7200f5", "ef955be6081878", "8c906f9fbbd9a8", "f16d11b5a2980c", "f837a8f49c0378", "33efbbae308e71", "0bda652822a309", "8990e49a4320ce", "8bf60c5517e853", "0b0f2a3d47d09b", "b07d28e7903ac9"],
  51. ["5009b61262ab9c", "0161bb90668bf4", "a314e46c502058", "447250d9698fed", "c3e4ceaa255d41", "5ba4045c2fdba8", "17b0720f52e736", "0eb0036d8439d0", "9e15116b8245e2", "3dad88738ceab0", "260986d154e9a9", "56cd13e67e508e", "9895906f7a2bc2", "4970647a63ed02", "5e192810f2e040", "02e7f4cad9b4cb", "18d5850dc181a2", "05204ea9653f18", "2d3b188124823d", "f9b34ca3d2c93b", "2e5ba515010f68", "7308114d65f874", "acbf4d6286131d", "46681d439816a8", "15fc07b05c47fe", "f0ef6a332c3132", "c4630529dd2021", "a743a1e9423e63", "b12af7fe3d806e", "0cb7d03c2afdae", "7abe068af28323", "fe75b567a2c0c7", "069313cf6c1f44", "a39aeec0ddcc87", "747c3bd20c1471", "876af6b8558b0f", "eb0b357c5d8f97", "c64ac9dcac22f2", "856e4341b42b50", "663b16ec5eb01f"],
  52. ["0d31dd990e70cc", "f7203530ab3d19", "6d42eb5412ec69", "dc9e4fcaf97880", "e0dcd2d94a10fc", "b5f39a9e831217", "4b084adf9c02c4", "d3cabf53a97846", "4c331980146846", "3c9f7c840833be", "b0cb542c3108b1", "9dcf7401e6f79a", "c1f27ed5dd4e0e", "509cf69e83c56c", "15ca00d43e1758", "5948602f5bf14d", "1d129ae6b9f4ee", "2b58f973ae2956", "6a6c792feb0c13", "62474058c00758", "caab48f22b2e6a", "ed88328618842d", "0418ebd349eb34", "846eda10087342", "e8b6c21b95cbf9", "cc90523ed0cb59", "4c9374718e79ca", "60c8fa29dd489a", "41f2190a03e88f", "8ac12bebb17c5e", "3195835960d662", "2317a3d2d90ead", "5f5aeb6d34f4e1", "7a39957a01179f", "3f88d79fc83f9c", "edb1049a771b1e", "30a85067c640ed", "06cac8047923de", "59bdda0f1b1b9d", "7a014eaecf61b7"],
  53. ["292e8b0f865638", "4dc1de3d7f5dda", "d9b1b7557b4db8", "54813ab90c75a3", "9b35f03246f1e4", "20f760465bc347", "0da41ba5991181", "a6a49de8fdf505", "60b1ea116f81a6", "ce2716aa9919a7", "e3fce68f208dd3", "05d5b9594f643d", "ded74364c812db", "16b6e7e4269696", "ad975ff975a727", "4d6e503b6ae9a9", "9ce664850ed1da", "a714650763250b", "944b7b251c3e6b", "0d37d4e4854c4c", "06c7e1c3d4b917", "5602bc69558908", "92f5ddd9a20bbd", "84d12a16b5963d", "d1426dd7f44f09", "06cca7d8cd71ba", "710072c1b4ea7a", "ebabe1e8242f72", "69960c6c0d5bf3", "2084edb90ada1d", "235ed7d8a9fe39", "3b133ed8a3fec1", "132c4509579af1", "203ca5447787a5", "ca938128fcd756", "ca569d31b6f05d", "edec4129270543", "ff17078079c2aa", "f642caa8568a3b", "8d1f6c3bf9b5e7"],
  54. ["c947c61701ce12", "1a3808b18cb73c", "d1d7543be23892", "9917eefd8b4b7d", "0eabef30f24b08", "b72c10d49c60a3", "c01344f22cc2a2", "b97c57f2a37b00", "f82a2f9338e520", "5a8b9c9ce0dc1d", "8a4d7e7260e257", "62046c5551c0e9", "19811c1011cf28", "dc158db4a957c2", "b516e794206aa4", "4a9e535622d8df", "bea44b252b2ab8", "7284568528acd5", "239ab1d64c7025", "bad538907922d6", "57fb163fcb9eca", "ad97c1507e480a", "78e8cfc81ca935", "14eee2413bbe9d", "e349073d92ab5c", "8ed191d530d9af", "f3a72b6e194e41", "d26925b22eb6c5", "f709c6088bb419", "8527923aa6f4f3", "1345fcb8916f88", "9f82d7a298174b", "b0a41e5d16d9d4", "28c7eab4098fe2", "f34abb591392d4", "a5084515586118", "71f3fcfcee19ff", "180d1b40c23b7c", "c18c22be085cc3", "edeb86d04f3c78"],
  55. ["c56c61899b8011", "2cf78b1bcd5b77", "99247be60f0cdb", "4c8a9aa7a58409", "e2bf0ad4cfe9b6", "f79b501f91d364", "5fd2c40e48e881", "c650973fb8e681", "7c8ae6d3aca02c", "7a01c329e3bf17", "3b126f2cda1e76", "229d405bbc41d3", "5e028a9f388566", "97e13e1dfee5e2", "aa02da00a5271a", "be2abd92296fc2", "e380153ffa1a5d", "dc3c184ca2fd9a", "8dd7381eccc7e0", "55a7fef2252572", "76da25ac98ef00", "3e12a21d43ef92", "28c5f1d9e71a96", "b7cd9a47a9c9d8", "aaf77a03539742", "9f8854a9983a9c", "2bcde940d64350", "6986616ba3f75f", "e80cc522c68b65", "f03f78b91d9f6c", "fdf9170e4ac9f1", "c84c3819797def", "03bbfca0340880", "2893d145bda408", "df07456e5388bf", "cbadcc8ac22dc9", "365807ab820d70", "29da8be4c0de87", "756ee3a7865bfe", "46439df366b70b"],
  56. ["ab960b51e728db", "e2e3c346921e4e", "74c6317baa49fb", "b3efd421fb40bd", "979d2df24bca93", "98d5bd5de71195", "bc030746a50c59", "02cf2a4b1b9812", "467af79145cfaa", "0ed643c7b530e4", "181ef7d406026a", "f6ea606e325377", "a302d06af1f7cc", "c7658f6ae6defa", "bbe5314d959e1f", "bb5757386c8799", "8759670183f618", "58e0cc3816f883", "c113183a0578ee", "ce5456e86ee96b", "c04285b8c56bb1", "74e5fb66d586e6", "9d8eea215e70c8", "f4a00feb7bc2f6", "369c2bf470063d", "5b267be08f0594", "c26fb2440b1ac6", "8610ef5a140769", "bb3d5b50a536d4", "df6c30bc09f971", "74e572ca84d171", "2deb91e812d860", "b17ac9ae5be211", "c95a0e3f542c78", "46397245b13a99", "1806ab9ceb6646", "1b4161b0ec2edc", "fc536e2a24abf8", "9f7207bf519f1b", "abf95b0d0d3cae"],
  57. ["d9e17ba1bf7678", "6526f524fad677", "ec243ad271d0cb", "9b1c06cf737605", "0a36697c74beaa", "fa0f0056a6bd7e", "9f2d03db497a93", "027d76e6e8692a", "72ceb29c5913a7", "55eb297dae3330", "eb676e7345fb39", "7021192efd5b47", "462906905e7511", "e005f52fd8da5e", "1288c01960d735", "3460b18eafd2d8", "faa9b1c3caf426", "5035e585d9fd2d", "85636dff1d4e42", "600c4b7f664267", "02b21e6a8c7a03", "79ce25c264e2f4", "035a7f32c227ea", "bf8f711445a7d7", "d0b5e3b336f71e", "c454a416321483", "bdc1a7a9d20dea", "e1ee4744e83143", "5b6969f2864529", "17a6b42d6346ab", "ff0fb6edf2265a", "ba75b0991f6dfb", "6638c1d7243ff8", "e7806af6600486", "dfe3bc58f31717", "b0c4adc2717922", "c11abff0b4a290", "43598e076f60be", "2ef17ad2f77605", "3a41a09d974da6"],
  58. ["ee787846e7ff26", "ce05d869fecf18", "fde916d95f9357", "4c1b4dd723b90d", "b1f024400d61a2", "f51dfebc71b770", "461e7f725d9637", "2b1587ff40035e", "a2cafbcd0c6b17", "2e9efaf6986045", "80e339a823ea56", "febfaa02609bb2", "a33955624e1602", "a137b84639ef0c", "6e2ecf420a6d6b", "69f13acbea8f97", "b4d36c41e3a867", "1352aee4798c08", "e3ec254ddf35cb", "ab600d90f13919", "d00cc1d401fd2c", "1c629e621756d2", "090f8d6e0895fa", "701bd1b0a355ce", "a53c7c91b15eb4", "dd8579d4dd92e4", "03d1c960c63d55", "215a8fbc09cc85", "59c1e6069b6dd1", "a0428bfb223cca", "46d131153e9982", "c5dab0c9ffb93d", "682db866d6503c", "a481c48384a087", "a417c564567258", "2ec7b9722b5c5f", "2d491f9cf79086", "30cd268b1088d0", "f02e69b1441963", "d9841b5339d18f"],
  59. ["a26deb7b957527", "337f3bd67d3c51", "e6839a4d5fe4cf", "1619c18889be68", "d971f0f57d1016", "56213ebf152a2d", "9c0e0394832c92", "9e6fc90ca28ba5", "9c5151dfbb8394", "f49fe4cf2a3f7a", "97f4db054b2b34", "2a4c21abf6406f", "eb941a80bee3f8", "7615468e80e77a", "0f935ebe8e8842", "959f2b3ba1f50c", "d6bc8b614e39de", "3c43d13746983a", "7956e617131247", "56de3547cf1010", "c16d5d1fce2bcc", "3e73e5ef9fd691", "1211c1a27803ad", "f1c9644aac4ba2", "8d67134e3be189", "d8aee617c607cb", "f62677b30d8ece", "e7df69402b2291", "6ec102f220e09f", "a6223e874c3e53", "fb474983ebdb9f", "806832bde2f4e6", "7c25ef688134b3", "4aadca3409a6b3", "bdccd638f3b19a", "2b01f18625fdd1", "0f5e91c28af081", "f28e4dcd9077cd", "9229d87caebbfb", "072b846b4d2ce0"],
  60. ["fd7a25e195d67a", "ec9546899268d2", "ff3068a2e9d0c2", "af9f2fc2de9978", "01b47566d0faef", "fc5a8eab966720", "4b981c9fe7ff10", "b4a0aa0873484e", "25a8b544ed8801", "c72530c2e5d37f", "94b0483e74e4fa", "bc5ac97d82cd68", "1a23d34cce0d52", "6e4d17a8475b19", "63493b14551149", "d36db24ae5ced3", "a24a53ea6aada0", "230cbe502aa32e", "2aa07485f281e6", "66777be0d719c7", "5d3ab65be78916", "06076f42e71bd2", "273e56dd3eccfd", "5ef1c9394b6a9e", "42f1f49590ffa2", "1e6ab6994e56a8", "8d54a339e301c2", "efff698c46e74e", "6721df7c5334d0", "f36cf6a93bf3ff", "91d8979d8fe631", "321dc8b5eccceb", "a237eb1423c395", "4623a16cc50b79", "83f616f60d8114", "32c15a65536b82", "e4a00d384d99cd", "369206bbef6fb4", "42a720e294a9e4", "768a1c77e94dac"],
  61. ["31d4798dffbd75", "da46bbd77e908b", "0fc027a69fcccc", "4204ee745159f5", "c14155873d42b2", "7ce0c031527eae", "22fb1c9d6da9a7", "33c940531510c9", "d938e52464ce71", "385b73fa95a2d3", "597bf6362dd268", "f9901921654409", "7c8d064cd5b4ea", "80e8fe2f1b3288", "ee188609ef2cdf", "beee34a1c48fe2", "459cefca35857f", "33b5320fbbca79", "7789297027b6a4", "f1debe5a09d013", "fd5d818a56bf63", "19a092fb1ec45c", "526f5d3ff64331", "9b8295291aef56", "d6963c3a92c34c", "065482a033fbbb", "9b9ab43410d764", "44ebbd99c86a86", "4c087234311b85", "db6e5a803ba13f", "760c159ce2a619", "d58d83243fe0ba", "1c1e5e83aa79b5", "75c8bbae9baabf", "2ed91bdb632ae8", "8e46b443cfffe5", "afa4f53f148577", "0be538701c4afa", "3fd89c44ef7ced", "060dcdc21e9368"],
  62. ["0a5b9e2ba4a53b", "63db0419a96d30", "f68e038377a61e", "aa15b78389ec74", "5f532809ff80f1", "f2892acc49ca4e", "e2d68174c08e81", "378254a38f5138", "0b060222bb20b1", "8013f6f4745c47", "ef08e87e2c197d", "b69d5ddaadf417", "7bc66fe482b730", "f4bd76d3bb1dfc", "09492b63f2935b", "43875dd685ab00", "e15a528f666486", "aad1fac042ef90", "b3bb7b8ef9c2e9", "c78967b9392a1c", "2f05fd5ca0230b", "1008345afdd18c", "dac73c313ace60", "346d535e500b62", "12e6357496459b", "ecccdac5a34926", "3b880f7098608f", "e66c3352a9cdd6", "049b176ff1a04d", "897d9569948066", "806230e9740d6e", "179ebf2b7952ab", "3a2c5079b5bbea", "73261b85c35fb1", "5b917dc1bf7e57", "9c55b95581c1d5", "e1fb86e6219639", "c72a22d8404448", "95dc5d7b966027", "457f3fec730d5d"],
  63. ["469cd82a2b3cec", "021d9de560b8d6", "85b4d126933886", "c8265dafb87325", "8741d99af7f420", "1329e52d3e66f8", "7d37c458a6ad05", "1241c5ccbc355b", "7fdcad3c3c269d", "05f04a0a23acc7", "ce076aba97cc18", "74b36afc4645b2", "cd7adaad8f5b91", "bd0651649dc722", "3d9b6437c667fb", "6827ec09eed45e", "8ad6102faa934f", "1a80658c0bfe1e", "ef1749235ab59f", "75478ad5949a06", "49ce6e19841851", "8df41dc39cc628", "bd9dc9bec89c8b", "7771a21fe8028c", "65082929b051f3", "c657798a3aebd1", "ce9c37c494cfc8", "156efce8330e42", "d0d95860d39040", "dfb0fb66f814c4", "4b421540a0aece", "9e767cbf7e9c49", "eeea5b5c866a9e", "e2026ca4bfb067", "ec9fff1a5d41c0", "290ed4da32d333", "65208d00dba471", "99e1d15a83b736", "5585401976a265", "1668daeb4aad72"],
  64. ["cdabffa646baca", "7a6c7bb29875f7", "1a87a53a2139c1", "1ecf7ae823158a", "b1087bf595f7f2", "d8e668fe076e4e", "b0794cf137a863", "81e2a419a320ac", "8090b1d39e5171", "813903d5f1a68c", "ba31f8211e56bb", "52413eefa30a66", "af88d053eb8a4a", "4d2235fdb9bf91", "69a947973d3ed3", "0dbcf583c26ffd", "b6bfbee58458b7", "5a12f3e625e5d8", "53ae22c2b1bc6a", "8e6f7e7bbde691", "2b692a6746d3be", "686438e4ac66e4", "aa77be21178471", "36aed3fc3ff079", "8c9373ebb1c2f7", "bb99fd5bfaebc1", "665902d08610e8", "8af0db91b80b6e", "00d4995f9a6ce8", "1d503d26442bd9", "e61b181dfd0949", "2a02f5075a277e", "76caa7ddc435fe", "5cedae4cae7a57", "4b5f7c58c4f214", "1446a05c1023ab", "459c93a9f5ad37", "1ea5f5aa4060b2", "a48215350fcd60", "ac21e2a4729a51"],
  65. ["f18cf87ecf430f", "0fd48c241ac6bc", "33964cd2e3d9ec", "8bebeffc2e848e", "bb84a5c2ea9b0e", "311f20ff7ce601", "752573f4effe98", "79dbe4d184dce5", "6bb04def99d322", "7d2d5f23c2475b", "7f93f7dbddf04e", "fff303e751fffe", "08d205f8999a3d", "5750d14f75e056", "1107a3f96ca8e9", "f62b50c8ad9f20", "53e7fcc55d72d8", "6345dec1054cb6", "01d52c21dc654a", "aa0bd78e39c594", "2265b675381cd5", "57cc03dd65f821", "1fa373049059a8", "9885886b48085f", "8357ab98192a14", "5bb6cfbf84048b", "5cf862f25ff6ab", "c9382e36ab2dbd", "2357b5ade91fcf", "2db77558ceef24", "d4a0cb3ba50a2a", "12c3cb633dfe47", "db805410168807", "a5e635ac766e1a", "25252810f49fad", "cae296fce18ed4", "b9932d5822c519", "4b7006cc54ea84", "2546d761d284cf", "2346d0a11b1ed9"],
  66. ["81ce0d028c4474", "c8002fd0315372", "8670db1a6ad6eb", "4c7f942260e9c9", "822bb2c423cc53", "e3b67febea3672", "59c24223d913c3", "6f4b196f69400f", "51bfb6cc7f3603", "fb9fbef84ffaf4", "7c1632636806f6", "a50ec42076931f", "f68b2be9e5e7ad", "7603302a518bd4", "d7cd9bb97ffa3c", "acf1faaebf7412", "f55d55d548bd86", "5b34112ed53d06", "1b58692e1e33b7", "cc7e3cb6d32fe2", "8f7b35c14a744f", "9a4ed599399554", "8eb369e71641af", "d4a6d1a5c74123", "8cc7ec376acf04", "ec0a470647b248", "2fd9e8eea1f10e", "94439285677960", "4d11f6e6a426e0", "06378817230b68", "ec14f2df152cb7", "199a8c0bd5f05d", "ecad5aab44ac2b", "ca87ab2ba6e905", "69c0bf2acdb36c", "d66279737bc807", "4dd946eb19d81b", "4e9c473b5e9846", "5a016f7ca86f9d", "d02c2b7dca744a"]]
  67.  
  68. # Transposed matrix (used for sink keys)
  69. tm = map(list, zip(*m))
  70.  
  71.  
  72.  
  73. # Generate a random KSV (40-bit number with exactly 20 zeroes and 20 ones)
  74. def gen_ksv():
  75.   random.seed()
  76.   ones = 0
  77.   zeroes = 0
  78.   ksv = ""
  79.   for i in range(0, 40):
  80.     if ones == 20:
  81.       bit = 0
  82.     elif zeroes == 20:
  83.       bit = 1
  84.     else:
  85.       bit = random.randint(0,1)
  86.     if bit == 0:
  87.       zeroes += 1
  88.     else:
  89.       ones += 1
  90.     ksv += str(bit)
  91.   return ksv
  92.  
  93. def sum_row(row):
  94.   sum = 0
  95.   for item in row:
  96.     item = long(item, 16)
  97.     item = item % pow(2, 56)
  98.     sum += item
  99.   return sum
  100.  
  101. def gen_key(matrix, ksv):
  102.   key = 0
  103.   for i in range(39, -1, -1):
  104.     if ksv[i] == "1":
  105.       key += sum_row(matrix[39-i])
  106.   # Key is the first 56-bits of this
  107.   return key & ((1<<56) - 1)
  108.  
  109. ksv = gen_ksv()
  110. source_key = gen_key(m, ksv)
  111. sink_key = gen_key(tm, ksv)
  112. print "KSV: %s" % ksv
  113. print "Source key: %s (%d)" % (hex(source_key), source_key)
  114. print "Sink key: %s (%d)" % (hex(sink_key), sink_key)
RAW Paste Data
Top