OSGP / Documentation

This repository contains documentation for the Open Smart Grid Platform project. This repository is built as a GitBook, therefore all content has to be written using markdown syntax. See the latest GitBook:
https://documentation.gxf.lfenergy.org/
Apache License 2.0
24 stars 15 forks source link

implementing OSLP protocol #219

Closed winy57 closed 4 years ago

winy57 commented 4 years ago

Hello,

We are currently developing an application to communicate with connected objects (electric meters currently, and soon a public lighting box).

We are already working with WM Systems who presented us their product which embeds the OSLP protocol. However, we do not wish to use the platform you propose, because it would duplicate our application which is already used for electrical meters.

We would therefore like to implement the OSLP protocol in our application in order to be able to communicate with the WM Systems box.

I was able to successfully install the platform and I was able to use the simulator to create an SSLD. Now I would like to make the SSLD of the simulator communicate with our application. If I understood correctly, the SSLD of the simulator acts as a TCP server (127.0.0.1:12122) and I need to send it a message. Will the message also have to be signed even with the simulator? I found the public key in the database, but how can I retrieve the private key?

So I integrated the oslp.proto file and I am currently developing the OSLP envelope. The deviceId matches SSLD_000-00-01? and I just do a getBytes() on it? How do I get the manufacturerId though?

Concerning the sequence number, that's what avoids replay?

Thanks, Mickael

kevinsmeets commented 4 years ago

Hello Mickael,

the OSLP device simulator listens on port 12122, which is the default port for the OSLP implementation. All exchanged messages have to be signed with ECDSA key pairs. Example key pairs available are here: https://github.com/OSGP/Config/tree/development/certificates/oslp . The simulator uses:

sign key simulator: oslp_sim_ecdsa_private.der (or .pem)
verify key platform: oslp_test_ecdsa_public.der (or .pem)

The OSGP implementation uses:

sign key platform: oslp_test_ecdsa_private.der (or .pem)
verify key simulator: oslp_sim_ecdsa_public.der (or .pem)

The verify key simulator is the public key you found in the database.

Messages sent to the simulator have to be signed using sign key platform. The simulator will verify the message using verify key platform.

Messages sent to the platform have to be signed using sign key simulator. The platform will verify the message using verify key simulator.

The deviceId in the OSLP envelope is 12 bytes, the first 2 bytes are the manufacturerId, the next 10 bytes are the identification of the device. The 10 bytes of the device identification can be converted to a Base64 string.

See the current implementation in Java for the order and sizes of the OSLP envelope content: https://github.com/OSGP/open-smart-grid-platform/blob/development/osgp/protocol-adapter-oslp/oslp/src/main/java/org/opensmartgridplatform/oslp/OslpEnvelope.java or have a look at the documentation: http://documentation.opensmartgridplatform.org/Protocols/OSLP/index.html .

The sequence number of the OSLP specification is indeed used for replay attack prevention. The sequence number is initialized with a random value and incremented for each exchanged message.

winy57 commented 4 years ago

Hello Kevin and thank you for all the details !

I have one more question... In order for the platform to recognize a device, you have to register and then confirm it. And from what I could see in the code, it's this manipulation that allows the creation of a random uid and a random number sequence.

Is it also this process that you have to operate in real life (i.e. with a real SSLD, without a simulator)?

Thanks, Mickael

kevinsmeets commented 4 years ago

Yes, I think the firmware of the device is not going to allow message exchange without these registration steps which contain these random values. The SSLD will send a RegisterDeviceRequest (which needs a correct RegisterDeviceResponse containing the value for randomDevice obtained from the request and the value randomPlatform). Then the SSLD will send a ConfirmRegisterDeviceRequest containing both values (which needs a correct ConfirmRegiterDeviceResponse). These registration steps have to be successful before other messages can be exchanged between SSLD and OSGP (or your OSLP client implementation).

MMaiero commented 2 years ago

@winy57 Hello, we are currently considering embedding OSLP protocol in Java and came to this issue. Did you succeed in this effort? Can you give us some guidance? Thanks