"key": "FiscalMetering.PublicKey",
"readonly": true,
"value": "3056301006072a8648ce3d020106052b8104000a03420004460a02ba2766d9c44f023ecc0e4e58644a87add1aadd6317e5fe4dccdb29b163a01d8a6297c84bc530f86431e92f8d46ab37830247c05cbd92fac252929e7f61"
+ },
+ {
+ "key": "FiscalMetering.SigningMethod",
+ "readonly": true,
+ "value": "ECDSA-secp256k1-SHA256"
}
]
},
encodingMethod: EncodingMethodEnumType
publicKey: string
signedMeterData: string
- signingMethod: SigningMethodEnumType
+ signingMethod: '' | SigningMethodEnumType
}
export interface SignedMeterDataParams {
const simulatedSignature = createHash('sha256').update(JSON.stringify(ocmfPayload)).digest('hex')
+ // OCMF includes the signing algorithm in the SA field of signedMeterData.
+ // Per OCA Application Note Table 11: "If it is already included in the
+ // signedMeterData, then this SHALL be an empty string."
const ocmfString = `OCMF|${JSON.stringify(ocmfPayload)}|{"SA":"${resolvedSigningMethod}","SD":"${simulatedSignature}"}`
return {
encodingMethod: DEFAULT_ENCODING_METHOD,
publicKey: publicKeyHex != null ? buildPublicKeyValue(publicKeyHex) : '',
signedMeterData: Buffer.from(ocmfString).toString('base64'),
- signingMethod: resolvedSigningMethod,
+ signingMethod: '',
}
}
type OCPP16SignedMeterValue,
OCPP16VendorParametersKey,
OCPPVersion,
- SigningMethodEnumType,
} from '../../../../src/types/index.js'
import { standardCleanup, withMockTimers } from '../../../helpers/TestLifecycleHelpers.js'
import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
assert.strictEqual(typeof parsed.signedMeterData, 'string')
assert.strictEqual(typeof parsed.publicKey, 'string')
assert.strictEqual(parsed.encodingMethod, EncodingMethodEnumType.OCMF)
- assert.strictEqual(parsed.signingMethod, SigningMethodEnumType.ECDSA_secp256r1_SHA256)
+ assert.strictEqual(parsed.signingMethod, '')
})
})
OCPPVersion,
PublicKeyWithSignedMeterValueEnumType,
type SampledValueTemplate,
- SigningMethodEnumType,
} from '../../../../src/types/index.js'
import { Constants } from '../../../../src/utils/index.js'
import { standardCleanup } from '../../../helpers/TestLifecycleHelpers.js'
)
assert.ok(sampledValue.signedMeterValue != null)
- assert.strictEqual(
- sampledValue.signedMeterValue.signingMethod,
- SigningMethodEnumType.ECDSA_secp256r1_SHA256
- )
+ assert.strictEqual(sampledValue.signedMeterValue.signingMethod, '')
assert.strictEqual(sampledValue.signedMeterValue.encodingMethod, EncodingMethodEnumType.OCMF)
})
) as OCPP20SampledValue | undefined
assert.notStrictEqual(energySampledValue, undefined)
assert.ok(energySampledValue?.signedMeterValue != null)
- assert.strictEqual(
- energySampledValue.signedMeterValue.signingMethod,
- SigningMethodEnumType.ECDSA_secp256r1_SHA256
- )
+ assert.strictEqual(energySampledValue.signedMeterValue.signingMethod, '')
assert.strictEqual(
energySampledValue.signedMeterValue.encodingMethod,
EncodingMethodEnumType.OCMF
EncodingMethodEnumType,
MeterValueContext,
MeterValueUnit,
- SigningMethodEnumType,
} from '../../../src/types/index.js'
const DEFAULT_PARAMS: SignedMeterDataParams = {
assert.ok(decoded.startsWith('OCMF|'))
})
- await it('should set signingMethod to ECDSA-secp256r1-SHA256', () => {
+ await it('should set signingMethod to empty string per OCA spec when using OCMF', () => {
const result = generateSignedMeterData(DEFAULT_PARAMS)
- assert.strictEqual(result.signingMethod, SigningMethodEnumType.ECDSA_secp256r1_SHA256)
+ assert.strictEqual(result.signingMethod, '')
})
await it('should set encodingMethod to OCMF', () => {