class Aeskeyfind < Formula desc "Program for automatic key-finding" homepage "https://citp.princeton.edu/research/memory/code/" url "https://citp.princeton.edu/memory-content/src/aeskeyfind-1.0.tar.gz" sha256 "1417e5c1b61e86bb9527db1f5bee1995a0eea82475db3cbc880e04bf706083e4" bottle do cellar :any_skip_relocation revision 1 sha256 "697164fffdd9980d5a27497d9efeff361bd3138262ba52985e6b78933100f1b1" => :el_capitan sha256 "291bf5f582110923f992976078e2a5569fecacac3dfaf20fc1dbc63576c022f5" => :yosemite sha256 "59010916c55f28c10a7f0eed3bdfb52f8926457d7793fb75e1e0c6bedbe73cc3" => :mavericks end def install system "make" bin.install "aeskeyfind" end test do # aeskeyfind will search a block of data and return any found keys # We're looking for this key: test_key = "30e2b369b65d6d36413f81c78aca6381a97f7e8918482838b7b55fd86839b149" # Test block containing the above AES key: test_data = [ 0xA7, 0xFF, 0xA3, 0x4A, 0x2E, 0x26, 0x8D, 0xBA, 0xAF, 0xA7, 0xB5, 0x71, 0x48, 0x49, 0xF9, 0x99, 0xA4, 0x89, 0xFC, 0xAB, 0x6A, 0x49, 0x57, 0xDD, 0xFE, 0xCD, 0xDE, 0x48, 0x90, 0xDA, 0x00, 0xFB, 0x7D, 0xFB, 0xE4, 0xD8, 0x21, 0x51, 0xCF, 0xB2, 0x57, 0x4E, 0x76, 0x2C, 0x21, 0x7A, 0x6C, 0x1B, 0x4A, 0xF0, 0xE4, 0x9F, 0x6E, 0x51, 0x26, 0x17, 0xB1, 0x9C, 0x2B, 0xED, 0xE5, 0xB6, 0x23, 0x34, 0x66, 0x04, 0x16, 0x54, 0x00, 0x2D, 0xEB, 0xB2, 0x95, 0x1A, 0xD7, 0x12, 0x92, 0x32, 0xC0, 0x3F, 0x35, 0xD6, 0xB1, 0xA4, 0xA2, 0xC4, 0x84, 0xC8, 0x5A, 0x04, 0xC3, 0x3D, 0x17, 0x53, 0xAB, 0x8B, 0xB7, 0xC7, 0x44, 0x59, 0x3C, 0x24, 0x11, 0xD3, 0x47, 0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 0x38, 0x60, 0x72, 0x0C, 0xBA, 0x41, 0xD8, 0xB7, 0xAE, 0xED, 0x67, 0x06, 0x3C, 0xE0, 0xF3, 0xAF, 0x1A, 0xA3, 0xB0, 0x76, 0x84, 0x1C, 0xB2, 0x75, 0x7D, 0xD0, 0x00, 0x4D, 0xA0, 0xD7, 0xA3, 0x9C, 0x98, 0xB7, 0xD1, 0x90, 0x22, 0xF6, 0x98, 0x24, 0xEC, 0xD3, 0xFF, 0x22, 0xD0, 0x33, 0x0C, 0x8D, 0xCA, 0x90, 0xBC, 0xFB, 0x4E, 0x8C, 0xD7, 0x7A, 0x52, 0xB4, 0xD7, 0x37, 0xF2, 0x63, 0x74, 0xAB, 0x6A, 0xD4, 0xA5, 0x3B, 0x48, 0x22, 0x3A, 0x76, 0x7F, 0xD5, 0xC5, 0x54, 0xAF, 0xE6, 0xC9, 0xD9, 0x65, 0x76, 0x75, 0x22, 0x2B, 0xFA, 0 ] path = testpath/"aeskey.bin" path.binwrite test_data.pack("C*") output = shell_output("#{bin}/aeskeyfind -q #{path}").strip assert_equal test_key, output end end