1 /*############################################################################
2 # Copyright 2016 Intel Corporation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 ############################################################################*/
16
17 /*!
18 * \file
19 * \brief Epid11CheckPrivRlEntry implementation.
20 */
21
22 #include "epid/verifier/1.1/api.h"
23 #include "epid/verifier/1.1/src/context.h"
Epid11CheckPrivRlEntry(Epid11VerifierCtx const * ctx,Epid11BasicSignature const * sig,FpElemStr const * f)24 EpidStatus Epid11CheckPrivRlEntry(Epid11VerifierCtx const* ctx,
25 Epid11BasicSignature const* sig,
26 FpElemStr const* f) {
27 EpidStatus result = kEpidErr;
28 EcPoint* b = NULL;
29 EcPoint* k = NULL;
30 EcPoint* t5 = NULL;
31 EcGroup* G3 = NULL;
32 if (!ctx || !sig || !f) {
33 return kEpidBadArgErr;
34 }
35 if (!ctx->epid11_params || !ctx->epid11_params->G3) {
36 return kEpidBadArgErr;
37 }
38 do {
39 // Section 4.1.2 Step 31. The verifier computes t5 = G3.exp(B, f)
40 // and verifies that G3.isEqual(t5, K) = false
41 bool compare_result = false;
42 G3 = ctx->epid11_params->G3;
43 result = NewEcPoint(G3, &b);
44 if (kEpidNoErr != result) {
45 result = kEpidMathErr;
46 break;
47 }
48 result = NewEcPoint(G3, &k);
49 if (kEpidNoErr != result) {
50 result = kEpidMathErr;
51 break;
52 }
53 result = NewEcPoint(G3, &t5);
54 if (kEpidNoErr != result) {
55 result = kEpidMathErr;
56 break;
57 }
58 result = ReadEcPoint(G3, &sig->B, sizeof(sig->B), b);
59 if (kEpidNoErr != result) {
60 result = kEpidMathErr;
61 break;
62 }
63 result = ReadEcPoint(G3, &sig->K, sizeof(sig->K), k);
64 if (kEpidNoErr != result) {
65 result = kEpidMathErr;
66 break;
67 }
68 result = EcExp(G3, b, (BigNumStr const*)f, t5);
69 if (kEpidNoErr != result) {
70 result = kEpidMathErr;
71 break;
72 }
73 result = EcIsEqual(G3, t5, k, &compare_result);
74 if (kEpidNoErr != result) {
75 result = kEpidMathErr;
76 break;
77 }
78 // if t5 == k, sig revoked in PrivRl
79 if (compare_result) {
80 result = kEpidSigRevokedInPrivRl;
81 } else {
82 result = kEpidNoErr;
83 }
84 } while (0);
85
86 DeleteEcPoint(&t5);
87 DeleteEcPoint(&k);
88 DeleteEcPoint(&b);
89 return result;
90 }
91