diff --git a/src/index.html b/src/index.html index d7a2b7a..c9298a6 100644 --- a/src/index.html +++ b/src/index.html @@ -528,6 +528,34 @@

Datenschutzerklärung für diesen Mängelmelder

+
+
+ +
+ +
+ +
+ Public Key Infrastructure +
+ +
+ +
+
+ +
+ +
+ + + +
+ +
+ diff --git a/src/scss/chargy.scss b/src/scss/chargy.scss index 7881a28..8786100 100644 --- a/src/scss/chargy.scss +++ b/src/scss/chargy.scss @@ -268,6 +268,9 @@ body { font-family: monospace; font-size: 110%; margin-top: 3px; + background-color: rgb(192 192 192 / 30%); + padding: 6px 8px; + border-radius: 4px; } #sigHead { @@ -495,7 +498,7 @@ body { .signer { display: table-cell; padding: 2px 0px 2px 5px; - vertical-align: middle; + vertical-align: middle; font-size: 85%; } @@ -2046,13 +2049,20 @@ body { .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; + } + } } @@ -2102,6 +2112,7 @@ body { form { + flex-grow: 2; padding: 5px 20px 20px 20px; .label { @@ -2209,6 +2220,24 @@ body { } + #pkiDetails { + + display: none; + + .overlayText { + + .footer { + + .overlayRightButton { + visibility: hidden; + } + + } + + } + + } + } .fullScreen { diff --git a/src/ts/EMHCrypt01.ts b/src/ts/EMHCrypt01.ts index 7553e17..d7fdcd9 100644 --- a/src/ts/EMHCrypt01.ts +++ b/src/ts/EMHCrypt01.ts @@ -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) diff --git a/src/ts/chargy.ts b/src/ts/chargy.ts index e27f621..7aa67d3 100644 --- a/src/ts/chargy.ts +++ b/src/ts/chargy.ts @@ -38,12 +38,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(); private chargingPools = new Array(); @@ -60,19 +61,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; } @@ -239,7 +242,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); diff --git a/src/ts/chargyApp.ts b/src/ts/chargyApp.ts index 826ea96..ee5dbac 100644 --- a/src/ts/chargyApp.ts +++ b/src/ts/chargyApp.ts @@ -73,6 +73,8 @@ export class ChargyApp { private aboutScreenDiv: HTMLDivElement; private applicationHashDiv: HTMLDivElement; private applicationHashValueDiv: HTMLDivElement; + private softwareInfosDiv: HTMLDivElement; + private openSourceLibsDiv: HTMLDivElement; private chargingSessionScreenDiv: HTMLDivElement; private invalidDataSetsScreenDiv: HTMLDivElement; private inputButtonsDiv: HTMLDivElement; @@ -86,31 +88,31 @@ export class ChargyApp { private errorTextDiv: HTMLDivElement; private feedbackDiv: HTMLDivElement; + private showFeedbackSection: Boolean; + private feedbackMethodsDiv: HTMLDivElement; + private feedbackEMailAnchor: HTMLAnchorElement; + private feedbackHotlineAnchor: HTMLAnchorElement; + private showIssueTrackerButton: HTMLButtonElement; + private issueTrackerText: HTMLDivElement; + private chargingTariffDetailsDiv: HTMLDivElement; private chargingTariffDetailsLeftButton: HTMLButtonElement; - private chargingPeriodDetailsDiv: HTMLDivElement; - private chargingPeriodDetailsLeftButton: HTMLButtonElement; + private chargingPeriodDetailsDiv: HTMLDivElement; + private chargingPeriodDetailsLeftButton: HTMLButtonElement; private measurementsDetailsDiv: HTMLDivElement; private measurementsDetailsLeftButton: HTMLButtonElement; -// private measurementsDetailsButton: HTMLButtonElement; - private issueTrackerDiv: HTMLDivElement; - private privacyStatement: HTMLDivElement; - private showFeedbackSection: Boolean; - private feedbackMethodsDiv: HTMLDivElement; - private feedbackEMailAnchor: HTMLAnchorElement; - private feedbackHotlineAnchor: HTMLAnchorElement; - private showIssueTrackerButton: HTMLButtonElement; - private issueTrackerText: HTMLDivElement; - private sendIssueButton: HTMLButtonElement; + private issueTrackerDiv: HTMLDivElement; private issueTrackerLeftButton: HTMLButtonElement; - + private privacyStatement: HTMLDivElement; private showPrivacyStatement: HTMLButtonElement; private privacyStatementAccepted: HTMLInputElement; - private softwareInfosDiv: HTMLDivElement; - private openSourceLibsDiv: HTMLDivElement; + private sendIssueButton: HTMLButtonElement; + + private pkiDetailsDiv: HTMLDivElement; + private pkiDetailsLeftButton: HTMLButtonElement; //#endregion @@ -213,6 +215,12 @@ export class ChargyApp { this.issueTrackerDiv.style.display = 'none'; } + this.pkiDetailsDiv = document.getElementById('pkiDetails') as HTMLDivElement; + this.pkiDetailsLeftButton = this.pkiDetailsDiv.querySelector(".overlayLeftButton") as HTMLButtonElement; + this.pkiDetailsLeftButton.onclick = () => { + this.pkiDetailsDiv.style.display = 'none'; + } + this.fileInputButton = document.getElementById('fileInputButton') as HTMLButtonElement; this.pasteButton = document.getElementById('pasteButton') as HTMLButtonElement; @@ -224,12 +232,15 @@ export class ChargyApp { //#endregion - this.chargy = new Chargy(this.i18n, - this.UILanguage, - this.elliptic, - this.moment, - this.asn1, - this.base32Decode); + this.chargy = new Chargy( + this.i18n, + this.UILanguage, + this.elliptic, + this.moment, + this.asn1, + this.base32Decode, + this.showPKIDetails.bind(this) + ); //#region OnWindowResize @@ -630,6 +641,7 @@ export class ChargyApp { //#endregion + //#region (private) loadI18n() private async loadI18n() { try { @@ -647,6 +659,10 @@ export class ChargyApp { } } + //#endregion + + //#region (private) loadPackageJSON() + private async loadPackageJSON() { try { @@ -700,8 +716,7 @@ export class ChargyApp { } } - - + //#endregion //#region UpdateFeedbackSection() @@ -961,7 +976,7 @@ export class ChargyApp { //#endregion - //#region calcApplicationHash(...) + //#region calcApplicationHash (...) private async calcApplicationHash() { @@ -992,7 +1007,7 @@ export class ChargyApp { //#endregion - //#region checkApplicationHashSignature(...) + //#region checkApplicationHashSignature (...) private checkApplicationHashSignature(app: any, version: any, @@ -1064,7 +1079,7 @@ export class ChargyApp { //#endregion - //#region detectAndConvertContentFormat(FileInfos) + //#region detectAndConvertContentFormat (FileInfos) private async detectAndConvertContentFormat(FileInfos: Array|chargyInterfaces.IFileInfo|string) { @@ -1108,7 +1123,7 @@ export class ChargyApp { //#endregion - //#region showChargeTransparencyRecord(CTR) + //#region showChargeTransparencyRecord (CTR) private async showChargeTransparencyRecord(CTR: chargyInterfaces.IChargeTransparencyRecord) { @@ -1984,7 +1999,7 @@ export class ChargyApp { //#endregion - //#region showChargingSessionDetails + //#region showChargingSessionDetails (chargingSession) private async showChargingSessionDetails(chargingSession: chargyInterfaces.IChargingSession) { @@ -2715,7 +2730,7 @@ export class ChargyApp { //#endregion - //#region showChargingTariffDetails + //#region showChargingTariffDetails (measurementValue) private showChargingTariffDetails(measurementValue: chargyInterfaces.IChargingTariff) : void { @@ -2787,7 +2802,7 @@ export class ChargyApp { //#endregion - //#region showChargingPeriodDetails + //#region showChargingPeriodDetails (chargingPeriod) private showChargingPeriodDetails(chargingPeriod: chargyInterfaces.IChargingPeriod) : void { @@ -2859,7 +2874,7 @@ export class ChargyApp { //#endregion - //#region showMeasurementCryptoDetails + //#region showMeasurementCryptoDetails (measurementValue) private showMeasurementCryptoDetails(measurementValue: chargyInterfaces.IMeasurementValue) : void { @@ -2931,6 +2946,78 @@ export class ChargyApp { //#endregion + //#region showPKIDetails (pkiData) + + private showPKIDetails(pkiData: any) : void + { + + function doError(text: String) + { + errorDiv.innerHTML = ' ' + text; + introDiv.style.display = "none"; + } + + //#region Headline + + const headlineDiv = this.pkiDetailsDiv.querySelector('.headline') as HTMLDivElement; + const errorDiv = headlineDiv. querySelector('.error') as HTMLDivElement; + const introDiv = headlineDiv. querySelector('.intro') as HTMLDivElement; + errorDiv.innerHTML = ""; + introDiv.style.display = "block"; + + //#endregion + + // if (!measurementValue?.measurement || + // !measurementValue.method) + // { + // doError(this.chargy.GetLocalizedMessage("Unknown meter data record format!")); + // return; + // } + + //#region Show data and result on overlay + + this.pkiDetailsDiv.style.display = 'block'; + + // const dataDiv = this.overlayDiv.querySelector('.data') as HTMLDivElement; + // const cryptoDataDiv = dataDiv. querySelector('#cryptoData') as HTMLDivElement; + // const bufferDiv = dataDiv. querySelector('#buffer .value') as HTMLDivElement; + // const hashedBufferDiv = dataDiv. querySelector('#hashedBuffer .value') as HTMLDivElement; + // const publicKeyDiv = dataDiv. querySelector('#publicKey .value') as HTMLDivElement; + // const signatureExpectedDiv = dataDiv. querySelector('#signatureExpected .value') as HTMLDivElement; + + // cryptoDataDiv.innerHTML = ''; + // bufferDiv.innerHTML = ''; + // hashedBufferDiv.innerHTML = '0x00000000000000000000000000000000000'; + // publicKeyDiv.innerHTML = '0x00000000000000000000000000000000000'; + // signatureExpectedDiv.innerHTML = '0x00000000000000000000000000000000000'; + + //#endregion + + //#region Footer + + //const footerDiv = this.measurementsDetailsDiv.querySelector('.footer') as HTMLDivElement; + //const signatureCheckDiv = footerDiv. querySelector('#signatureCheck') as HTMLDivElement; + + //signatureCheckDiv.innerHTML = ''; + + //#endregion + + // measurementValue.method.ViewMeasurement(measurementValue, + // errorDiv, + // introDiv, + + // cryptoDataDiv, + // bufferDiv, + // hashedBufferDiv, + // publicKeyDiv, + // signatureExpectedDiv, + + // signatureCheckDiv); + + } + + //#endregion + } diff --git a/src/ts/chargyInterfaces.ts b/src/ts/chargyInterfaces.ts index 92ab0f7..70fe8b4 100644 --- a/src/ts/chargyInterfaces.ts +++ b/src/ts/chargyInterfaces.ts @@ -912,3 +912,5 @@ export interface IParkingTariff { signatures?: Array } + +export type ShowPKIDetailsFunction = (pkiData: any) => void;