Hi,
I'm developing a smart meter, and referencing this open source code.
I've tested this code with parameters of 9.2.4.8.4 example in Green Book 7 as following:
Invocation counter is contained in last 4 bytes of AAD field(but I was wrong to comment //IV, Sorry), and I've downloaded source code at 2017-3-24 from Github.
I've thought that there's a problem of parametering gcm.
In the book, only authentication does not contain plaintext, but GXDLMSChipperingStream.Write(byte[]) requires plaintext. I've tested with non-plaintext (new byte[]{}), but result is wrong, too.
Maybe other problem with my parameterizing?
Mr. kurumi, Please help me to get the correct result.
Thank you in advance sincerely.
Hi, Mr. kurumi.
I've tested with 3 Security of Authentication, Encryption, Authentication_Encryption.
And the results of Encryption, Authentication_Encryption were correct.
Only Authentication's result was wrong.
Could you tell me why this happened?
================ SOLVED !!!! ==================
I'm very sorry to annoy you about this problem.
I've missed that if Security is Authentication, MUST have not to call Write(byte[]).
The problem is solved.
Thank you for you attention to me.
Please help me in advance.
hello :
twinkle__star
I have the same problem with kurumi at work .i have see you tell kurumi "http://www.gurux.fi/GuruxDLMSTranslator?pdu=C30181000F0000280000FF01010…; now i want to the soure codes of aes_gmac,can you give me,my email :[Email removed by Admin] Thank you twinkle__star.
Wish best Regards zhihong zeng.
Dear Mikko
I must be making some dumb mistake but I have several times on GuruX Translator .. and ...
The reply for server challenge is correct.
But the reply for the target challenge does not come out to be correct ...
System Title: 4D4D4D0000BC614E
Invocation Counter 01234567
Challenge: 4B35366956616759
Expected Challenge String: FE 14 66 AF B3 DB CD 4F 93 89 E2 B7
GuruX generated Challenge String: 55 C8 77 21 3C D8 0F 7C C4 13 7E 2E
GMAC
Hi,
Do you have latest version from source codes? Then check your Invocation counter. I do not have Blue Book here but in my mind it's reversed.
BR,
Mikko
Invocation counter is
Invocation counter is contained in last 4 bytes of AAD field(but I was wrong to comment //IV, Sorry), and I've downloaded source code at 2017-3-24 from Github.
I've thought that there's a problem of parametering gcm.
In the book, only authentication does not contain plaintext, but GXDLMSChipperingStream.Write(byte[]) requires plaintext. I've tested with non-plaintext (new byte[]{}), but result is wrong, too.
Maybe other problem with my parameterizing?
Mr. kurumi, Please help me to get the correct result.
Thank you in advance sincerely.
GMAC
Hi,
I check this from Green Book. If I set parameters from the GB 8-2 I get right reply.
target.Ciphering.SystemTitle = Helpers.HexToBytes("4D4D4D0000000001");
server.Ciphering.SystemTitle = Helpers.HexToBytes("4D4D4D0000BC614E");
//Invocation counter
target.Ciphering.InvocationCounter = 0x00000001;
server.Ciphering.InvocationCounter = 0x01234567;
target.Ciphering.BlockCipherKey = Helpers.HexToBytes("000102030405060708090A0B0C0D0E0F");
server.Ciphering.BlockCipherKey = Helpers.HexToBytes("000102030405060708090A0B0C0D0E0F");
target.Ciphering.AuthenticationKey = Helpers.HexToBytes("D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF");
server.Ciphering.AuthenticationKey = Helpers.HexToBytes("D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF");
target.Authentication = Authentication.HighGMAC;
target.CtoSChallenge = Helpers.HexToBytes("4B35366956616759");
server.StoCChallenge = Helpers.HexToBytes("503677524A323146");
http://www.gurux.fi/GuruxDLMSTranslator?pdu=C30181000F0000280000FF01010…
Hi, Mr. kurumi.
Hi, Mr. kurumi.
I've tested with 3 Security of Authentication, Encryption, Authentication_Encryption.
And the results of Encryption, Authentication_Encryption were correct.
Only Authentication's result was wrong.
Could you tell me why this happened?
Source Code Here.
Source Code Here.
byte[] block_cipher_key = StringToByteArray("000102030405060708090A0B0C0D0E0F");
byte[] authentication_key = StringToByteArray("D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF");
byte[] system_title = StringToByteArray("4D4D4D0000BC614E");
uint frame_counter = 0x01234567;
byte[] plain_text = StringToByteArray("4B35366956616759");
byte[] aad = GetAuthenticatedData(Security.Authentication, authentication_key, plain_text);
GXDLMSChipperingStream gcm = new GXDLMSChipperingStream(
Security.Authentication,
true,
block_cipher_key,
aad,
GetNonse(frame_counter, system_title),
null
);
gcm.Write(plain_text);
byte[] cipher_text = gcm.FlushFinalBlock();
Console.WriteLine($"Tag ({gcm.GetTag().Length}) : {BitConverter.ToString(gcm.GetTag())}");
Result :
Tag (12) : 79-16-34-63-74-90-FD-5C-3A-EA-6A-0F
I have solved this problem!!!
================ SOLVED !!!! ==================
I'm very sorry to annoy you about this problem.
I've missed that if Security is Authentication, MUST have not to call Write(byte[]).
The problem is solved.
Thank you for you attention to me.
Please help me in advance.
GMAC
Hi,
I'm glad that this is solved.
BR,
Mikko
i want to the soure codes of aes_gmac(for C)
hello :
twinkle__star
I have the same problem with kurumi at work .i have see you tell kurumi "http://www.gurux.fi/GuruxDLMSTranslator?pdu=C30181000F0000280000FF01010…; now i want to the soure codes of aes_gmac,can you give me,my email :[Email removed by Admin] Thank you twinkle__star.
Wish best Regards zhihong zeng.
Target challenge does not match
Dear Mikko
I must be making some dumb mistake but I have several times on GuruX Translator .. and ...
The reply for server challenge is correct.
But the reply for the target challenge does not come out to be correct ...
System Title: 4D4D4D0000BC614E
Invocation Counter 01234567
Challenge: 4B35366956616759
Expected Challenge String: FE 14 66 AF B3 DB CD 4F 93 89 E2 B7
GuruX generated Challenge String: 55 C8 77 21 3C D8 0F 7C C4 13 7E 2E
Could you please help me here?
Many thanks.
Please help me to selection
Please help me to selection of function in C language
which function I will used for get a Expected Challenge String. as above mentiond
Hi RAJPURA,
Hi RAJPURA,
Please, create a new topic if you have a new question.
I'll answer your question there.
BR,
Mikko