security through obscurity
This commit is contained in:
parent
de13b172c8
commit
fd7c4890f8
4 changed files with 55 additions and 0 deletions
1
security-through-obscurity/description.md
Normal file
1
security-through-obscurity/description.md
Normal file
|
@ -0,0 +1 @@
|
|||
I've never seen such a cryptosystem before! It looks like a public key cryptosystem, though... Could you help me crack it?
|
41
security-through-obscurity/encrypt.sage
Normal file
41
security-through-obscurity/encrypt.sage
Normal file
|
@ -0,0 +1,41 @@
|
|||
p = 196732205348849427366498732223276547339
|
||||
secret = REDACTED
|
||||
def calc_root(num, mod, n):
|
||||
f = GF(mod)
|
||||
temp = f(num)
|
||||
return temp.nth_root(n)
|
||||
|
||||
def gen_v_list(primelist, p, secret):
|
||||
a = []
|
||||
for prime in primelist:
|
||||
a.append(calc_root(prime, p, secret))
|
||||
return a
|
||||
|
||||
def decodeInt(i, primelist):
|
||||
pl = sorted(primelist)[::-1]
|
||||
out = ''
|
||||
for j in pl:
|
||||
if i%j == 0:
|
||||
out += '1'
|
||||
else:
|
||||
out += '0'
|
||||
return out
|
||||
|
||||
def bin2asc(b):
|
||||
return hex(int(b,2)).replace('0x','').decode('hex')
|
||||
|
||||
primelist = [2,3,5,7,11,13,17,19,23,29,31,37,43,47,53,59]
|
||||
message = REDACTED
|
||||
chunks = []
|
||||
for i in range(0,len(message),2):
|
||||
chunks += [message[i:i+2]]
|
||||
|
||||
vlist = gen_v_list(primelist,p,secret)
|
||||
print(vlist)
|
||||
for chunk in chunks:
|
||||
binarized = bin(int(chunk.encode('hex'),16)).replace('0b','').zfill(16)[::-1] #lsb first
|
||||
enc = 1
|
||||
for bit in range(len(binarized)):
|
||||
enc *= vlist[bit]**int(binarized[bit])
|
||||
enc = enc%p
|
||||
print(enc)
|
10
security-through-obscurity/problem.yml
Normal file
10
security-through-obscurity/problem.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
title: Security Through Obscurity
|
||||
hint: Maybe google would help.
|
||||
category: Cryptography
|
||||
autogen: false
|
||||
programming: false
|
||||
value: 451
|
||||
files:
|
||||
- encrypt.sage
|
||||
- publickey_and_ciphertext.txt
|
||||
|
3
security-through-obscurity/publickey_and_ciphertext.txt
Normal file
3
security-through-obscurity/publickey_and_ciphertext.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
p = 196732205348849427366498732223276547339
|
||||
vlist = [186290890175539004453897585557650819247, 75402298316736094226532182518108134406, 125495142022496378270547998225256386407, 97774267687164931514953833940936099082, 101991197227908059637463567354647370660, 153833851791059142883915934225837717549, 57404874013093467650483424580890463792, 21385179362692238453302681296928238570, 73119997627509808412069264512026243174, 187307466063352771786747395191866088255, 99696708971915885525739992181010504930, 35400960589917132410614021764179554582, 165004028169785856134522269878963539096, 23921651712221317415895203722083962980, 101282552285744196401422074083408273639, 36527324251768098978171373433957274016]
|
||||
ciphertext = [10804437392992369932709952388461430442, 176193785024128365464527424154073333243, 149270645998191619421663334736314262928, 84083279828403258970202482839973583723, 105542809657403162156368566034837560781, 170535468317794277192003839288646533914, 1709561989051017137832962458645802494, 30208132812353075834728747743616689590, 179552149608863037880916374596103803214, 146319871444551859531557724256502213689, 94266034977624098660397183255753485858, 59624105602644297614582310044425417646, 150207980679551836987813576795479579005, 47189940152625174480564945084004798024, 60923399917552243674613186036841652885, 56060552313063913798237738953734149992, 153365453785043472981157196787373992079, 97439800863356756323659264743487719966, 105572255903480949865247928773026019148, 47189940152625174480564945084004798024, 32547907449246015626932936731350157592, 97471053149217334376536988401195572824, 156999991149661497460742185971412527182, 97705058765750947378422286408948780428, 56123764944636237849915747435965967337, 180380146745295930385428990214293723238, 178014626944341285289827069179285260436, 99504741454750536629756505680249931430]
|
Loading…
Reference in a new issue