summaryrefslogtreecommitdiffstats
path: root/challenge/c10.go
blob: 5e208ee7796207bd79fbab9c3d15897eded93214 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
// Copyright © 2020 rsiddharth <s@ricketyspace.net>
// SPDX-License-Identifier: ISC

package challenge

import (
	"fmt"
	"ricketyspace.net/cryptopals/lib"
)

var cipher80038A = lib.HexStrToBytes("7649abac8119b246cee98e9b12e9197d" +
	"5086cb9b507219ee95db113a917678b2" +
	"73bed6b8e3c1743b7116e69e22229516" +
	"3ff1caa1681fac09120eca307586e1a7")

var key80038A = lib.HexStrToBytes("2b7e151628aed2a6abf7158809cf4f3c")

var iv80038A = lib.HexStrToBytes("000102030405060708090a0b0c0d0e0f")

var cipher10 string = `CRIwqt4+szDbqkNY+I0qbNXPg1XLaCM5etQ5Bt9DRFV/xIN2k8Go7jtArLIy
P605b071DL8C+FPYSHOXPkMMMFPAKm+Nsu0nCBMQVt9mlluHbVE/yl6VaBCj
NuOGvHZ9WYvt51uR/lklZZ0ObqD5UaC1rupZwCEK4pIWf6JQ4pTyPjyiPtKX
g54FNQvbVIHeotUG2kHEvHGS/w2Tt4E42xEwVfi29J3yp0O/TcL7aoRZIcJj
MV4qxY/uvZLGsjo1/IyhtQp3vY0nSzJjGgaLYXpvRn8TaAcEtH3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zRyWh4PkDj5wy5ECaRbfO
7rbs1EHlshFvXfGlLdEfP2kKpT9U32NKZ4h+Gr9ymqZ6isb1KfNov1rw0KSq
YNP+EyWCyLRJ3EcOYdvVwVb+vIiyzxnRdugB3vNzaNljHG5ypEJQaTLphIQn
lP02xcBpMNJN69bijVtnASN/TLV5ocYvtnWPTBKu3OyOkcflMaHCEUgHPW0f
mGfld4i9Tu35zrKvTDzfxkJX7+KJ72d/V+ksNKWvwn/wvMOZsa2EEOfdCidm
oql027IS5XvSHynQtvFmw0HTk9UXt8HdVNTqcdy/jUFmXpXNP2Wvn8PrU2Dh
kkIzWhQ5Rxd/vnM2QQr9Cxa2J9GXEV3kGDiZV90+PCDSVGY4VgF8y7GedI1h`

var key10 = "YELLOW SUBMARINE"

var iv10 []byte = make([]byte, 16)

func init() {
	for i := 0; i < 16; i++ {
		iv10[i] = 0x00
	}
}

func C10() {
	o := lib.AESDecryptCBC(cipher80038A, key80038A, iv80038A)
	fmt.Printf("NIST SP 800-38A F.2.2:%v\n", lib.BytesToHexStr(o))

	c := lib.Base64ToBytes(cipher10)
	k := lib.StrToBytes(key10)
	iv := iv10

	o = lib.AESDecryptCBC(c, k, iv)
	fmt.Printf("\nCryptopals Ch. 10:\n%v", lib.BytesToStr(o))
}

// Output:
// NIST SP 800-38A F.2.2: 6b c1 be e2 2e 40 9f 96 e9 3d 7e 11 73 93 17 2a ae 2d 8a 57 1e 03 ac 9c 9e b7 6f ac 45 af 8e 51 30 c8 1c 46 a3 5c e4 11 e5 fb c1 19 1a 0a 52 ef f6 9f 24 45 df 4f 9b 17 ad 2b 41 7b e6 6c 37 10
//
// Cryptopals Ch. 10:
// I'm back and I'm ringin' the bell
// A rockin' on the mike while the fly girls yell
// In ecstasy in the back of me
// Well that's my DJ Deshay cuttin' all them Z's
// Hittin' hard and the girlies goin' crazy
// Vanilla's on the mike, man I'm not lazy.
//
// I'm lettin' my drug kick in
// It controls my mouth and I begin
// To just let it flow, let my concepts go
// My posse's to the side yellin', Go Vanilla Go!
//
// Smooth 'cause that's the way I will be
// And if you don't give a damn, then
// Why you starin' at me
// So get off 'cause I control the stage
// There's no dissin' allowed
// I'm in my own phase
// The girlies sa y they love me and that is ok
// And I can dance better than any kid n' play
//
// Stage 2 -- Yea the one ya' wanna listen to
// It's off my head so let the beat play through
// So I can funk it up and make it sound good
// 1-2-3 Yo -- Knock on some wood
// For good luck, I like my rhymes atrocious
// Supercalafragilisticexpialidocious
// I'm an effect and that you can bet
// I can take a fly girl and make her wet.
//
// I'm like Samson -- Samson to Delilah
// There's no denyin', You can try to hang
// But you'll keep tryin' to get my style
// Over and over, practice makes perfect
// But not if you're a loafer.
//
// You'll get nowhere, no place, no time, no girls
// Soon -- Oh my God, homebody, you probably eat
// Spaghetti with a spoon! Come on and say it!
//
// VIP. Vanilla Ice yep, yep, I'm comin' hard like a rhino
// Intoxicating so you stagger like a wino
// So punks stop trying and girl stop cryin'
// Vanilla Ice is sellin' and you people are buyin'
// 'Cause why the freaks are jockin' like Crazy Glue
// Movin' and groovin' trying to sing along
// All through the ghetto groovin' this here song
// Now you're amazed by the VIP posse.
//
// Steppin' so hard like a German Nazi
// Startled by the bases hittin' ground
// There's no trippin' on mine, I'm just gettin' down
// Sparkamatic, I'm hangin' tight like a fanatic
// You trapped me once and I thought that
// You might have it
// So step down and lend me your ear
// '89 in my time! You, '90 is my year.
//
// You're weakenin' fast, YO! and I can tell it
// Your body's gettin' hot, so, so I can smell it
// So don't be mad and don't be sad
// 'Cause the lyrics belong to ICE, You can call me Dad
// You're pitchin' a fit, so step back and endure
// Let the witch doctor, Ice, do the dance to cure
// So come up close and don't be square
// You wanna battle me -- Anytime, anywhere
//
// You thought that I was weak, Boy, you're dead wrong
// So come on, everybody and sing this song
//
// Say -- Play that funky music Say, go white boy, go white boy go
// play that funky music Go white boy, go white boy, go
// Lay down and boogie and play that funky music till you die.
//
// Play that funky music Come on, Come on, let me hear
// Play that funky music white boy you say it, say it
// Play that funky music A little louder now
// Play that funky music, white boy Come on, Come on, Come on
// Play that funky music
//