From 5967931a29a8588b79ecb732ecc81571f518eed2 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Mon, 21 Dec 2020 12:54:37 -0500 Subject: challenge/ch13.go -> challenge/c13.go --- challenge/c13.go | 30 ++++++++++++++++++++++++++++++ challenge/ch13.go | 30 ------------------------------ 2 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 challenge/c13.go delete mode 100644 challenge/ch13.go (limited to 'challenge') diff --git a/challenge/c13.go b/challenge/c13.go new file mode 100644 index 0000000..357a802 --- /dev/null +++ b/challenge/c13.go @@ -0,0 +1,30 @@ +// Copyright © 2020 rsiddharth +// SPDX-License-Identifier: ISC + +package challenge + +import ( + "fmt" + "ricketyspace.net/cryptopals/lib" +) + +func C13() { + adminBlock := lib.BytesToStr(lib.Pkcs7Padding(lib.StrToBytes("admin"), 16)) + ep := lib.WebProfileFor("foo@abacus" + adminBlock) + encryptedEP := lib.WebEncryptProfile(ep) + adminBlockCipher := encryptedEP[16:32] // Second block in the cipher + + ep = lib.WebProfileFor("foo@abacus") + encryptedEP = lib.WebEncryptProfile(ep) + for i := 0; i < 16; i++ { // Replace last block with the admin cipher block. + encryptedEP[32+i] = adminBlockCipher[i] + } + adminEP := lib.WebDecryptProfile(encryptedEP) + adminProfile := lib.WebDecodeProfile(adminEP) + fmt.Printf("Admin Encoded Profile: %v\n", adminEP) + fmt.Printf("Admin Profile: %v\n", adminProfile) +} + +// Output: +// Admin Encoded Profile: email=foo@abacus&uid=10001&role=admin +// Admin Profile: map[email:foo@abacus role:admin uid:10001] diff --git a/challenge/ch13.go b/challenge/ch13.go deleted file mode 100644 index 357a802..0000000 --- a/challenge/ch13.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright © 2020 rsiddharth -// SPDX-License-Identifier: ISC - -package challenge - -import ( - "fmt" - "ricketyspace.net/cryptopals/lib" -) - -func C13() { - adminBlock := lib.BytesToStr(lib.Pkcs7Padding(lib.StrToBytes("admin"), 16)) - ep := lib.WebProfileFor("foo@abacus" + adminBlock) - encryptedEP := lib.WebEncryptProfile(ep) - adminBlockCipher := encryptedEP[16:32] // Second block in the cipher - - ep = lib.WebProfileFor("foo@abacus") - encryptedEP = lib.WebEncryptProfile(ep) - for i := 0; i < 16; i++ { // Replace last block with the admin cipher block. - encryptedEP[32+i] = adminBlockCipher[i] - } - adminEP := lib.WebDecryptProfile(encryptedEP) - adminProfile := lib.WebDecodeProfile(adminEP) - fmt.Printf("Admin Encoded Profile: %v\n", adminEP) - fmt.Printf("Admin Profile: %v\n", adminProfile) -} - -// Output: -// Admin Encoded Profile: email=foo@abacus&uid=10001&role=admin -// Admin Profile: map[email:foo@abacus role:admin uid:10001] -- cgit v1.2.3