Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ung 1067 verfication #17

Open
wants to merge 70 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
0a203d7
change logging
UBOK19 Mar 3, 2021
7658673
separate unpacking and verifying messages
UBOK19 Mar 3, 2021
08aa451
adapt tests to changes
UBOK19 Mar 3, 2021
8ba781a
add proper backend response verification
UBOK19 Mar 3, 2021
69db333
rearranged code, added support for several identities to protocol impl
Mar 24, 2021
d19d4b6
comments (FIXME) do not unpack before signature is verified
Mar 24, 2021
85789e4
FIXME do not exit from client methods. throw exception and handle/log…
Mar 24, 2021
57d68a5
fixup! FIXME do not exit from client methods. throw exception and han…
Mar 24, 2021
5cd5637
add a function to split up a upp-msgpack into the message and the sig…
UBOK19 Mar 29, 2021
f72cecc
do not unpack the upp during verification
UBOK19 Mar 29, 2021
f1d12dc
do not unpack a upp before verification
UBOK19 Mar 29, 2021
8f67a1f
move pack example and extend it
UBOK19 Jun 28, 2021
653c5cd
add script to dump keystore contents
UBOK19 Jun 28, 2021
a770691
move verification example and extend it
UBOK19 Jun 28, 2021
95dd8f7
add script to send data and key registration upps
UBOK19 Jun 28, 2021
3f92456
move unpacker
UBOK19 Jun 28, 2021
670d7fa
add script to request anchoring status of an UPP
UBOK19 Jun 28, 2021
c783b00
distinguish between v1/v2 upps when splitting off the signature
UBOK19 Jun 28, 2021
0e6d2d2
fix tests
UBOK19 Jun 28, 2021
b8a614b
add a script to send data to the uBirch Simple Data Service
UBOK19 Jul 1, 2021
5b90291
fix old comment
UBOK19 Jul 1, 2021
caed463
only print anchoring information if the UPP is anchored
UBOK19 Jul 1, 2021
53bab4f
move and extend data verifier script
UBOK19 Jul 1, 2021
b960adc
fix result displaying
UBOK19 Jul 1, 2021
f0ec062
add ability to serialize json before creating the hash for the UPP
UBOK19 Jul 1, 2021
5fc0190
fix invalid indentation
UBOK19 Jul 2, 2021
3775c12
fix parameter description
UBOK19 Jul 2, 2021
25a15fb
add documentation for some examples
UBOK19 Jul 2, 2021
4636086
remove old comment
UBOK19 Jul 2, 2021
c47c537
fix typo
UBOK19 Jul 2, 2021
2bec84b
add documentation for keystore dumper script
UBOK19 Jul 2, 2021
887a82a
Reviewed and corrected EXAMPLES.md
Jul 5, 2021
4b58c55
.
UBOK19 Jul 6, 2021
e7812ab
fix incomplete toc
UBOK19 Jul 7, 2021
44d64a2
test-identity try to solve broken reference
Jul 8, 2021
5c6debc
solve broken reference links
Jul 8, 2021
6b48d13
add option to only generate data hash without verifying it
UBOK19 Sep 4, 2021
76c7ce8
fix typo in usage info
UBOK19 Oct 12, 2021
701a60c
add hashlink functionality to data verifier and upp creator scripts
UBOK19 Oct 12, 2021
d0d510c
print used hashing method to prevent confusion
UBOK19 Oct 15, 2021
06b1b44
update the readme to have some info about hashlink
UBOK19 Oct 15, 2021
ec56fad
add ability to read hex encoded upps as input to the upp verifier
UBOK19 Oct 21, 2021
f0d94e8
add hex-input support for the anchoring status script
UBOK19 Nov 7, 2021
ede1d65
add a script to check chains of upps (upp-chaining)
UBOK19 Nov 7, 2021
b33e3a6
add docs for the chain-checker script
UBOK19 Nov 7, 2021
56bff97
adapt changes from review to the readme
UBOK19 Nov 16, 2021
71a6a1c
include changes from review
UBOK19 Nov 16, 2021
2c59f53
[from review] replace old print statement with logger.x
UBOK19 Nov 16, 2021
9c3027e
initialize ishex and ishex_str in __init__ before using it in setup_a…
UBOK19 Nov 16, 2021
f4cb6e1
adapt changes from review
UBOK19 Nov 16, 2021
725ec4b
adapt changes from review
UBOK19 Nov 16, 2021
525e282
Merge pull request #14 from ubirch/UNG-2711
Nov 16, 2021
bda1dae
add note about which endpoint to use for verifiaction
UBOK19 Feb 5, 2022
b37b50b
replace the keystore dumper with a more capable script
UBOK19 Feb 20, 2022
e4d882c
implement the key service example script
UBOK19 Feb 20, 2022
3e1ee23
update the readme
UBOK19 Feb 20, 2022
0cb1191
Merge pull request #16 from ubirch/keyservice-example-script
UBOK19 Apr 7, 2022
e6e6c0c
fix issues from review
UBOK19 Apr 7, 2022
7207e82
[bugfix] used non existent function
UBOK19 Apr 7, 2022
d0dc0ca
replace demo key with dev key
UBOK19 Apr 7, 2022
d0bfaf8
added NOTE for environment
Apr 7, 2022
2d67ded
add ecdsa support to the keystore
UBOK19 Apr 8, 2022
8b6da75
add ecdsa key support to the upp generator example
UBOK19 Apr 8, 2022
31cbc69
update the keystore tool to work with ecdsa
UBOK19 Apr 8, 2022
28c08dd
add not implemented exception when trying to generate keyreg UPPs wit…
UBOK19 Apr 8, 2022
5d3bc46
add a tool to (generate+)register ecdsa keys using X.509 certificates
UBOK19 Apr 8, 2022
04717e4
implement an option to set the ubirch environment
UBOK19 Apr 8, 2022
f5766a4
add documentation for the x509 registrator to
UBOK19 Apr 8, 2022
c01e586
make the verifier able to work with ecdsa
UBOK19 Apr 8, 2022
2079743
add a debug logging statement
UBOK19 Apr 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
512 changes: 512 additions & 0 deletions examples/EXAMPLES.md

Large diffs are not rendered by default.

145 changes: 145 additions & 0 deletions examples/data-sender.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import sys
import logging
import argparse
import msgpack
import requests
import binascii
import uuid

import ubirch


DEFAULT_ENV = "dev"


logging.basicConfig(format='%(asctime)s %(name)20.20s %(funcName)20.20s() %(levelname)-8.8s %(message)s', level=logging.INFO)
logger = logging.getLogger()


class Main:
def __init__(self):
self.argparser : argparse.ArgumentParser = None
self.args : argparse.Namespace = None

self.uuid_str : str = None
self.uuid : uuid.UUID = None
self.auth : str = None
self.env : str = None
self.input : str = None

self.api : ubirch.API = None

# initialize the argument parser
self.setup_argparse()

return

def setup_argparse(self):
self.argparser = argparse.ArgumentParser(
description="Send some data to the uBirch Simple Data Service",
epilog="Note that the input data should follow this pattern: "
"{\"timestamp\": TIMESTAMP, \"uuid\": \"UUID\", \"msg_type\": 0, \"data\": DATA, \"hash\": \"UPP_HASH\"}. "
"For more information take a look at the EXAMPLES.md file."
)

self.argparser.add_argument("uuid", metavar="UUID", type=str,
help="UUID to work with; e.g.: 56bd9b85-6c6e-4a24-bf71-f2ac2de10183"
)
self.argparser.add_argument("auth", metavar="AUTH", type=str,
help="uBirch device authentication token, e.g.: 12345678-1234-1234-1234-123456789abc (this is NOT the UUID)"
)
self.argparser.add_argument("--env", "-e", metavar="ENV", type=str, default=DEFAULT_ENV,
help="environment to operate in; dev, demo or prod (default: %s)" % DEFAULT_ENV
)
self.argparser.add_argument("input", metavar="INPUT", type=str,
help="data to be sent to the simple data service"
)

return

def process_args(self) -> bool:
# parse cli arguments (exists on err)
self.args = self.argparser.parse_args()

# get all needed args
self.uuid_str = self.args.uuid
self.auth = self.args.auth
self.env = self.args.env
self.input = self.args.input

# process the uuid
try:
self.uuid = uuid.UUID(hex=self.uuid_str)
except Exception as e:
logger.error("Invalid UUID: \"%s\"" % self.uuid_str)
logger.exception(e)

return False

# validate env
if self.env.lower() not in ["dev", "demo", "prod"]:
logger.error("Invalid value for --env: \"%s\"!" % self.env)

return False

return True

def init_api(self) -> bool:
try:
# initialize the uBirch api
self.api = ubirch.API(env=self.env, debug=True)
self.api.set_authentication(self.uuid, self.auth)
except Exception as e:
logger.exception(e)

return False

return True

def send_data(self) -> bool:
try:
r = self.api.send_data(self.uuid, self.input.encode())

# check the response
if r.status_code == 200:
logger.info("Successfully sent all data to the Simple Data Service! (%d)" % r.status_code)
else:
logger.error("Failed to send data to the Simple Data Service! (%d)" % r.status_code)
logger.error(r.content)
except Exception as e:
logger.exception(e)

return False

return True

def run(self):
# process all args
if self.process_args() != True:
logger.error("Errors occured during argument processing - exiting!\n")

self.argparser.print_usage()

return 1

# initialize the api
if self.init_api() != True:
logger.error("Errors occured while initializing the uBirch API - exiting!\n")

self.argparser.print_usage()

return 1

# send data
if self.send_data() != True:
logger.error("Errors occured while sending data to the simple data service - exiting!\n")

self.argparser.print_usage()

return 1

return 0


if __name__ == "__main__":
sys.exit(Main().run())
Loading