Conversation
…ation Fixes: #42 Signed-off-by: Wiktor Kwapisiewicz <wiktor@metacode.biz>
Signed-off-by: Wiktor Kwapisiewicz <wiktor@metacode.biz>
Signed-off-by: Wiktor Kwapisiewicz <wiktor@metacode.biz>
signature parameter to verify for detached signatures verificationsignature and file parameters to verify for detached signatures verification
Signed-off-by: Wiktor Kwapisiewicz <wiktor@metacode.biz>
b892a67 to
ed158b5
Compare
|
@jinnatar I wonder if it'd be possible for you to test this PR with your code? I'd rather wait for your "ack" that this is exactly what you need before merging 😅 I'm happy to provide build instructions if necessary. |
|
There's probably something I'm slightly misunderstanding and is not clarified by the updated examples. I can't seem to be able to pass the output of
Full sample code: import os
import requests
from pysequoia import Cert, Sig, verify
base = "sigtest-artefacts/"
os.makedirs(base, exist_ok=True)
artefacts = [
"https://openbao.org/assets/openbao-gpg-pub-20240618.asc",
"https://github.com/openbao/openbao/releases/download/v2.2.1/bao_2.2.1_linux_amd64.deb.gpgsig",
"https://github.com/openbao/openbao/releases/download/v2.2.1/bao_2.2.1_linux_amd64.deb",
]
for artefact in artefacts:
filename = artefact.split("/")[-1]
if not os.path.isfile(base + filename):
with open(base + filename, "wb") as f, requests.get(artefact) as response:
f.write(response.content)
def get_certs(key_ids):
# key_ids is an array of required signing keys
print(f"For verification, we need these keys: {key_ids}")
return [cert]
cert = Cert.from_file(base + "openbao-gpg-pub-20240618.asc")
signature = Sig.from_file(base + "bao_2.2.1_linux_amd64.deb.gpgsig")
result = verify(
file=base + "bao_2.2.1_linux_amd64.deb", store=get_certs, signature=signature
)
print(result.valid_sigs) |
|
Oh, good point 😅 the existing code would take just a byte array but using Sig would be better. I'll adjust it (but it may take a while due to holiday season here). Thanks for testing. This is highly valuable! |
Signed-off-by: Wiktor Kwapisiewicz <wiktor@metacode.biz>
c91777c to
6a8f736
Compare
|
Okay, I've adjusted the code to take a If you could verify this again it'd be very happy 🙏 |
|
Yup, that's now working in a way that is logical at least to me, and allows me to implement what I was looking for! Thanks! |
|
That's great! I'll let it sit for a couple of days and release a new version. Thanks for help! |
This PR adds two parameters to
verifythat can be used interchangeably:signature- for holding a detached signature, when this is given thebytesparameter is considered raw data for verification (instead of an OpenPGP message).file- used instead ofbytesfor passing file name. This is especially useful for large files that would have to be loaded in memory when usingbytes.Fixes: #42