Skip to content

Commit 8bd52cd

Browse files
committed
SE050: remove empty spaces
1 parent fc732ba commit 8bd52cd

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
@@ -174,11 +174,11 @@ int SE05XClass::random(byte data[], size_t length)
174174
smStatus_t status;
175175
uint16_t offset = 0;
176176
uint16_t left = length;
177-
177+
178178
while (left > 0) {
179179
uint16_t chunk = (left > SE05X_MAX_CHUNK_SIZE) ? SE05X_MAX_CHUNK_SIZE : left;
180180
size_t max_buffer = chunk;
181-
181+
182182
status = Se05x_API_GetRandom(&_se05x_session, chunk, (data + offset), &max_buffer);
183183
if (status != SM_OK) {
184184
SMLOG_E("Error in Se05x_API_GetRandom \n");
@@ -343,7 +343,7 @@ int SE05XClass::beginSHA256()
343343
{
344344
smStatus_t status;
345345
SE05x_CryptoModeSubType_t subtype;
346-
346+
347347
subtype.digest = kSE05x_DigestMode_SHA256;
348348

349349
status = Se05x_API_CreateCryptoObject(&_se05x_session, kSE05x_CryptoObject_DIGEST_SHA256, kSE05x_CryptoContext_DIGEST, subtype);
@@ -363,7 +363,7 @@ int SE05XClass::beginSHA256()
363363
int SE05XClass::updateSHA256(const byte in[], size_t inLen)
364364
{
365365
smStatus_t status;
366-
366+
367367
status = Se05x_API_DigestUpdate(&_se05x_session, kSE05x_CryptoObject_DIGEST_SHA256, in, inLen);
368368
if (status != SM_OK) {
369369
SMLOG_E("Error in Se05x_API_DigestUpdate \n");
@@ -380,7 +380,7 @@ int SE05XClass::endSHA256(byte out[], size_t* outLen)
380380
if (*outLen < SE05X_SHA256_LENGTH) {
381381
SMLOG_E("Error in endSHA256 \n");
382382
*outLen = 0;
383-
return 0;
383+
return 0;
384384
}
385385

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

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

@@ -580,7 +580,7 @@ int SE05XClass::readBinaryObject(int objectId, byte data[], size_t dataMaxLen, s
580580
while (left > 0) {
581581
uint16_t chunk = (left > SE05X_MAX_CHUNK_SIZE) ? SE05X_MAX_CHUNK_SIZE : left;
582582
size_t max_buffer = chunk;
583-
583+
584584
status = Se05x_API_ReadObject(&_se05x_session, objectId, offset, chunk, (data + offset), &max_buffer);
585585
if (status != SM_OK) {
586586
SMLOG_E("Error in Se05x_API_ReadObject \n");
@@ -782,9 +782,9 @@ int SE05XClass::getECKeyXyValuesFromDER(byte* derKey, size_t derLen, byte* rawKe
782782
if(*rawLen < SE05X_EC_KEY_RAW_LENGTH) {
783783
SMLOG_E("Error in getECKeyXyValuesFromDER \n");
784784
*rawLen = 0;
785-
return 0;
785+
return 0;
786786
}
787-
787+
788788
/* XY values are stored in the last 64 bytes of DER buffer */
789789
*rawLen = SE05X_EC_KEY_RAW_LENGTH;
790790
memcpy(rawKey, &derKey[derLen - SE05X_EC_KEY_RAW_LENGTH], SE05X_EC_KEY_RAW_LENGTH);
@@ -797,15 +797,15 @@ int SE05XClass::setECKeyXyVauesInDER(const byte* rawKey, size_t rawLen, byte* de
797797
if(rawLen != SE05X_EC_KEY_RAW_LENGTH) {
798798
SMLOG_E("Error in setECKeyXyVauesInDER invalid raw key\n");
799799
*derLen = 0;
800-
return 0;
800+
return 0;
801801
}
802802

803803
if(*derLen < SE05X_EC_KEY_DER_LENGTH) {
804804
SMLOG_E("Error in setECKeyXyVauesInDER buffer too small\n");
805805
*derLen = 0;
806-
return 0;
806+
return 0;
807807
}
808-
808+
809809
/* Copy header byte from 0 to 25 */
810810
memcpy(&derKey[0], &ecc_der_header_nist256[0], SE05X_EC_KEY_DER_HEADER_LENGTH);
811811
/* Add format byte */
@@ -825,13 +825,13 @@ int SE05XClass::getECSignatureRsValuesFromDER(byte* derSignature, size_t derLen,
825825
if ((derLen < SE05X_EC_SIGNATURE_MIN_DER_LENGTH) || (derLen > SE05X_EC_SIGNATURE_MAX_DER_LENGTH)) {
826826
SMLOG_E("Error in getECSignatureRsValuesFromDER invalid signature\n");
827827
*rawLen = 0;
828-
return 0;
828+
return 0;
829829
}
830830

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

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

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)