Skip to content

Commit

Permalink
Merge pull request #76 from nokia/ian11
Browse files Browse the repository at this point in the history
Added PCR Schema printing to u10, and a10.asvr.pcrschemaS functionality
  • Loading branch information
iolivergithub authored Feb 12, 2022
2 parents 84a92be + 6b9bb29 commit 106bc83
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 19 deletions.
2 changes: 1 addition & 1 deletion a10/a10.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: a10
Version: 2022.2.12.1
Version: 2022.2.12.2
Summary: Attestation Services Engine and Libraries
Home-page: https://github.com/nokia/AttestationEngine
Author: Ian Oliver
Expand Down
2 changes: 1 addition & 1 deletion a10/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setuptools.setup(
name="a10",
version="2022.2.12.1",
version="2022.2.12.2",
author="Ian Oliver",
author_email="ian.oliver@nokia-bell-labs.com",
description="Attestation Services Engine and Libraries",
Expand Down
16 changes: 14 additions & 2 deletions u10/blueprints/claims.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,22 @@ def claimprettyprintPCRs(item_id):
pcrlist[p]=ps



return render_template("claimprettyprint/pcrs.html", cla=c,pcrlist=pcrlist)
#get the pcr schema, we check that
#claim.header.element.tpm2.tpm0.pcrschema exists
#this returns None if no schema is included

pcrschema=c.get("header").get("element").get("tpm2").get("tpm0").get("pcrschema")
if pcrschema==None:
pcrschema="-"

return render_template("claimprettyprint/pcrs.html", cla=c,pcrlist=pcrlist,pcrschema=pcrschema)







@claims_blueprint.route("/claim/prettyprint/quote/<item_id>", methods=["GET"])
def claimprettyprintQuote(item_id):
c = a10.asvr.claims.getClaim(item_id).msg()
Expand Down
42 changes: 27 additions & 15 deletions u10/templates/claimprettyprint/pcrs.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,50 @@
{% block content %}
<h2>PCRs Pretty Print</h2>
Claim: <a href=/claim/{{ cla.itemid }}>{{ cla.itemid }}</a>


<hr/>
<hr />
<h4>PCR Banks utilised: {% for b in pcrlist.keys() %}
<span class="badge bg-primary">{{ b }}</span>
{% endfor %}</h4>

<hr/>
<span class="badge bg-primary">{{ b }}</span>
{% endfor %} &nbsp;

{% if pcrschema != "-" %}
PCR Schema is <span class="badge bg-primary">{{ pcrschema }}</span>
{% else %}
<span class="badge bg-danger">No PCR schema specified for this claim</span>
{% endif %}
</h4>
<hr />
<div>
{% set p = resolvePCRSchema( pcrschema ) %}

{% for b in pcrlist.keys() %}
<h3>Bank: {{ b }}</h3>
<table class="table table-striped .table-sm">
<tbody id="pcrtable">
{% for r in pcrlist[b] %}
{% set h = resolveHash( r[1] ) %}
<tr>
<td> <b>{{ r[0] }}</b></td>
{% set h = resolveHash( r[1] ) %}
<td>
{% if h == "-" %}
<a href="/new/hash/{{ r[1] }}"> <i class="fa fa-user-plus"></i> </a>
{% else %}
{{ h.short }}
{{ h.short }}
{% endif %}
</td>
<td> <i>{{ r[1] }}</i></td>
<td>
{% if h == "-" %}
-
{% else %}
{{ h.long }}
<td>
<!--
OK, this needs a bit of explaining...it turns out that r[0] is cast to an int by flask jinja
So, to convert it to a string, we can concatenate to an empty string using the the jinja concat ~ operator
Turns out there's a host of useful operators here: https://jinja.palletsprojects.com/en/2.11.x/templates/#list-of-builtin-filters
-->
{% if p != "-" %}
{{ p["pcrs"][b]["" ~ r[0]] }}
<br />
{% endif %}

{% if h != "-" %}
<i>{{ h.long }}</i>
{% endif %}
</td>
</tr>
Expand All @@ -46,5 +59,4 @@ <h3>Bank: {{ b }}</h3>
</tbody>
</table>
{% endfor %}

{% endblock %}
13 changes: 13 additions & 0 deletions u10/u10.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import a10.structures.constants
import a10.asvr.hashes
import a10.asvr.pcrschemas

u10 = Flask(__name__)

Expand Down Expand Up @@ -63,6 +64,18 @@ def resolveHash(h):
return "-"
return dict(resolveHash=resolveHash)

@u10.context_processor
def resolvePCRSchema_processor():
def resolvePCRSchema(n):
#print("Calling context processor with ",n,b,p)
r = a10.asvr.pcrschemas.getPCRSchema(n)
print("pcrschema ",r.rc())
if r.rc()==a10.structures.constants.SUCCESS:
return r.msg()
else:
return "-"
return dict(resolvePCRSchema=resolvePCRSchema)

#
# Handle errors, censorship and cups to tea
#
Expand Down

0 comments on commit 106bc83

Please sign in to comment.