Skip to content

Commit 8b7768f

Browse files
committed
SE050: remove empty spaces
1 parent b1b9886 commit 8b7768f

File tree

2 files changed

+43
-43
lines changed

2 files changed

+43
-43
lines changed

Diff for: libraries/SE05X/src/SE05X.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ int SE05XClass::random(byte data[], size_t length)
175175
smStatus_t status;
176176
uint16_t offset = 0;
177177
uint16_t left = length;
178-
178+
179179
while (left > 0) {
180180
uint16_t chunk = (left > SE05X_MAX_CHUNK_SIZE) ? SE05X_MAX_CHUNK_SIZE : left;
181181
size_t max_buffer = chunk;
182-
182+
183183
status = Se05x_API_GetRandom(&_se05x_session, chunk, (data + offset), &max_buffer);
184184
if (status != SM_OK) {
185185
SMLOG_E("Error in Se05x_API_GetRandom \n");
@@ -344,7 +344,7 @@ int SE05XClass::beginSHA256()
344344
{
345345
smStatus_t status;
346346
SE05x_CryptoModeSubType_t subtype;
347-
347+
348348
subtype.digest = kSE05x_DigestMode_SHA256;
349349

350350
status = Se05x_API_CreateCryptoObject(&_se05x_session, kSE05x_CryptoObject_DIGEST_SHA256, kSE05x_CryptoContext_DIGEST, subtype);
@@ -364,7 +364,7 @@ int SE05XClass::beginSHA256()
364364
int SE05XClass::updateSHA256(const byte in[], size_t inLen)
365365
{
366366
smStatus_t status;
367-
367+
368368
status = Se05x_API_DigestUpdate(&_se05x_session, kSE05x_CryptoObject_DIGEST_SHA256, in, inLen);
369369
if (status != SM_OK) {
370370
SMLOG_E("Error in Se05x_API_DigestUpdate \n");
@@ -381,7 +381,7 @@ int SE05XClass::endSHA256(byte out[], size_t* outLen)
381381
if (*outLen < SE05X_SHA256_LENGTH) {
382382
SMLOG_E("Error in endSHA256 \n");
383383
*outLen = 0;
384-
return 0;
384+
return 0;
385385
}
386386

387387
status = Se05x_API_DigestFinal(&_se05x_session, kSE05x_CryptoObject_DIGEST_SHA256, NULL, 0, out, outLen);
@@ -537,7 +537,7 @@ int SE05XClass::ecdsaVerify(const byte message[], const byte signature[], const
537537
}
538538

539539
if (!deleteBinaryObject(SE05X_TEMP_OBJECT)) {
540-
SMLOG_E("ecdsaVerify failure deleting temporary object\n");
540+
SMLOG_E("ecdsaVerify failure deleting temporary object\n");
541541
return 0;
542542
}
543543

@@ -581,7 +581,7 @@ int SE05XClass::readBinaryObject(int objectId, byte data[], size_t dataMaxLen, s
581581
while (left > 0) {
582582
uint16_t chunk = (left > SE05X_MAX_CHUNK_SIZE) ? SE05X_MAX_CHUNK_SIZE : left;
583583
size_t max_buffer = chunk;
584-
584+
585585
status = Se05x_API_ReadObject(&_se05x_session, objectId, offset, chunk, (data + offset), &max_buffer);
586586
if (status != SM_OK) {
587587
SMLOG_E("Error in Se05x_API_ReadObject \n");
@@ -783,9 +783,9 @@ int SE05XClass::getECKeyXyValuesFromDER(byte* derKey, size_t derLen, byte* rawKe
783783
if(*rawLen < SE05X_EC_KEY_RAW_LENGTH) {
784784
SMLOG_E("Error in getECKeyXyValuesFromDER \n");
785785
*rawLen = 0;
786-
return 0;
786+
return 0;
787787
}
788-
788+
789789
/* XY values are stored in the last 64 bytes of DER buffer */
790790
*rawLen = SE05X_EC_KEY_RAW_LENGTH;
791791
memcpy(rawKey, &derKey[derLen - SE05X_EC_KEY_RAW_LENGTH], SE05X_EC_KEY_RAW_LENGTH);
@@ -798,15 +798,15 @@ int SE05XClass::setECKeyXyVauesInDER(const byte* rawKey, size_t rawLen, byte* de
798798
if(rawLen != SE05X_EC_KEY_RAW_LENGTH) {
799799
SMLOG_E("Error in setECKeyXyVauesInDER invalid raw key\n");
800800
*derLen = 0;
801-
return 0;
801+
return 0;
802802
}
803803

804804
if(*derLen < SE05X_EC_KEY_DER_LENGTH) {
805805
SMLOG_E("Error in setECKeyXyVauesInDER buffer too small\n");
806806
*derLen = 0;
807-
return 0;
807+
return 0;
808808
}
809-
809+
810810
/* Copy header byte from 0 to 25 */
811811
memcpy(&derKey[0], &ecc_der_header_nist256[0], SE05X_EC_KEY_DER_HEADER_LENGTH);
812812
/* Add format byte */
@@ -826,13 +826,13 @@ int SE05XClass::getECSignatureRsValuesFromDER(byte* derSignature, size_t derLen,
826826
if ((derLen < SE05X_EC_SIGNATURE_MIN_DER_LENGTH) || (derLen > SE05X_EC_SIGNATURE_MAX_DER_LENGTH)) {
827827
SMLOG_E("Error in getECSignatureRsValuesFromDER invalid signature\n");
828828
*rawLen = 0;
829-
return 0;
829+
return 0;
830830
}
831831

832832
if (*rawLen < SE05X_EC_SIGNATURE_RAW_LENGTH) {
833833
SMLOG_E("Error in getECSignatureRsValuesFromDER buffer too small\n");
834834
*rawLen = 0;
835-
return 0;
835+
return 0;
836836
}
837837

838838
rLen = derSignature[3];
@@ -867,7 +867,7 @@ int SE05XClass::setECSignatureRsValuesInDER(const byte* rawSignature, size_t raw
867867
{
868868
/**
869869
* Always consider worst case with padding
870-
*
870+
*
871871
* | 0x30 0x46 0x02 0x21 0x00 | R values 32 bytes | 0x02 0x21 0x00 | S values 32 bytes |
872872
*
873873
*/

Diff for: libraries/SE05X/src/SE05X.h

+28-28
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class SE05XClass
6868
* @return 0 on Failure 1 on Success
6969
*/
7070
int generatePrivateKey(int keyID, byte keyBuf[], size_t keyBufMaxLen, size_t* keyLen);
71-
71+
7272
/** generatePublicKey
7373
*
7474
* Reads ECCurve_NIST_P256 public key from KeyID. Public key will be available
@@ -117,7 +117,7 @@ class SE05XClass
117117
* @param[in] inLen Input data length
118118
*
119119
* @return 0 on Failure 1 on Success
120-
*/
120+
*/
121121
int updateSHA256(const byte in[], size_t inLen);
122122

123123
/** endSHA256
@@ -128,9 +128,9 @@ class SE05XClass
128128
* @param[in,out] outLen Size of output data buffer, SHA256 length
129129
*
130130
* @return 0 on Failure 1 on Success
131-
*/
131+
*/
132132
int endSHA256(byte out[], size_t* outLen);
133-
133+
134134
/** SHA256
135135
*
136136
* One-shot SHA256
@@ -142,15 +142,15 @@ class SE05XClass
142142
* @param[out] outLen SHA256 length
143143
*
144144
* @return 0 on Failure 1 on Success
145-
*/
145+
*/
146146
int SHA256(const byte in[], size_t inLen, byte out[], size_t outMaxLen, size_t* outLen);
147147

148148
/** Sign
149149
*
150150
* Computes ECDSA signature using key stored in KeyID SE050 object.
151151
* Output buffer is filled with the signature in DER format:
152-
*
153-
* | 0x30 | payloadsize 1 byte | 0x02 | R length 1 byte | padding 0x00 (if length 0x21) | R values 32 bytes
152+
*
153+
* | 0x30 | payloadsize 1 byte | 0x02 | R length 1 byte | padding 0x00 (if length 0x21) | R values 32 bytes
154154
* | 0x02 | S length 1 byte | padding 0x00 (if length 0x21) | S values 32 bytes
155155
*
156156
* SHA256 -> private Key -> Signature
@@ -163,7 +163,7 @@ class SE05XClass
163163
* @param[out] sigLen signature length
164164
*
165165
* @return 0 on Failure 1 on Success
166-
*/
166+
*/
167167
int Sign(int keyID, const byte hash[], size_t hashLen, byte sig[], size_t maxSigLen, size_t* sigLen);
168168

169169
/** Verify
@@ -173,28 +173,28 @@ class SE05XClass
173173
* Input SHA256
174174
* ? Match ?
175175
* Signature -> public Key -> Original SHA256
176-
*
176+
*
177177
* @param[in] keyID SE050 object ID containing the key
178178
* @param[in] hash Input SHA256 used to compute the signature
179179
* @param[in] hashLen SHA256 length
180180
* @param[in] sig Input buffer containint the signature
181181
* @param[in] sigLen signature length
182182
*
183183
* @return 0 on Failure (Not match) 1 on Success (Match)
184-
*/
184+
*/
185185
int Verify(int keyID, const byte hash[], size_t hashLen, const byte sig[],size_t sigLen);
186186

187187
/** readBinaryObject
188188
*
189189
* Reads binary data from SE050 object.
190-
*
190+
*
191191
* @param[in] ObjectId SE050 object ID containing data
192192
* @param[out] data Output data buffer
193193
* @param[in] dataMaxLen Output data buffer size
194194
* @param[out] sig Binary object size
195195
*
196196
* @return 0 on Failure 1 on Success
197-
*/
197+
*/
198198
int readBinaryObject(int ObjectId, byte data[], size_t dataMaxLen, size_t* length);
199199

200200
/** AES_ECB_encrypt
@@ -268,43 +268,43 @@ class SE05XClass
268268
/** writeBinaryObject
269269
*
270270
* Writes binary data into SE050 object.
271-
*
271+
*
272272
* @param[in] ObjectId SE050 object ID
273273
* @param[in] data Input data buffer
274274
* @param[in] length Input data buffer size
275275
*
276276
* @return 0 on Failure 1 on Success
277-
*/
277+
*/
278278
int writeBinaryObject(int ObjectId, const byte data[], size_t length);
279279

280280
/** existsBinaryObject
281281
*
282282
* Checks if Object exist
283-
*
283+
*
284284
* @param[in] ObjectId SE050 object ID
285285
*
286286
* @return 0 on Failure (Not exist) 1 on Success (Exists)
287-
*/
287+
*/
288288
int existsBinaryObject(int objectId);
289289

290290
/** deleteBinaryObject
291291
*
292292
* Deletes SE050 object
293-
*
293+
*
294294
* @param[in] ObjectId SE050 object ID
295295
*
296296
* @return 0 on Failure 1 on Success
297-
*/
297+
*/
298298
int deleteBinaryObject(int objectId);
299299

300300
/** deleteBinaryObject
301301
*
302302
* Deletes all SE050 user objects
303-
*
303+
*
304304
* @param[in] ObjectId SE050 object ID
305305
*
306306
* @return 0 on Failure 1 on Success
307-
*/
307+
*/
308308
int deleteAllObjects();
309309

310310
/* ECCX08 legacy API*/
@@ -344,20 +344,20 @@ class SE05XClass
344344
* Input SHA256
345345
* ? Match ?
346346
* Signature -> public Key -> Original SHA256
347-
*
347+
*
348348
* @param[in] message Input SHA256 used to compute the signature 32 bytes
349349
* @param[in] sig Input buffer containint the signature R S values 64bytes
350350
* @param[in] pubkey Public key X Y values 64bytes
351351
*
352352
* @return 0 on Failure (Not match) 1 on Success (Match)
353-
*/
353+
*/
354354
int ecdsaVerify(const byte message[], const byte signature[], const byte pubkey[]);
355355

356356
/** ecSign
357357
*
358358
* Computes ECDSA signature using key stored in KeyID SE050 object.
359359
* Output buffer is filled with the signature R S values:
360-
*
360+
*
361361
* | R values 32 bytes | S values 32 bytes |
362362
*
363363
* SHA256 -> private Key -> Signature
@@ -367,31 +367,31 @@ class SE05XClass
367367
* @param[out] signature Output buffer containint the signature 64 bytes
368368
*
369369
* @return 0 on Failure 1 on Success
370-
*/
370+
*/
371371
int ecSign(int slot, const byte message[], byte signature[]);
372372

373373
/** readSlot
374374
*
375375
* Reads binary data from SE050 object.
376-
*
376+
*
377377
* @param[in] ObjecslottId SE050 object ID containing data
378378
* @param[out] data Output data buffer
379379
* @param[in] length Number of bytes to read
380380
*
381381
* @return 0 on Failure 1 on Success
382-
*/
382+
*/
383383
int readSlot(int slot, byte data[], int length);
384384

385385
/** writeSlot
386386
*
387387
* Writes binary data into SE050 object.
388-
*
388+
*
389389
* @param[in] ObjectId SE050 object ID
390390
* @param[in] data Input data buffer
391391
* @param[in] length Number of bytes to write
392392
*
393393
* @return 0 on Failure 1 on Success
394-
*/
394+
*/
395395
int writeSlot(int slot, const byte data[], int length);
396396

397397
inline int locked() { return 1; }

0 commit comments

Comments
 (0)