diff options
author | rsiddharth <s@ricketyspace.net> | 2020-12-21 12:41:09 -0500 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2020-12-21 12:41:09 -0500 |
commit | 5a03bb77ffaef47ab109b7b5284d0158f9eafb9c (patch) | |
tree | 9457ff6897c3b12c04ec926dadc10dba65afa167 /challenge/ch13.go | |
parent | e62af3b41545ac7cb1b1b1cc0f58503a9437741c (diff) |
do challenge 13
Diffstat (limited to 'challenge/ch13.go')
-rw-r--r-- | challenge/ch13.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/challenge/ch13.go b/challenge/ch13.go new file mode 100644 index 0000000..357a802 --- /dev/null +++ b/challenge/ch13.go @@ -0,0 +1,30 @@ +// Copyright © 2020 rsiddharth <s@ricketyspace.net> +// 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] |