File: plain-verify.py

package info (click to toggle)
endesive 2.18.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,540 kB
  • sloc: python: 17,934; java: 1,000; xml: 800; sh: 306; javascript: 118; makefile: 8
file content (28 lines) | stat: -rwxr-xr-x 823 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env vpython3
# *-* coding: utf-8 *-*
from endesive import plain


def main():
    trusted_cert_pems = (open('ca/demo2_ca.crt.pem', 'rb').read(),)
    datau = open('plain-unsigned.txt', 'rb').read()
    for fname in (
            'plain-ssl-signed-attr.txt',
            'plain-ssl-signed-noattr.txt',
            'plain-signed-attr.txt',
            'plain-signed-noattr.txt',
            'plain-signed-pss.txt',
    ):
        print('*' * 20, fname)
        try:
            datas = open(fname, 'rb').read()
        except FileNotFoundError:
            print("no such file", fname)
            continue
        (hashok, signatureok, certok) = plain.verify(datas, datau, trusted_cert_pems)
        print('signature ok?', signatureok)
        print('hash ok?', hashok)
        print('cert ok?', certok)


main()