50ea8ef93d · 2026-03-14 04:53:21 +07:00
14 Commits
2026-03-05 04:50:27 +07:00
Ts
2026-03-14 04:43:48 +07:00
2026-03-05 03:25:11 +07:00
2026-01-24 18:12:04 +07:00
2026-03-05 03:25:11 +07:00
2026-03-05 03:25:11 +07:00
2026-03-06 18:19:28 +07:00
2026-03-06 18:19:28 +07:00
2026-03-05 04:50:27 +07:00
Ts3
2026-03-14 04:53:21 +07:00
2026-03-06 18:19:28 +07:00

fuck ts

a5/1

what is this for again

implemented in a51.py

explanation

  1. setup

    set up three strips of length 19, 22, 23. Imagine this strip is like a fixed size fifo queue.

  2. check slots to roll

    in these three strips, find these slot, take those value

    strip length slot for maj (index 0)
    19 8
    22 10
    23 10

    if value in slot is equal to the majority, roll it.

  3. roll

    for each strip that rolls, take value from these slots and xor them together. The result will be pushed in.

    strip length slots to xor
    19 13, 16, 17, 18
    22 20, 21
    23 7, 20, 21, 22

    so if 19 roll i do:

    x0 = x[13] ^ x[16] ^ x[17] ^ x[18]
    x = [x0, *x][:-1]
    
  4. get result

    take the last thing ever of the three strips, xor them together, and thats your output.

DES/AES basics

des

key length: 56 effective / 64 all
block length: 64
rounds: 16
subkey: 48

S-box

used to hash a 6 bit number to 4 bit

table should have 4 rows [00-03] 16 cols [00-15]

to get where youre at:

6 bit number with the form \overline{mabcdn}_2 (each being 0 or 1)

find row \overline{mn}_2 (as decimal)

find col \overline{abcd}_2 (as decimal)

im lazy

im not writing the rest of ts down. aint no way son

block modes

diagram ahh. i aint do Ts.

cipher block chaining (CBC)


\begin{aligned}
    y_1 &= e_k(x_1 \oplus IV) \\
    y_i &= e_k(x_i \oplus y_{i-1}) \\
    x_1 &= e_k^{-1}(y_1) \oplus IV \\
    x_i &= e_k^{-1}(y_i) \oplus y_{i-1} \\
\end{aligned}

OFB


\begin{aligned}
    s_1 &= e_k(IV) \\
    s_i &= e_k(s_{i-1}) \\
    y_i &= s_i \oplus x_i \\
    x_i &= s_i \oplus y_i \\
\end{aligned}

cfb


\begin{aligned}
    y_1 &= e_k(IV) \oplus x_1 \\
    y_i &= e_k(y_{i-1}) \oplus x_i \\
    x_1 &= e_k(IV) \oplus y_1 \\
    x_i &= e_k(y_{i-1}) \oplus y_i \\
\end{aligned}

ctr


\begin{aligned}
    y_i = e_k(IV \| CTR_i) \oplus x_i
\end{aligned}

fast expo

two kinds apparently. idk

the one

  1. convert expo to binary. we go left to right. (Ts is buns)

    lets say we have x, e = \overline{e_1e_2e_3e_4}_2 and n. We are trying to do x^e \pmod n or just x^e

  2. let do Ts

    1. of course

      we have e_1 = 1

      do x^{\overline{e_1}} \pmod n

    2. sq step

      we are trying to expand Ts to x^{\overline{e_1e_2}}

      so we first do x^{\overline{e_10}} aka x^{\overline{e_1} \cdot 2}

      do ans^2 \pmod n

    3. mul step

      if e_2 conveniently equals 0, skip Ts.

      so x^{\overline{e_10}} needs to become x^{\overline{e_11}}

      that means you needa multiply by x.

      do ans \cdot x \pmod n

    4. repeat 2 until you cant no more

  3. Ts is complete! pow(x, e, n) == ans.

rsa

Ts is for encrypting a Thing knowing Some.

uhh

get urself two prime p, q.

N = pq has length 1024 bit.

LN = (p-1)(q-1)

e st. 1 < e < LN && gcd(e, LN) = 1

find d st. e^{-1} \equiv d \pmod{LN}

your pubkey is N, e

your privkey is d

message enc/dec

for enc: M^e \equiv C \pmod N

for dec: C^d \equiv M \pmod N

dhke

for establishing the first of connections

get yourself and peers to agree on a prime p, generator g.

your key is a.

whatever was the relationship between these number idfk.

do g^a mod p. send that as pubkey Yours.

whoever else doing ts would send some of theirs (B)

do B^a mod p.

whoever was sending you would do A^b mod p, b being their key.

these two numbers should be the same.

Now you can encrypt your msg with this shared key using aes or something idfk

elgamal / dsa

for authentication. is this really you type shit.

elgamal

  1. setup get yourself a prime p.

    alpha in [0, p) where gcd(alpha, p) = 1.

    d in [2, p-2]

    calc beta being alpha^d mod p

    now your pubkey is p, alpha, beta

    privkey is d

  2. sign yo shi imagine msg x.

    create a throwaway key ke in [2, p-2] and is coprime with p - 1

    calc r = alpha ^ ke mod p

    s = (x - d \cdot r) k_e^{-1} \pmod{p-1}

    give (r, s) to whoever is gonna verify yo msg

  3. verify x get ts to be true:

    \beta^rr^s \equiv \alpha^x \pmod p

    then you are ball.

fuck is this used for

they will try to write yo rsa pubkey + yo id in the msg so the rsa key is from who you expect

a random ahh Certificate Authority will give you the id

dsa

is jus a cracked version of above

hash

sha1

msg

msg will be chopped up in 512 bit chunks to be hashed

get msg length. + 64 as this length stores in a 64 bit number.

if this doesnt fit a multiple of 512 pad between with 100.000

so the final is (imagine) f"{msg}1000...000{len(msg):b}" with length being multiple of 512.

diagrams

no.

S
Description
am i ready for Ts
Readme
51 KiB
0 Stars 2 Watchers 0 Forks
Languages
Python 100%