My nix-darwin and NixOS config
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: further alignment

+17 -17
+17 -17
scripts/migrate-gts-to-sharkey.sh
··· 49 49 50 50 # ── Inline Python converter: Go JSON RSA key → PEM ──────────────────────────── 51 51 # Called as: json_to_pem <private|public> <<< "$JSON" 52 - # Uses nix shell to provide python3 + cryptography without a global install. 52 + # Uses nix-shell to provide python3 + cryptography without a global install. 53 + # 54 + # Go's encoding/json marshals *rsa.PrivateKey with fields: 55 + # private: {"N":...,"E":...,"D":...,"Primes":[p,q],...} 56 + # Go's encoding/json marshals *rsa.PublicKey with fields: 57 + # public: {"N":...,"E":...} 53 58 JSON_TO_PEM_PY=' 54 59 import sys, json 55 60 from cryptography.hazmat.primitives.asymmetric.rsa import ( ··· 59 64 Encoding, PrivateFormat, PublicFormat, NoEncryption 60 65 ) 61 66 62 - # Go marshals big.Int via MarshalText() — plain decimal, no quotes, as a JSON number. 63 - def bigint(v): 64 - return int(v) 65 - 66 - k = json.loads(sys.stdin.read()) 67 - N = bigint(k["N"]) 68 - E = int(k["E"]) 69 - D = bigint(k["D"]) 70 - P = bigint(k["Primes"][0]) 71 - Q = bigint(k["Primes"][1]) 72 - 67 + k = json.loads(sys.stdin.read()) 68 + mode = sys.argv[1] 69 + N = int(k["N"]) 70 + E = int(k["E"]) 73 71 pub = RSAPublicNumbers(E, N) 74 - priv = RSAPrivateNumbers(P, Q, D, rsa_crt_dmp1(D, P), rsa_crt_dmq1(D, Q), rsa_crt_iqmp(P, Q), pub) 75 - key = priv.private_key() 76 72 77 - if sys.argv[1] == "private": 78 - sys.stdout.write(key.private_bytes(Encoding.PEM, PrivateFormat.TraditionalOpenSSL, NoEncryption()).decode()) 73 + if mode == "private": 74 + D = int(k["D"]) 75 + P = int(k["Primes"][0]) 76 + Q = int(k["Primes"][1]) 77 + priv = RSAPrivateNumbers(P, Q, D, rsa_crt_dmp1(D, P), rsa_crt_dmq1(D, Q), rsa_crt_iqmp(P, Q), pub) 78 + sys.stdout.write(priv.private_key().private_bytes(Encoding.PEM, PrivateFormat.TraditionalOpenSSL, NoEncryption()).decode()) 79 79 else: 80 - sys.stdout.write(key.public_key().public_bytes(Encoding.PEM, PublicFormat.SubjectPublicKeyInfo).decode()) 80 + sys.stdout.write(pub.public_key().public_bytes(Encoding.PEM, PublicFormat.SubjectPublicKeyInfo).decode()) 81 81 ' 82 82 83 83 json_to_pem() {