Lines Matching +full:x +full:- +full:size

3  * Use of this source code is governed by a BSD-style
5 * SPDX-License-Identifier: BSD-2-Clause
44 uint16_t size; /* sizeof(body) */ in PACKED_TYPE()
51 uint16_t size; /* sizeof(body) */
58 uint16_t size; /* sizeof(alg) + sizeof(body) */
88 uint16_t size; /* sizeof(body) */
95 uint16_t size; /* sizeof(body) */
102 tpm_es256_coord_t x;
152 int ok = -1;
154 if ((dgst->size = sizeof(dgst->body)) != SHA_DIGEST_LENGTH ||
158 EVP_DigestUpdate(ctx, authdata->ptr, authdata->len) != 1 ||
159 EVP_DigestUpdate(ctx, clientdata->ptr, clientdata->len) != 1 ||
160 EVP_DigestFinal_ex(ctx, dgst->body, NULL) != 1) {
175 name->alg = TPM_ALG_SHA256; in get_signed_name()
176 name->size = sizeof(name->alg) + sizeof(name->body); in get_signed_name()
177 if (sizeof(name->body) != SHA256_DIGEST_LENGTH || in get_signed_name()
178 SHA256(pubarea->ptr, pubarea->len, name->body) != name->body) { in get_signed_name()
180 return -1; in get_signed_name()
187 bswap_rs256_pubarea(tpm_rs256_pubarea_t *x) in bswap_rs256_pubarea() argument
189 x->alg = htobe16(x->alg); in bswap_rs256_pubarea()
190 x->hash = htobe16(x->hash); in bswap_rs256_pubarea()
191 x->attr = htobe32(x->attr); in bswap_rs256_pubarea()
192 x->policy.size = htobe16(x->policy.size); in bswap_rs256_pubarea()
193 x->param.symmetric = htobe16(x->param.symmetric); in bswap_rs256_pubarea()
194 x->param.scheme = htobe16(x->param.scheme); in bswap_rs256_pubarea()
195 x->param.keybits = htobe16(x->param.keybits); in bswap_rs256_pubarea()
196 x->key.size = htobe16(x->key.size); in bswap_rs256_pubarea()
200 bswap_es256_pubarea(tpm_es256_pubarea_t *x) in bswap_es256_pubarea() argument
202 x->alg = htobe16(x->alg); in bswap_es256_pubarea()
203 x->hash = htobe16(x->hash); in bswap_es256_pubarea()
204 x->attr = htobe32(x->attr); in bswap_es256_pubarea()
205 x->policy.size = htobe16(x->policy.size); in bswap_es256_pubarea()
206 x->param.symmetric = htobe16(x->param.symmetric); in bswap_es256_pubarea()
207 x->param.scheme = htobe16(x->param.scheme); in bswap_es256_pubarea()
208 x->param.curve_id = htobe16(x->param.curve_id); in bswap_es256_pubarea()
209 x->param.kdf = htobe16(x->param.kdf); in bswap_es256_pubarea()
210 x->point.x.size = htobe16(x->point.x.size); in bswap_es256_pubarea()
211 x->point.y.size = htobe16(x->point.y.size); in bswap_es256_pubarea()
215 bswap_sha1_certinfo(tpm_sha1_attest_t *x) in bswap_sha1_certinfo() argument
217 x->magic = htobe32(x->magic); in bswap_sha1_certinfo()
218 x->type = htobe16(x->type); in bswap_sha1_certinfo()
219 x->signer.size = htobe16(x->signer.size); in bswap_sha1_certinfo()
220 x->data.size = htobe16(x->data.size); in bswap_sha1_certinfo()
221 x->name.alg = htobe16(x->name.alg); in bswap_sha1_certinfo()
222 x->name.size = htobe16(x->name.size); in bswap_sha1_certinfo()
232 if (buf->len != sizeof(*actual)) { in check_rs256_pubarea()
233 fido_log_debug("%s: buf->len=%zu", __func__, buf->len); in check_rs256_pubarea()
234 return -1; in check_rs256_pubarea()
236 actual = (const void *)buf->ptr; in check_rs256_pubarea()
241 expected.attr = be32toh(actual->attr); in check_rs256_pubarea()
244 expected.policy = actual->policy; in check_rs256_pubarea()
245 expected.policy.size = sizeof(expected.policy.body); in check_rs256_pubarea()
250 expected.key.size = sizeof(expected.key.body); in check_rs256_pubarea()
251 memcpy(&expected.key.body, &pk->n, sizeof(expected.key.body)); in check_rs256_pubarea()
257 return ok != 0 ? -1 : 0; in check_rs256_pubarea()
267 if (buf->len != sizeof(*actual)) { in check_es256_pubarea()
268 fido_log_debug("%s: buf->len=%zu", __func__, buf->len); in check_es256_pubarea()
269 return -1; in check_es256_pubarea()
271 actual = (const void *)buf->ptr; in check_es256_pubarea()
276 expected.attr = be32toh(actual->attr); in check_es256_pubarea()
279 expected.policy = actual->policy; in check_es256_pubarea()
280 expected.policy.size = sizeof(expected.policy.body); in check_es256_pubarea()
285 expected.point.x.size = sizeof(expected.point.x.body); in check_es256_pubarea()
286 expected.point.y.size = sizeof(expected.point.y.body); in check_es256_pubarea()
287 memcpy(&expected.point.x.body, &pk->x, sizeof(expected.point.x.body)); in check_es256_pubarea()
288 memcpy(&expected.point.y.body, &pk->y, sizeof(expected.point.y.body)); in check_es256_pubarea()
294 return ok != 0 ? -1 : 0; in check_es256_pubarea()
305 int ok = -1; in check_sha1_certinfo()
315 if (buf->len != sizeof(*actual)) { in check_sha1_certinfo()
316 fido_log_debug("%s: buf->len=%zu", __func__, buf->len); in check_sha1_certinfo()
319 actual = (const void *)buf->ptr; in check_sha1_certinfo()
324 expected.signer = actual->signer; in check_sha1_certinfo()
325 expected.signer.size = sizeof(expected.signer.alg) + in check_sha1_certinfo()
328 expected.clock = actual->clock; in check_sha1_certinfo()
330 expected.fwversion = actual->fwversion; in check_sha1_certinfo()
332 expected.qual_name = actual->qual_name; in check_sha1_certinfo()
341 return ok != 0 ? -1 : 0; in check_sha1_certinfo()
349 const fido_blob_t *pubarea = &attstmt->pubarea; in fido_get_signed_hash_tpm()
350 const fido_blob_t *certinfo = &attstmt->certinfo; in fido_get_signed_hash_tpm()
352 if (attstmt->alg != COSE_RS1) { in fido_get_signed_hash_tpm()
354 attstmt->alg); in fido_get_signed_hash_tpm()
355 return -1; in fido_get_signed_hash_tpm()
358 switch (attcred->type) { in fido_get_signed_hash_tpm()
360 if (check_es256_pubarea(pubarea, &attcred->pubkey.es256) < 0) { in fido_get_signed_hash_tpm()
362 return -1; in fido_get_signed_hash_tpm()
366 if (check_rs256_pubarea(pubarea, &attcred->pubkey.rs256) < 0) { in fido_get_signed_hash_tpm()
368 return -1; in fido_get_signed_hash_tpm()
373 attcred->type); in fido_get_signed_hash_tpm()
374 return -1; in fido_get_signed_hash_tpm()
380 return -1; in fido_get_signed_hash_tpm()
383 if (dgst->len < SHA_DIGEST_LENGTH || in fido_get_signed_hash_tpm()
384 SHA1(certinfo->ptr, certinfo->len, dgst->ptr) != dgst->ptr) { in fido_get_signed_hash_tpm()
386 return -1; in fido_get_signed_hash_tpm()
388 dgst->len = SHA_DIGEST_LENGTH; in fido_get_signed_hash_tpm()