Skip to content

Commit

Permalink
wip: add imagebuilder
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Spooren <[email protected]>
  • Loading branch information
aparcar authored and Paul Spooren committed Oct 13, 2022
1 parent 0c09512 commit d103d00
Show file tree
Hide file tree
Showing 8 changed files with 624 additions and 425 deletions.
444 changes: 101 additions & 343 deletions asu/build.py

Large diffs are not rendered by default.

47 changes: 0 additions & 47 deletions asu/common.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import base64
import hashlib
import json
import struct
from pathlib import Path

import nacl.signing
import requests
from flask import current_app

Expand Down Expand Up @@ -129,46 +125,3 @@ def get_packages_hash(packages: list) -> str:
str: hash of `req`
"""
return get_str_hash(" ".join(sorted(list(set(packages)))), 12)


def fingerprint_pubkey_usign(pubkey: str) -> str:
"""Return fingerprint of signify/usign public key
Args:
pubkey (str): signify/usign public key
Returns:
str: string containing the fingerprint
"""
keynum = base64.b64decode(pubkey.splitlines()[-1])[2:10]
return "".join(format(x, "02x") for x in keynum)


def verify_usign(sig_file: Path, msg_file: Path, pub_key: str) -> bool:
"""Verify a signify/usign signature
This implementation uses pynacl
Args:
sig_file (Path): signature file
msg_file (Path): message file to be verified
pub_key (str): public key to use for verification
Returns:
bool: Sucessfull verification
Todo:
Currently ignores keynum and pkalg
"""
pkalg, keynum, pubkey = struct.unpack("!2s8s32s", base64.b64decode(pub_key))
sig = base64.b64decode(sig_file.read_text().splitlines()[-1])

pkalg, keynum, sig = struct.unpack("!2s8s64s", sig)

verify_key = nacl.signing.VerifyKey(pubkey, encoder=nacl.encoding.RawEncoder)
try:
verify_key.verify(msg_file.read_bytes(), sig)
return True
except nacl.exceptions.CryptoError:
return False
Loading

0 comments on commit d103d00

Please sign in to comment.