• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stefanberger / libtpms / #2014

04 Aug 2025 07:21PM UTC coverage: 76.783% (-0.4%) from 77.225%
#2014

push

travis-ci

web-flow
Merge 24cf223e7 into 925b06ee4

33895 of 44144 relevant lines covered (76.78%)

93978.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.72
/src/tpm2/AlgorithmTests.c
1
/********************************************************************************/
2
/*                                                                                */
3
/*                          Code to perform the various self-test functions.        */
4
/*                             Written by Ken Goldman                                */
5
/*                       IBM Thomas J. Watson Research Center                        */
6
/*            $Id: AlgorithmTests.c 1658 2021-01-22 23:14:01Z kgoldman $        */
7
/*                                                                                */
8
/*  Licenses and Notices                                                        */
9
/*                                                                                */
10
/*  1. Copyright Licenses:                                                        */
11
/*                                                                                */
12
/*  - Trusted Computing Group (TCG) grants to the user of the source code in        */
13
/*    this specification (the "Source Code") a worldwide, irrevocable,                 */
14
/*    nonexclusive, royalty free, copyright license to reproduce, create         */
15
/*    derivative works, distribute, display and perform the Source Code and        */
16
/*    derivative works thereof, and to grant others the rights granted herein.        */
17
/*                                                                                */
18
/*  - The TCG grants to the user of the other parts of the specification         */
19
/*    (other than the Source Code) the rights to reproduce, distribute,         */
20
/*    display, and perform the specification solely for the purpose of                 */
21
/*    developing products based on such documents.                                */
22
/*                                                                                */
23
/*  2. Source Code Distribution Conditions:                                        */
24
/*                                                                                */
25
/*  - Redistributions of Source Code must retain the above copyright licenses,         */
26
/*    this list of conditions and the following disclaimers.                        */
27
/*                                                                                */
28
/*  - Redistributions in binary form must reproduce the above copyright         */
29
/*    licenses, this list of conditions        and the following disclaimers in the         */
30
/*    documentation and/or other materials provided with the distribution.        */
31
/*                                                                                */
32
/*  3. Disclaimers:                                                                */
33
/*                                                                                */
34
/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF        */
35
/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH        */
36
/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)        */
37
/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.                */
38
/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for                 */
39
/*  information on specification licensing rights available through TCG         */
40
/*  membership agreements.                                                        */
41
/*                                                                                */
42
/*  - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED         */
43
/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR         */
44
/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR                 */
45
/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY                 */
46
/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.                */
47
/*                                                                                */
48
/*  - Without limitation, TCG and its members and licensors disclaim all         */
49
/*    liability, including liability for infringement of any proprietary         */
50
/*    rights, relating to use of information in this specification and to the        */
51
/*    implementation of this specification, and TCG disclaims all liability for        */
52
/*    cost of procurement of substitute goods or services, lost profits, loss         */
53
/*    of use, loss of data or any incidental, consequential, direct, indirect,         */
54
/*    or special damages, whether under contract, tort, warranty or otherwise,         */
55
/*    arising in any way out of use or reliance upon this specification or any         */
56
/*    information herein.                                                        */
57
/*                                                                                */
58
/*  (c) Copyright IBM Corp. and others, 2016 - 2021                                */
59
/*                                                                                */
60
/********************************************************************************/
61

62
/* 10.2.1 AlgorithmTests.c */
63
/* 10.2.1.1 Introduction */
64
/* This file contains the code to perform the various self-test functions. */
65
/* 10.2.1.2 Includes and Defines */
66
#include    "Tpm.h"
67
#define     SELF_TEST_DATA
68
#if SELF_TEST
69
/* These includes pull in the data structures. They contain data definitions for the various
70
   tests. */
71
#include    "SelfTest.h"
72
#include    "SymmetricTest.h"
73
#include    "RsaTestData.h"
74
#include    "EccTestData.h"
75
#include    "HashTestData.h"
76
#include    "KdfTestData.h"
77
#define TEST_DEFAULT_TEST_HASH(vector)                                        \
78
    if(TEST_BIT(DEFAULT_TEST_HASH, g_toTest))                                \
79
        TestHash(DEFAULT_TEST_HASH, vector);
80
/* Make sure that the algorithm has been tested */
81
#define CLEAR_BOTH(alg)     {   CLEAR_BIT(alg, *toTest);                \
82
        if(toTest != &g_toTest)                                                \
83
            CLEAR_BIT(alg, g_toTest); }
84
#define SET_BOTH(alg)     {   SET_BIT(alg, *toTest);                        \
85
        if(toTest != &g_toTest)                                                \
86
            SET_BIT(alg, g_toTest); }
87
#define TEST_BOTH(alg)       ((toTest != &g_toTest)                        \
88
                              ? TEST_BIT(alg, *toTest) || TEST_BIT(alg, g_toTest) \
89
                              : TEST_BIT(alg, *toTest))
90
/* Can only cancel if doing a list. */
91
#define CHECK_CANCELED                                                        \
92
    if(_plat__IsCanceled() && toTest != &g_toTest)                        \
93
        return TPM_RC_CANCELED;
94
/* 10.2.1.3 Hash Tests */
95
/* 10.2.1.3.1 Description */
96
/* The hash test does a known-value HMAC using the specified hash algorithm. */
97
/* 10.2.1.3.2 TestHash() */
98
/* The hash test function. */
99
static TPM_RC
100
TestHash(
9,347✔
101
         TPM_ALG_ID          hashAlg,
102
         ALGORITHM_VECTOR    *toTest
103
         )
104
{
105
    TPM2B_DIGEST      computed;  // value computed
9,347✔
106
    HMAC_STATE        state;
9,347✔
107
    UINT16            digestSize;
9,347✔
108
    const TPM2B       *testDigest = NULL;
9,347✔
109
    //    TPM2B_TYPE(HMAC_BLOCK, DEFAULT_TEST_HASH_BLOCK_SIZE);
110
    pAssert(hashAlg != TPM_ALG_NULL);
9,347✔
111
#define HASH_CASE_FOR_TEST(HASH, hash)        case ALG_##HASH##_VALUE:        \
112
    testDigest = &c_##HASH##_digest.b;                                        \
113
    break;
114
    switch(hashAlg)
9,347✔
115
        {
116
            FOR_EACH_HASH(HASH_CASE_FOR_TEST)
1,321✔
117

118
          default:
×
119
            FAIL(FATAL_ERROR_INTERNAL);
×
120
        }
121
    // Clear the to-test bits
122
    CLEAR_BOTH(hashAlg);
9,347✔
123

124
    // If there is an algorithm without test vectors, then assume that things are OK.
125
    if(testDigest == NULL || testDigest->size == 0)
9,347✔
126
        return TPM_RC_SUCCESS;
127

128
    // Set the HMAC key to twice the digest size
129
    digestSize = CryptHashGetDigestSize(hashAlg);
9,347✔
130
    CryptHmacStart(&state, hashAlg, digestSize * 2,
9,347✔
131
                   (BYTE *)c_hashTestKey.t.buffer);
132
    CryptDigestUpdate(&state.hashState, 2 * CryptHashGetBlockSize(hashAlg),
9,347✔
133
                      (BYTE *)c_hashTestData.t.buffer);
134
    computed.t.size = digestSize;
9,347✔
135
    CryptHmacEnd(&state, digestSize, computed.t.buffer);
9,347✔
136
    if((testDigest->size != computed.t.size)
9,347✔
137
       || (memcmp(testDigest->buffer, computed.t.buffer, computed.b.size) != 0)) {
9,347✔
138
        SELF_TEST_FAILURE;
×
139
    }
140
    return TPM_RC_SUCCESS;
141
}
142
// libtpms added begin
143
#if SMAC_IMPLEMENTED && ALG_CMAC
144
static TPM_RC
145
TestSMAC(
23✔
146
         ALGORITHM_VECTOR    *toTest
147
         )
148
{
149
    HMAC_STATE          state;
23✔
150
    UINT16              copied;
23✔
151
    BYTE                out[MAX_SYM_BLOCK_SIZE];
23✔
152
    UINT32              outSize = sizeof(out);
23✔
153
    UINT16              blocksize;
23✔
154
    int                 i;
23✔
155
    TPMU_PUBLIC_PARMS   cmac_keyParms;
23✔
156

157
    // initializing this statically seems impossible with gcc...
158
    cmac_keyParms.symDetail.sym.algorithm = TPM_ALG_AES;
23✔
159
    cmac_keyParms.symDetail.sym.keyBits.sym = 128;
23✔
160

161
    for (i = 0; CMACTests[i].key; i++ )
115✔
162
        {
163
            blocksize = CryptMacStart(&state, &cmac_keyParms,
92✔
164
                                      TPM_ALG_CMAC, CMACTests[i].key);
165
            pAssert(blocksize <= outSize);
92✔
166
            CryptDigestUpdate(&state.hashState, CMACTests[i].datalen,
92✔
167
                              CMACTests[i].data);
92✔
168
            copied = CryptMacEnd(&state, outSize, out);
92✔
169
            if((CMACTests[i].outlen != copied)
92✔
170
              || (memcmp(out, CMACTests[i].out, CMACTests[i].outlen) != 0)) {
92✔
171
                SELF_TEST_FAILURE;
×
172
            }
173
        }
174
    return TPM_RC_SUCCESS;
23✔
175
}
176
#endif
177
// libtpms added end
178
/* 10.2.1.4 Symmetric Test Functions */
179
/* 10.2.1.4.1 MakeIv() */
180
/* Internal function to make the appropriate IV depending on the mode. */
181
static UINT32
182
MakeIv(
988✔
183
       TPM_ALG_ID    mode,     // IN: symmetric mode
184
       UINT32        size,     // IN: block size of the algorithm
185
       BYTE         *iv        // OUT: IV to fill in
186
       )
187
{
188
    BYTE          i;
988✔
189
    if(mode == TPM_ALG_ECB)
988✔
190
        return 0;
191
    if(mode == TPM_ALG_CTR)
808✔
192
        {
193
            // The test uses an IV that has 0xff in the last byte
194
            for(i = 1; i <= size; i++)
2,708✔
195
                *iv++ = 0xff - (BYTE)(size - i);
2,528✔
196
        }
197
    else
198
        {
199
            for(i = 0; i < size; i++)
8,916✔
200
                *iv++ = i;
8,288✔
201
        }
202
    return size;
203
}
204
/* 10.2.1.4.2 TestSymmetricAlgorithm() */
205
/* Function to test a specific algorithm, key size, and mode. */
206
static void
207
TestSymmetricAlgorithm(
560✔
208
                       const SYMMETRIC_TEST_VECTOR     *test,          //
209
                       TPM_ALG_ID                       mode           //
210
                       )
211
{
212
    BYTE                            encrypted[MAX_SYM_BLOCK_SIZE * 2];
560✔
213
    BYTE                            decrypted[MAX_SYM_BLOCK_SIZE * 2];
560✔
214
    TPM2B_IV                        iv;
560✔
215

216
    // libtpms added beging
217
    if (test->dataOut[mode - TPM_ALG_CTR] == NULL)
560✔
218
        return;
66✔
219
    // libtpms added end
220

221
    //
222
    // Get the appropriate IV
223
    iv.t.size = (UINT16)MakeIv(mode, test->ivSize, iv.t.buffer);
494✔
224
    // Encrypt known data
225
    CryptSymmetricEncrypt(encrypted, test->alg, test->keyBits, test->key, &iv,
494✔
226
                          mode, test->dataInOutSize, test->dataIn);
494✔
227
    // Check that it matches the expected value
228
    if(!MemoryEqual(encrypted, test->dataOut[mode - TPM_ALG_CTR],
494✔
229
                    test->dataInOutSize)) {
494✔
230
        SELF_TEST_FAILURE;
×
231
    }
232
    // Reinitialize the iv for decryption
233
    MakeIv(mode, test->ivSize, iv.t.buffer);
494✔
234
    CryptSymmetricDecrypt(decrypted, test->alg, test->keyBits, test->key, &iv,
494✔
235
                          mode, test->dataInOutSize,
494✔
236
                          test->dataOut[mode - TPM_ALG_CTR]);
494✔
237
    // Make sure that it matches what we started with
238
    if(!MemoryEqual(decrypted, test->dataIn, test->dataInOutSize)) {
494✔
239
        SELF_TEST_FAILURE;
×
240
    }
241
}
242
/* 10.2.1.4.3 AllSymsAreDone() */
243
/* Checks if both symmetric algorithms have been tested. This is put here so that addition of a
244
   symmetric algorithm will be relatively easy to handle */
245
/* Return Value        Meaning */
246
/* TRUE(1)        all symmetric algorithms tested */
247
/* FALSE(0)        not all symmetric algorithms tested */
248
static BOOL
249
AllSymsAreDone(
45✔
250
               ALGORITHM_VECTOR        *toTest
251
               )
252
{
253
    return (!TEST_BOTH(TPM_ALG_AES) && !TEST_BOTH(TPM_ALG_SM4));
45✔
254
}
255
/* 10.2.1.4.4 AllModesAreDone() */
256
/* Checks if all the modes have been tested */
257
/* Return Value        Meaning */
258
/* TRUE(1)        all modes tested */
259
/* FALSE(0)        all modes not tested */
260
static BOOL
261
AllModesAreDone(
8✔
262
                ALGORITHM_VECTOR            *toTest
263
                )
264
{
265
    TPM_ALG_ID                  alg;
8✔
266
    for(alg = SYM_MODE_FIRST; alg <= SYM_MODE_LAST; alg++)
32✔
267
        if(TEST_BOTH(alg))
40✔
268
            return FALSE;
269
    return TRUE;
270
}
271
/* 10.2.1.4.5 TestSymmetric() */
272
/* If alg is a symmetric block cipher, then all of the modes that are selected are tested. If alg is
273
   a mode, then all algorithms of that mode are tested. */
274
static TPM_RC
275
TestSymmetric(
53✔
276
              TPM_ALG_ID                   alg,
277
              ALGORITHM_VECTOR            *toTest
278
              )
279
{
280
    SYM_INDEX                    index;
53✔
281
    TPM_ALG_ID                   mode;
53✔
282
    //
283
    if(!TEST_BIT(alg, *toTest))
53✔
284
        return TPM_RC_SUCCESS;
285
    if(alg == TPM_ALG_AES || alg == TPM_ALG_SM4 || alg == TPM_ALG_CAMELLIA || alg == TPM_ALG_TDES)
53✔
286
        {
287
            // Will test the algorithm for all modes and key sizes
288
            CLEAR_BOTH(alg);
45✔
289
            // A test this algorithm for all modes
290
            for(index = 0; index < NUM_SYMS; index++)
405✔
291
                {
292
                    if(c_symTestValues[index].alg == alg)
360✔
293
                        {
294
                            for(mode = SYM_MODE_FIRST;
295
                                mode <= SYM_MODE_LAST;
672✔
296
                                mode++)
560✔
297
                                {
298
                                    if(TEST_BIT(mode, g_implementedAlgorithms)) // libtpms always test implemented modes
560✔
299
                                        TestSymmetricAlgorithm(&c_symTestValues[index], mode);
560✔
300
                                }
301
                        }
302
                }
303
            // if all the symmetric tests are done
304
            if(AllSymsAreDone(toTest))
45✔
305
                {
306
                    // all symmetric algorithms tested so no modes should be set
307
                    for(alg = SYM_MODE_FIRST; alg <= SYM_MODE_LAST; alg++)
204✔
308
                        CLEAR_BOTH(alg);
170✔
309
                }
310
        }
311
    else if(SYM_MODE_FIRST <= alg && alg <= SYM_MODE_LAST)
312
        {
313
            // Test this mode for all key sizes and algorithms
314
            for(index = 0; index < NUM_SYMS; index++)
72✔
315
                {
316
                    // The mode testing only comes into play when doing self tests
317
                    // by command. When doing self tests by command, the block ciphers are
318
                    // tested first. That means that all of their modes would have been
319
                    // tested for all key sizes. If there is no block cipher left to
320
                    // test, then clear this mode bit.
321
                    if(!TEST_BIT(TPM_ALG_AES, *toTest)
64✔
322
                       && !TEST_BIT(TPM_ALG_SM4, *toTest))
64✔
323
                        {
324
                            CLEAR_BOTH(alg);
64✔
325
                        }
326
                    else
327
                        {
328
                            for(index = 0; index < NUM_SYMS; index++)
×
329
                                {
330
                                    if(TEST_BIT(c_symTestValues[index].alg, *toTest))
×
331
                                        TestSymmetricAlgorithm(&c_symTestValues[index], alg);
×
332
                                }
333
                            // have tested this mode for all algorithms
334
                            CLEAR_BOTH(alg);
64✔
335
                        }
336
                }
337
            if(AllModesAreDone(toTest))
8✔
338
                {
339
                    CLEAR_BOTH(TPM_ALG_AES);
×
340
                    CLEAR_BOTH(TPM_ALG_SM4);
×
341
                }
342
        }
343
    else
344
        pAssert(alg == 0 && alg != 0);
×
345
    return TPM_RC_SUCCESS;
346
}
347
/* 10.2.1.5 RSA Tests */
348
#if ALG_RSA
349
/* 10.2.1.5.1 Introduction */
350
/* The tests are for public key only operations and for private key operations. Signature
351
   verification and encryption are public key operations. They are tested by using a KVT. For
352
   signature verification, this means that a known good signature is checked by
353
   CryptRsaValidateSignature(). If it fails, then the TPM enters failure mode. For encryption, the
354
   TPM encrypts known values using the selected scheme and checks that the returned value matches
355
   the expected value. */
356
/* For private key operations, a full scheme check is used. For a signing key, a known key is used
357
   to sign a known message. Then that signature is verified. since the signature may involve use of
358
   random values, the signature will be different each time and we can't always check that the
359
   signature matches a known value. The same technique is used for decryption (RSADP/RSAEP). */
360
/* When an operation uses the public key and the verification has not been tested, the TPM will do a
361
   KVT. */
362
/* The test for the signing algorithm is built into the call for the algorithm */
363
/* 10.2.1.5.2 RsaKeyInitialize() */
364
/* The test key is defined by a public modulus and a private prime. The TPM's RSA code computes the
365
   second prime and the private exponent. */
366
static void
367
RsaKeyInitialize(
89✔
368
                 OBJECT          *testObject
369
                 )
370
{
371
    MemoryCopy2B(&testObject->publicArea.unique.rsa.b, (P2B)&c_rsaPublicModulus,
89✔
372
                 sizeof(c_rsaPublicModulus));
373
    MemoryCopy2B(&testObject->sensitive.sensitive.rsa.b, (P2B)&c_rsaPrivatePrime,
89✔
374
                 sizeof(testObject->sensitive.sensitive.rsa.t.buffer));
375
    testObject->publicArea.parameters.rsaDetail.keyBits = RSA_TEST_KEY_SIZE * 8;
89✔
376
    // Use the default exponent
377
    testObject->publicArea.parameters.rsaDetail.exponent = 0;
89✔
378
    testObject->attributes.privateExp = 0;
89✔
379
}
89✔
380
/* 10.2.1.5.3 TestRsaEncryptDecrypt() */
381
/* These tests are for a public key encryption that uses a random value. */
382
static TPM_RC
383
TestRsaEncryptDecrypt(
52✔
384
                      TPM_ALG_ID           scheme,            // IN: the scheme
385
                      ALGORITHM_VECTOR    *toTest             //
386
                      )
387
{
388
    TPM2B_PUBLIC_KEY_RSA             testInput;
52✔
389
    TPM2B_PUBLIC_KEY_RSA             testOutput;
52✔
390
    OBJECT                           testObject;
52✔
391
    const TPM2B_RSA_TEST_KEY        *kvtValue = NULL;
52✔
392
    TPM_RC                           result = TPM_RC_SUCCESS;
52✔
393
    const TPM2B                     *testLabel = NULL;
52✔
394
    TPMT_RSA_DECRYPT                 rsaScheme;
52✔
395
    //
396
    // Don't need to initialize much of the test object but do need to initialize
397
    // the flag indicating that the private exponent has been computed.
398
    testObject.attributes.privateExp = CLEAR;
52✔
399
    RsaKeyInitialize(&testObject);
52✔
400
    rsaScheme.scheme = scheme;
52✔
401
    rsaScheme.details.anySig.hashAlg = DEFAULT_TEST_HASH;
52✔
402
    CLEAR_BOTH(scheme);
52✔
403
    CLEAR_BOTH(TPM_ALG_NULL);
52✔
404
    if(scheme == TPM_ALG_NULL)
52✔
405
        {
406
            // This is an encryption scheme using the private key without any encoding.
407
            memcpy(testInput.t.buffer, c_RsaTestValue, sizeof(c_RsaTestValue));
27✔
408
            testInput.t.size = sizeof(c_RsaTestValue);
27✔
409
            if(TPM_RC_SUCCESS != CryptRsaEncrypt(&testOutput, &testInput.b,
27✔
410
                                                 &testObject, &rsaScheme, NULL, NULL)) {
411
                SELF_TEST_FAILURE;
×
412
            }
413
            if(!MemoryEqual(testOutput.t.buffer, c_RsaepKvt.buffer, c_RsaepKvt.size)) {
27✔
414
                SELF_TEST_FAILURE;
×
415
            }
416
            MemoryCopy2B(&testInput.b, &testOutput.b, sizeof(testInput.t.buffer));
27✔
417
            if(TPM_RC_SUCCESS != CryptRsaDecrypt(&testOutput.b, &testInput.b,
27✔
418
                                                 &testObject, &rsaScheme, NULL)) {
419
                SELF_TEST_FAILURE;
×
420
            }
421
            if(!MemoryEqual(testOutput.t.buffer, c_RsaTestValue,
27✔
422
                            sizeof(c_RsaTestValue))) {
423
                SELF_TEST_FAILURE;
×
424
            }
425
        }
426
    else
427
        {
428
            // TPM_ALG_RSAES:
429
            // This is an decryption scheme using padding according to
430
            // PKCS#1v2.1, 7.2. This padding uses random bits. To test a public
431
            // key encryption that uses random data, encrypt a value and then
432
            // decrypt the value and see that we get the encrypted data back.
433
            // The hash is not used by this encryption so it can be TMP_ALG_NULL
434
            // TPM_ALG_OAEP_:
435
            // This is also an decryption scheme and it also uses a
436
            // pseudo-random
437
            // value. However, this also uses a hash algorithm. So, we may need
438
            // to test that algorithm before use.
439
            if(scheme == TPM_ALG_OAEP)
25✔
440
                {
441
                    TEST_DEFAULT_TEST_HASH(toTest);
13✔
442
                    kvtValue = &c_OaepKvt;
13✔
443
                    testLabel = OAEP_TEST_STRING;
13✔
444
                }
445
            else if(scheme == TPM_ALG_RSAES)
12✔
446
                {
447
                    kvtValue = &c_RsaesKvt;
448
                    testLabel = NULL;
449
                }
450
            else {
451
                SELF_TEST_FAILURE;
×
452
            }
453
            // Only use a digest-size portion of the test value
454
            memcpy(testInput.t.buffer, c_RsaTestValue, DEFAULT_TEST_DIGEST_SIZE);
25✔
455
            testInput.t.size = DEFAULT_TEST_DIGEST_SIZE;
25✔
456
            // See if the encryption works
457
            if(TPM_RC_SUCCESS != CryptRsaEncrypt(&testOutput, &testInput.b,
25✔
458
                                                 &testObject, &rsaScheme, testLabel,
459
                                                 NULL)) {
460
                SELF_TEST_FAILURE;
×
461
            }
462
            MemoryCopy2B(&testInput.b, &testOutput.b, sizeof(testInput.t.buffer));
25✔
463
            // see if we can decrypt this value and get the original data back
464
            if(TPM_RC_SUCCESS != CryptRsaDecrypt(&testOutput.b, &testInput.b,
25✔
465
                                                 &testObject, &rsaScheme, testLabel)) {
466
                SELF_TEST_FAILURE;
×
467
            }
468
            // See if the results compare
469
            if(testOutput.t.size != DEFAULT_TEST_DIGEST_SIZE
25✔
470
               || !MemoryEqual(testOutput.t.buffer, c_RsaTestValue,
25✔
471
                               DEFAULT_TEST_DIGEST_SIZE)) {
472
                SELF_TEST_FAILURE;
×
473
            }
474
            // Now check that the decryption works on a known value
475
            MemoryCopy2B(&testInput.b, (P2B)kvtValue,
25✔
476
                         sizeof(testInput.t.buffer));
477
            if(TPM_RC_SUCCESS != CryptRsaDecrypt(&testOutput.b, &testInput.b,
25✔
478
                                                 &testObject, &rsaScheme, testLabel)) {
479
                SELF_TEST_FAILURE;
×
480
            }
481
            if(testOutput.t.size != DEFAULT_TEST_DIGEST_SIZE
25✔
482
               || !MemoryEqual(testOutput.t.buffer, c_RsaTestValue,
25✔
483
                               DEFAULT_TEST_DIGEST_SIZE)) {
484
                SELF_TEST_FAILURE;
×
485
            }
486
        }
487
    return result;
52✔
488
}
489
/* 10.2.1.5.4 TestRsaSignAndVerify() */
490
/* This function does the testing of the RSA sign and verification functions. This test does a
491
   KVT. */
492
static TPM_RC
493
TestRsaSignAndVerify(
37✔
494
                     TPM_ALG_ID               scheme,
495
                     ALGORITHM_VECTOR        *toTest
496
                     )
497
{
498
    TPM_RC                      result = TPM_RC_SUCCESS;
37✔
499
    OBJECT                      testObject;
37✔
500
    TPM2B_DIGEST                testDigest;
37✔
501
    TPMT_SIGNATURE              testSig;
37✔
502
    // Do a sign and signature verification.
503
    // RSASSA:
504
    // This is a signing scheme according to PKCS#1-v2.1 8.2. It does not
505
    // use random data so there is a KVT for the signing operation. On
506
    // first use of the scheme for signing, use the TPM's RSA key to
507
    // sign a portion of c_RsaTestData and compare the results to c_RsassaKvt. Then
508
    // decrypt the data to see that it matches the starting value. This verifies
509
    // the signature with a KVT
510
    // Clear the bits indicating that the function has not been checked. This is to
511
    // prevent looping
512
    CLEAR_BOTH(scheme);
37✔
513
    CLEAR_BOTH(TPM_ALG_NULL);
37✔
514
    CLEAR_BOTH(TPM_ALG_RSA);
37✔
515
    RsaKeyInitialize(&testObject);
37✔
516
    memcpy(testDigest.t.buffer, (BYTE *)c_RsaTestValue, DEFAULT_TEST_DIGEST_SIZE);
37✔
517
    testDigest.t.size = DEFAULT_TEST_DIGEST_SIZE;
37✔
518
    testSig.sigAlg = scheme;
37✔
519
    testSig.signature.rsapss.hash = DEFAULT_TEST_HASH;
37✔
520
    // RSAPSS:
521
    // This is a signing scheme a according to PKCS#1-v2.2 8.1 it uses
522
    // random data in the signature so there is no KVT for the signing
523
    // operation. To test signing, the TPM will use the TPM's RSA key
524
    // to sign a portion of c_RsaTestValue and then it will verify the
525
    // signature. For verification, c_RsapssKvt is verified before the
526
    // user signature blob is verified. The worst case for testing of this
527
    // algorithm is two private and one public key operation.
528
    // The process is to sign known data. If RSASSA is being done, verify that the
529
    // signature matches the precomputed value. For both, use the signed value and
530
    // see that the verification says that it is a good signature. Then
531
    // if testing RSAPSS, do a verify of a known good signature. This ensures that
532
    // the validation function works.
533
    if(TPM_RC_SUCCESS != CryptRsaSign(&testSig, &testObject, &testDigest, NULL)) {
37✔
534
        SELF_TEST_FAILURE;
×
535
    }
536
    // For RSASSA, make sure the results is what we are looking for
537
    if(testSig.sigAlg == TPM_ALG_RSASSA)
37✔
538
        {
539
            if(testSig.signature.rsassa.sig.t.size != RSA_TEST_KEY_SIZE
25✔
540
               || !MemoryEqual(c_RsassaKvt.buffer,
25✔
541
                               testSig.signature.rsassa.sig.t.buffer,
542
                               RSA_TEST_KEY_SIZE)) {
543
                SELF_TEST_FAILURE;
×
544
            }
545
        }
546
    // See if the TPM will validate its own signatures
547
    if(TPM_RC_SUCCESS != CryptRsaValidateSignature(&testSig, &testObject,
37✔
548
                                                   &testDigest)) {
549
        SELF_TEST_FAILURE;
×
550
    }
551
    // If this is RSAPSS, check the verification with known signature
552
    // Have to copy because  CrytpRsaValidateSignature() eats the signature
553
    if(TPM_ALG_RSAPSS == scheme)
37✔
554
        {
555
            MemoryCopy2B(&testSig.signature.rsapss.sig.b, (P2B)&c_RsapssKvt,
12✔
556
                         sizeof(testSig.signature.rsapss.sig.t.buffer));
557
            if(TPM_RC_SUCCESS != CryptRsaValidateSignature(&testSig, &testObject,
12✔
558
                                                           &testDigest)) {
559
                SELF_TEST_FAILURE;
×
560
            }
561
        }
562
    return result;
37✔
563
}
564
/* 10.2.1.5.5 TestRSA() */
565
/* Function uses the provided vector to indicate which tests to run. It will clear the vector after
566
   each test is run and also clear g_toTest */
567
static TPM_RC
568
TestRsa(
89✔
569
        TPM_ALG_ID               alg,
570
        ALGORITHM_VECTOR        *toTest
571
        )
572
{
573
    TPM_RC                  result = TPM_RC_SUCCESS;
89✔
574
    //
575
    switch(alg)
89✔
576
        {
577
          case TPM_ALG_NULL:
27✔
578
            // This is the RSAEP/RSADP function. If we are processing a list, don't
579
            // need to test these now because any other test will validate
580
            // RSAEP/RSADP. Can tell this is list of test by checking to see if
581
            // 'toTest' is pointing at g_toTest. If so, this is an isolated test
582
            // an need to go ahead and do the test;
583
            if((toTest == &g_toTest)
27✔
584
               || (!TEST_BIT(TPM_ALG_RSASSA, *toTest)
20✔
585
                   && !TEST_BIT(TPM_ALG_RSAES, *toTest)
20✔
586
                   && !TEST_BIT(TPM_ALG_RSAPSS, *toTest)
20✔
587
                   && !TEST_BIT(TPM_ALG_OAEP, *toTest)))
20✔
588
                // Not running a list of tests or no other tests on the list
589
                // so run the test now
590
                result = TestRsaEncryptDecrypt(alg, toTest);
27✔
591
            // if not running the test now, leave the bit on, just in case things
592
            // get interrupted
593
            break;
594
          case TPM_ALG_OAEP:
25✔
595
          case TPM_ALG_RSAES:
596
            result = TestRsaEncryptDecrypt(alg, toTest);
25✔
597
            break;
25✔
598
          case TPM_ALG_RSAPSS:
37✔
599
          case TPM_ALG_RSASSA:
600
            result = TestRsaSignAndVerify(alg, toTest);
37✔
601
            break;
37✔
602
          default:
×
603
            SELF_TEST_FAILURE;
×
604
        }
605
    return result;
89✔
606
}
607
#endif // TPM_ALG_RSA
608
/* 10.2.1.6 ECC Tests */
609
#if ALG_ECC
610
/* 10.2.1.6.1 LoadEccParameter() */
611
/* This function is mostly for readability and type checking */
612
static void
613
LoadEccParameter(
359✔
614
                 TPM2B_ECC_PARAMETER          *to,       // target
615
                 const TPM2B_EC_TEST          *from      // source
616
                 )
617
{
618
    MemoryCopy2B(&to->b, &from->b, sizeof(to->t.buffer));
359✔
619
}
70✔
620
/* 10.2.1.6.2 LoadEccPoint() */
621
static void
622
LoadEccPoint(
289✔
623
             TPMS_ECC_POINT               *point,       // target
624
             const TPM2B_EC_TEST          *x,             // source
625
             const TPM2B_EC_TEST           *y
626
             )
627
{
628
    MemoryCopy2B(&point->x.b, (TPM2B *)x, sizeof(point->x.t.buffer));
289✔
629
    MemoryCopy2B(&point->y.b, (TPM2B *)y, sizeof(point->y.t.buffer));
289✔
630
}
289✔
631
/* 10.2.1.6.3 TestECDH() */
632
/* This test does a KVT on a point multiply. */
633
static TPM_RC
634
TestECDH(
219✔
635
         TPM_ALG_ID          scheme,         // IN: for consistency
636
         ALGORITHM_VECTOR    *toTest         // IN/OUT: modified after test is run
637
         )
638
{
639
    TPMS_ECC_POINT          Z;
219✔
640
    TPMS_ECC_POINT          Qe;
219✔
641
    TPM2B_ECC_PARAMETER     ds;
219✔
642
    TPM_RC                  result = TPM_RC_SUCCESS;
219✔
643
    //
644
    NOT_REFERENCED(scheme);
219✔
645
    CLEAR_BOTH(TPM_ALG_ECDH);
219✔
646
    LoadEccParameter(&ds, &c_ecTestKey_ds);
219✔
647
    LoadEccPoint(&Qe, &c_ecTestKey_QeX, &c_ecTestKey_QeY);
219✔
648
    if(TPM_RC_SUCCESS != CryptEccPointMultiply(&Z, c_testCurve, &Qe, &ds,
219✔
649
                                               NULL, NULL)) {
650
        SELF_TEST_FAILURE;
×
651
    }
652
    if(!MemoryEqual2B(&c_ecTestEcdh_X.b, &Z.x.b)
219✔
653
       || !MemoryEqual2B(&c_ecTestEcdh_Y.b, &Z.y.b)) {
219✔
654
        SELF_TEST_FAILURE;
×
655
    }
656
    return result;
219✔
657
}
658
/* 10.2.1.6.4        TestEccSignAndVerify() */
659
static TPM_RC
660
TestEccSignAndVerify(
70✔
661
                     TPM_ALG_ID                   scheme,
662
                     ALGORITHM_VECTOR            *toTest
663
                     )
664
{
665
    OBJECT                       testObject;
70✔
666
    TPMT_SIGNATURE               testSig;
70✔
667
    TPMT_ECC_SCHEME              eccScheme;
70✔
668
    testSig.sigAlg = scheme;
70✔
669
    testSig.signature.ecdsa.hash = DEFAULT_TEST_HASH;
70✔
670
    eccScheme.scheme = scheme;
70✔
671
    eccScheme.details.anySig.hashAlg = DEFAULT_TEST_HASH;
70✔
672
    CLEAR_BOTH(scheme);
70✔
673
    CLEAR_BOTH(TPM_ALG_ECDH);
70✔
674
    // ECC signature verification testing uses a KVT.
675
    switch(scheme)
70✔
676
        {
677
          case TPM_ALG_ECDSA:
678
            LoadEccParameter(&testSig.signature.ecdsa.signatureR, &c_TestEcDsa_r);
59✔
679
            LoadEccParameter(&testSig.signature.ecdsa.signatureS, &c_TestEcDsa_s);
59✔
680
            break;
681
          case TPM_ALG_ECSCHNORR:
682
            LoadEccParameter(&testSig.signature.ecschnorr.signatureR,
11✔
683
                             &c_TestEcSchnorr_r);
684
            LoadEccParameter(&testSig.signature.ecschnorr.signatureS,
11✔
685
                             &c_TestEcSchnorr_s);
686
            break;
687
          case TPM_ALG_SM2:
688
            // don't have a test for SM2
689
            return TPM_RC_SUCCESS;
690
          default:
×
691
            SELF_TEST_FAILURE;
×
692
            break;
70✔
693
        }
694
    TEST_DEFAULT_TEST_HASH(toTest);
70✔
695
    // Have to copy the key. This is because the size used in the test vectors
696
    // is the size of the ECC parameter for the test key while the size of a point
697
    // is TPM dependent
698
    MemoryCopy2B(&testObject.sensitive.sensitive.ecc.b, &c_ecTestKey_ds.b,
70✔
699
                 sizeof(testObject.sensitive.sensitive.ecc.t.buffer));
700
    LoadEccPoint(&testObject.publicArea.unique.ecc, &c_ecTestKey_QsX,
70✔
701
                 &c_ecTestKey_QsY);
702
    testObject.publicArea.parameters.eccDetail.curveID = c_testCurve;
70✔
703
    if(TPM_RC_SUCCESS != CryptEccValidateSignature(&testSig, &testObject,
70✔
704
                                                   (TPM2B_DIGEST *)&c_ecTestValue.b))
705
        {
706
            SELF_TEST_FAILURE;
×
707
        }
708
    CHECK_CANCELED;
70✔
709
    // Now sign and verify some data
710
    if(TPM_RC_SUCCESS != CryptEccSign(&testSig, &testObject,
70✔
711
                                      (TPM2B_DIGEST *)&c_ecTestValue,
712
                                      &eccScheme, NULL)) {
713
        SELF_TEST_FAILURE;
×
714
    }
715
    CHECK_CANCELED;
70✔
716
    if(TPM_RC_SUCCESS != CryptEccValidateSignature(&testSig, &testObject,
70✔
717
                                                   (TPM2B_DIGEST *)&c_ecTestValue)) {
718
        SELF_TEST_FAILURE;
×
719
    }
720
    CHECK_CANCELED;
70✔
721
    return TPM_RC_SUCCESS;
722
}
723
/* 10.2.1.6.5        TestKDFa() */
724

725
static TPM_RC
726
TestKDFa(
66✔
727
         ALGORITHM_VECTOR        *toTest
728
         )
729
{
730
    static TPM2B_KDF_TEST_KEY   keyOut;
66✔
731
    UINT32                      counter = 0;
66✔
732
    //
733
    CLEAR_BOTH(TPM_ALG_KDF1_SP800_108);
66✔
734
    keyOut.t.size = CryptKDFa(KDF_TEST_ALG, &c_kdfTestKeyIn.b, &c_kdfTestLabel.b,
66✔
735
                              &c_kdfTestContextU.b, &c_kdfTestContextV.b,
736
                              TEST_KDF_KEY_SIZE * 8, keyOut.t.buffer,
737
                              &counter, FALSE);
738
    if (   keyOut.t.size != TEST_KDF_KEY_SIZE
66✔
739
           || !MemoryEqual(keyOut.t.buffer, c_kdfTestKeyOut.t.buffer,
66✔
740
                           TEST_KDF_KEY_SIZE))
741
        SELF_TEST_FAILURE;
×
742
    return TPM_RC_SUCCESS;
66✔
743
}
744
/* 10.2.1.6.6        TestEcc() */
745
static TPM_RC
746
TestEcc(
289✔
747
        TPM_ALG_ID              alg,
748
        ALGORITHM_VECTOR        *toTest
749
        )
750
{
751
    TPM_RC                  result = TPM_RC_SUCCESS;
289✔
752
    NOT_REFERENCED(toTest);
289✔
753
    switch(alg)
289✔
754
        {
755
          case TPM_ALG_ECC:
219✔
756
          case TPM_ALG_ECDH:
757
            // If this is in a loop then see if another test is going to deal with
758
            // this.
759
            // If toTest is not a self-test list
760
            if((toTest == &g_toTest)
219✔
761
               // or this is the only ECC test in the list
762
               || !(TEST_BIT(TPM_ALG_ECDSA, *toTest)
×
763
                    || TEST_BIT(TPM_ALG_ECSCHNORR, *toTest)
×
764
                    || TEST_BIT(TPM_ALG_SM2, *toTest)))
×
765
                {
766
                    result = TestECDH(alg, toTest);
219✔
767
                }
768
            break;
769
          case TPM_ALG_ECDSA:
70✔
770
          case TPM_ALG_ECSCHNORR:
771
          case TPM_ALG_SM2:
772
            result = TestEccSignAndVerify(alg, toTest);
70✔
773
            break;
70✔
774
          default:
×
775
            SELF_TEST_FAILURE;
×
776
            break;
289✔
777
        }
778
    return result;
289✔
779
}
780
#endif // TPM_ALG_ECC
781
/* 10.2.1.6.4 TestAlgorithm() */
782
/* Dispatches to the correct test function for the algorithm or gets a list of testable
783
   algorithms. */
784
/* If toTest is not NULL, then the test decisions are based on the algorithm selections in
785
   toTest. Otherwise, g_toTest is used. When bits are clear in g_toTest they will also be cleared
786
   toTest. */
787
/* If there doesn't happen to be a test for the algorithm, its associated bit is quietly cleared. */
788
/* If alg is zero (TPM_ALG_ERROR), then the toTest vector is cleared of any bits for which there is
789
   no test (i.e. no tests are actually run but the vector is cleared). */
790
/* NOTE: toTest will only ever have bits set for implemented algorithms but alg can be anything. */
791
/* Error Returns Meaning */
792
/* TPM_RC_CANCELED test was canceled */
793
LIB_EXPORT
794
TPM_RC
795
TestAlgorithm(
22,131✔
796
              TPM_ALG_ID               alg,
797
              ALGORITHM_VECTOR        *toTest
798
              )
799
{
800
    TPM_ALG_ID              first = (alg == TPM_ALG_ERROR) ? TPM_ALG_FIRST : alg;
22,131✔
801
    TPM_ALG_ID              last = (alg == TPM_ALG_ERROR) ? TPM_ALG_LAST : alg;
22,131✔
802
    BOOL                    doTest = (alg != TPM_ALG_ERROR);
22,131✔
803
    TPM_RC                  result = TPM_RC_SUCCESS;
22,131✔
804
    if(toTest == NULL)
22,131✔
805
        toTest = &g_toTest;
9,614✔
806
    // This is kind of strange. This function will either run a test of the selected
807
    // algorithm or just clear a bit if there is no test for the algorithm. So,
808
    // either this loop will be executed once for the selected algorithm or once for
809
    // each of the possible algorithms. If it is executed more than once ('alg' ==
810
    // TPM_ALG_ERROR), then no test will be run but bits will be cleared for
811
    // unimplemented algorithms. This was done this way so that there is only one
812
    // case statement with all of the algorithms. It was easier to have one case
813
    // statement than to have multiple ones to manage whenever an algorithm ID is
814
    // added.
815
    for(alg = first; (alg <= last); alg++)
862,533✔
816
        {
817
            // if 'alg' was TPM_ALG_ERROR, then we will be cycling through
818
            // values, some of which may not be implemented. If the bit in toTest
819
            // happens to be set, then we could either generated an assert, or just
820
            // silently CLEAR it. Decided to just clear.
821
            if(!TEST_BIT(alg, g_implementedAlgorithms))
840,402✔
822
                {
823
                    CLEAR_BIT(alg, *toTest);
427,455✔
824
                    continue;
427,455✔
825
                }
826
            // Process whatever is left.
827
            // NOTE: since this switch will only be called if the algorithm is
828
            // implemented, it is not necessary to modify this list except to comment
829
            // out the algorithms for which there is no test
830
            switch(alg)
412,947✔
831
                {
832
                    // Symmetric block ciphers
833
#if ALG_AES
834
                  case TPM_ALG_AES:
12,236✔
835
// libtpms added begin
836
#if SMAC_IMPLEMENTED && ALG_CMAC
837
                    if (doTest) {
12,236✔
838
                         result = TestSMAC(toTest);
23✔
839
                         if (result != TPM_RC_SUCCESS)
23✔
840
                             break;
841
                    }
842
#endif
843
// libtpms added end
844
#endif
845
#if ALG_SM4
846
                    // if SM4 is implemented, its test is like other block ciphers but there
847
                    // aren't any test vectors for it yet
848
                    //            case TPM_ALG_SM4:
849
#endif
850
#if ALG_CAMELLIA
851
                  case TPM_ALG_CAMELLIA:  // libtpms activated
852
#endif
853
#if ALG_TDES
854
                  case TPM_ALG_TDES:      // libtpms added
855
#endif
856
                    // Symmetric modes
857
#if !ALG_CFB
858
#   error   CFB is required in all TPM implementations
859
#endif // !TPM_ALG_CFB
860
                  case TPM_ALG_CFB:
861
                    if(doTest)
48,897✔
862
                        result = TestSymmetric(alg, toTest);
45✔
863
                    break;
864
#if ALG_CTR
865
                  case TPM_ALG_CTR:
48,860✔
866
#endif // TPM_ALG_CRT
867
#if ALG_OFB
868
                  case TPM_ALG_OFB:
869
#endif // TPM_ALG_OFB
870
#if ALG_CBC
871
                  case TPM_ALG_CBC:
872
#endif // TPM_ALG_CBC
873
#if ALG_ECB
874
                  case TPM_ALG_ECB:
875
#endif
876
                    if(doTest)
48,860✔
877
                        result = TestSymmetric(alg, toTest);
8✔
878
                    else
879
                        // If doing the initialization of g_toTest vector, only need
880
                        // to test one of the modes for the symmetric algorithms. If
881
                        // initializing for a SelfTest(FULL_TEST), allow all the modes.
882
                        if(toTest == &g_toTest)
48,852✔
883
                            CLEAR_BIT(alg, *toTest);
48,852✔
884
                    break;
885
#if !ALG_HMAC
886
#   error   HMAC is required in all TPM implementations
887
#endif
888
                  case TPM_ALG_HMAC:
12,220✔
889
                    // Clear the bit that indicates that HMAC is required because
890
                    // HMAC is used as the basic test for all hash algorithms.
891
                    CLEAR_BOTH(alg);
12,220✔
892
                    // Testing HMAC means test the default hash
893
                    if(doTest)
12,220✔
894
                        TestHash(DEFAULT_TEST_HASH, toTest);
7✔
895
                    else
896
                        // If not testing, then indicate that the hash needs to be
897
                        // tested because this uses HMAC
898
                        SET_BOTH(DEFAULT_TEST_HASH);
12,213✔
899
                    break;
900
                    // Have to use two arguments for the macro even though only the first is used in the
901
                    // expansion.
902
#define HASH_CASE_TEST(HASH, hash)                                        \
903
                    case ALG_##HASH##_VALUE:
904
                    FOR_EACH_HASH(HASH_CASE_TEST)
58,188✔
905
#undef HASH_CASE_TEST
906
                        if(doTest)
58,188✔
907
                            result = TestHash(alg, toTest);
9,336✔
908
                    break;
909
                    // RSA-dependent
910
#if ALG_RSA
911
                  case TPM_ALG_RSA:
12,240✔
912
                    CLEAR_BOTH(alg);
12,240✔
913
                    if(doTest)
12,240✔
914
                        result = TestRsa(TPM_ALG_NULL, toTest);
27✔
915
                    else
916
                        SET_BOTH(TPM_ALG_NULL);
12,213✔
917
                    break;
918
                  case TPM_ALG_RSASSA:
48,914✔
919
                  case TPM_ALG_RSAES:
920
                  case TPM_ALG_RSAPSS:
921
                  case TPM_ALG_OAEP:
922
                  case TPM_ALG_NULL:    // used or RSADP
923
                    if(doTest)
48,914✔
924
                        result = TestRsa(alg, toTest);
62✔
925
                    break;
926
#endif // ALG_RSA
927
#if ALG_KDF1_SP800_108
928
                  case TPM_ALG_KDF1_SP800_108:
12,279✔
929
                    if(doTest)
12,279✔
930
                        result = TestKDFa(toTest);
66✔
931
                    break;
932
#endif // ALG_KDF1_SP800_108
933
#if ALG_ECC
934
                    // ECC dependent but no tests
935
                    //        case TPM_ALG_ECDAA:
936
                    //        case TPM_ALG_ECMQV:
937
                    //        case TPM_ALG_KDF1_SP800_56a:
938
                    //        case TPM_ALG_KDF2:
939
                    //        case TPM_ALG_MGF1:
940
                  case TPM_ALG_ECC:
12,220✔
941
                    CLEAR_BOTH(alg);
12,220✔
942
                    if(doTest)
12,220✔
943
                        result = TestEcc(TPM_ALG_ECDH, toTest);
7✔
944
                    else
945
                        SET_BOTH(TPM_ALG_ECDH);
12,213✔
946
                    break;
947
                  case TPM_ALG_ECDSA:
36,921✔
948
                  case TPM_ALG_ECDH:
949
                  case TPM_ALG_ECSCHNORR:
950
                    //            case TPM_ALG_SM2:
951
                    if(doTest)
36,921✔
952
                        result = TestEcc(alg, toTest);
282✔
953
                    break;
954
#endif // ALG_ECC
955
                  default:
122,208✔
956
                    CLEAR_BIT(alg, *toTest);
122,208✔
957
                    break;
122,208✔
958
                }
959
            if(result != TPM_RC_SUCCESS)
412,947✔
960
                break;
961
        }
962
    return result;
22,131✔
963
}
964
#endif // SELF_TESTS
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc