Skip to content

Commit

Permalink
Add PKI details screen
Browse files Browse the repository at this point in the history
  • Loading branch information
ahzf committed May 5, 2024
1 parent a8e7350 commit eca6166
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 65 deletions.
37 changes: 33 additions & 4 deletions src/css/chargy.scss
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@
font-family: monospace;
font-size: 110%;
margin-top: 3px;
background-color: rgb(192 192 192 / 30%);
padding: 6px 8px;
border-radius: 4px;
}

#sigHead {
Expand Down Expand Up @@ -495,7 +498,7 @@
.signer {
display: table-cell;
padding: 2px 0px 2px 5px;
vertical-align: middle;
vertical-align: middle;
font-size: 85%;
}

Expand Down Expand Up @@ -2046,13 +2049,20 @@
.signatures {

display: flex;
padding: 3px 0px 0px 0px;
padding-left: 5px;
font-family: sans-serif;
font-size: 70%;
color: #6d6d6d;

i {
padding: 0px 3px 0px 10px;
.signature {

padding: 3px 7px 2px 5px;
cursor: zoom-in;

i {
padding-right: 4px;
}

}

}
Expand Down Expand Up @@ -2102,6 +2112,7 @@

form {

flex-grow: 2;
padding: 5px 20px 20px 20px;

.label {
Expand Down Expand Up @@ -2209,6 +2220,24 @@

}

#pkiDetails {

display: none;

.overlayText {

.footer {

.overlayRightButton {
visibility: hidden;
}

}

}

}

}

.fullScreen {
Expand Down
35 changes: 34 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,41 @@ <h1>Datenschutzerklärung für diesen Mängelmelder</h1>
</div>
</div>

</div>
<div id="pkiDetails" class="overlay">
<div class="overlayText">

<div class="headline">

<div class="error"></div>

<div class="intro">
Public Key Infrastructure
</div>

</div>

<div class="data">
</div>

<div class="spacer">

</div>

<div class="footer">

<button class="overlayLeftButton"><i class="fas fa-arrow-alt-circle-left"></i></button>

<div id="signatureCheck"></div>

<button class="overlayRightButton"><i class="fas fa-arrow-alt-circle-right"></i></button>

</div>

</div>

</div>

</div>

<script type="text/javascript">

Expand Down
32 changes: 22 additions & 10 deletions src/ts/EMHCrypt01.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,16 +366,28 @@ export class EMHCrypt01 extends ACrypt {
try
{

const signatureDiv = PublicKeyDiv?.parentElement?.children[3]?.appendChild(document.createElement('div'));

if (signatureDiv != null)
signatureDiv.innerHTML = await this.chargy.CheckMeterPublicKeySignature(measurementValue.measurement.chargingSession?.chargingStation,
measurementValue.measurement.chargingSession?.EVSE,
//@ts-ignore
measurementValue.measurement.chargingSession.EVSE.meters[0],
//@ts-ignore
measurementValue.measurement.chargingSession.EVSE.meters[0].publicKeys[0],
signature);
const signatureDiv = PublicKeyDiv.parentElement?.children[3]?.appendChild(document.createElement('div'));

if (signatureDiv)
{

signatureDiv.classList.add("signature");

signatureDiv.innerHTML = await this.chargy.CheckMeterPublicKeySignature(
measurementValue.measurement.chargingSession?.chargingStation,
measurementValue.measurement.chargingSession?.EVSE,
//@ts-ignore
measurementValue.measurement.chargingSession.EVSE.meters[0],
//@ts-ignore
measurementValue.measurement.chargingSession.EVSE.meters[0].publicKeys[0],
signature
);

signatureDiv.onclick = () => {
this.chargy.showPKIDetails({});
}

}

}
catch (exception)
Expand Down
43 changes: 23 additions & 20 deletions src/ts/chargy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ export class Chargy {

//#region Data

public readonly i18n: any;
public readonly UILanguage: string;
public readonly elliptic: any;
public readonly moment: any;
public readonly asn1: any;
public readonly base32Decode: any;
public readonly i18n: any;
public readonly UILanguage: string;
public readonly elliptic: any;
public readonly moment: any;
public readonly asn1: any;
public readonly base32Decode: any;
public readonly showPKIDetails: chargyInterfaces.ShowPKIDetailsFunction;

private chargingStationOperators = new Array<chargyInterfaces.IChargingStationOperator>();
private chargingPools = new Array<chargyInterfaces.IChargingPool>();
Expand All @@ -59,19 +60,21 @@ export class Chargy {

//#endregion

constructor(i18n: any,
UILanguage: string,
elliptic: any,
moment: any,
asn1: any,
base32Decode: any) {

this.i18n = i18n;
this.UILanguage = UILanguage;
this.elliptic = elliptic;
this.moment = moment;
this.asn1 = asn1;
this.base32Decode = base32Decode;
constructor(i18n: any,
UILanguage: string,
elliptic: any,
moment: any,
asn1: any,
base32Decode: any,
ShowPKIDetails: chargyInterfaces.ShowPKIDetailsFunction) {

this.i18n = i18n;
this.UILanguage = UILanguage;
this.elliptic = elliptic;
this.moment = moment;
this.asn1 = asn1;
this.base32Decode = base32Decode;
this.showPKIDetails = ShowPKIDetails;

}

Expand Down Expand Up @@ -238,7 +241,7 @@ export class Chargy {
// update(Input, 'utf8').
// digest('hex');

var result = new this.elliptic.ec('secp256k1').
var result = new this.elliptic.ec('secp256r1').
keyFromPublic(signature.publicKey, 'hex').
verify (sha256value,
signature.signature);
Expand Down
Loading

0 comments on commit eca6166

Please sign in to comment.