kaoh / globalplatform

C library + command-line for Open- / GlobalPlatform smart cards
https://kaoh.github.io/globalplatform/
Other
72 stars 30 forks source link

Check coding style #23

Closed kaoh closed 4 years ago

kaoh commented 19 years ago

http://cvs.sourceforge.net/viewcvs.py/globalplatform/OpenPlatform/OpenPlatform.c?rev=1.3&view=markup

The following code example from the function "mutual_authentication" looks strange to me. i=0; sendBuffer[i++] = 0x84; sendBuffer[i++] = 0x82; sendBuffer[i++] = securityLevel; sendBuffer[i++] = 0x00; sendBuffer[i++] = 0x10; memcpy(sendBuffer+i, host_cryptogram, 8); i+=8;

I would prefer an optimised version or a cleaner inline function call that will also be reused at other places. sendBuffer[0] = 0x84; sendBuffer[1] = 0x82; sendBuffer[2] = securityLevel; sendBuffer[3] = 0x00; sendBuffer[4] = 0x10; memcpy(sendBuffer + 5, host_cryptogram, 8); i = 13;

Reported by: elfring

kaoh commented 18 years ago

Logged In: YES user_id=1309428

Why should I use fixed index numbers? If the indexes are fixed, whenever something changes (is extended) I have to renumber everything. So everything is much more flexible and can be used also as template for all other APDUs.

Original comment by: kaoh