Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: crypto/bn.c

Issue 660204: Upgrade to tpm-emulator version 0.7. (Closed)
Patch Set: Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « crypto/bn.h ('k') | crypto/hmac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Software-Based Trusted Platform Module (TPM) Emulator for Linux 1 /* Software-based Trusted Platform Module (TPM) Emulator
2 * Copyright (C) 2006 Mario Strasser <mast@gmx.net>, 2 * Copyright (C) 2004-2010 Mario Strasser <mast@gmx.net>
3 * Swiss Federal Institute of Technology (ETH) Zurich
4 * 3 *
5 * This module is free software; you can redistribute it and/or modify 4 * This module is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published 5 * it under the terms of the GNU General Public License as published
7 * by the Free Software Foundation; either version 2 of the License, 6 * by the Free Software Foundation; either version 2 of the License,
8 * or (at your option) any later version. 7 * or (at your option) any later version.
9 * 8 *
10 * This module is distributed in the hope that it will be useful, 9 * This module is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 12 * GNU General Public License for more details.
14 * 13 *
15 * $Id$ 14 * $Id: bn.c 406 2010-02-19 11:08:30Z mast $
16 */ 15 */
17 16
18 #include "bn.h" 17 #include "bn.h"
19 18
20 void tpm_bn_init(tpm_bn_t a) 19 void tpm_bn_init(tpm_bn_t a)
21 { 20 {
22 mpz_init(a); 21 mpz_init(a);
23 } 22 }
24 23
25 void tpm_bn_init2(tpm_bn_t a, size_t nbits) 24 void tpm_bn_init2(tpm_bn_t a, size_t nbits)
26 { 25 {
27 mpz_init2(a, nbits + + GMP_NUMB_BITS); 26 mpz_init2(a, nbits + GMP_NUMB_BITS);
28 } 27 }
29 28
30 void tpm_bn_init_set(tpm_bn_t a, tpm_bn_t val) 29 void tpm_bn_init_set(tpm_bn_t a, tpm_bn_t val)
31 { 30 {
32 mpz_init_set(a, val); 31 mpz_init_set(a, val);
33 } 32 }
34 33
35 void tpm_bn_init_set_ui(tpm_bn_t a, uint32_t val) 34 void tpm_bn_init_set_ui(tpm_bn_t a, uint32_t val)
36 { 35 {
37 mpz_init_set_ui(a, val); 36 mpz_init_set_ui(a, val);
(...skipping 19 matching lines...) Expand all
57 return mpz_sizeinbase(a, 2); 56 return mpz_sizeinbase(a, 2);
58 } 57 }
59 58
60 void tpm_bn_import(tpm_bn_t out, size_t count, int order, const void *in) 59 void tpm_bn_import(tpm_bn_t out, size_t count, int order, const void *in)
61 { 60 {
62 mpz_import(out, count, order, 1, 0, 0, in); 61 mpz_import(out, count, order, 1, 0, 0, in);
63 } 62 }
64 63
65 void tpm_bn_export(void *out, size_t *count, int order, tpm_bn_t in) 64 void tpm_bn_export(void *out, size_t *count, int order, tpm_bn_t in)
66 { 65 {
67 mpz_export(out, count, order, 1, 0, 0, in); 66 size_t count_out;
67 mpz_export(out, &count_out, order, 1, 0, 0, in);
68 if (count != NULL) *count = count_out;
68 } 69 }
69 70
70 int tpm_bn_cmp(tpm_bn_t a, tpm_bn_t b) 71 int tpm_bn_cmp(tpm_bn_t a, tpm_bn_t b)
71 { 72 {
72 return mpz_cmp(a, b); 73 return mpz_cmp(a, b);
73 } 74 }
74 75
75 int tpm_bn_cmp_ui(tpm_bn_t a, uint32_t b) 76 int tpm_bn_cmp_ui(tpm_bn_t a, uint32_t b)
76 { 77 {
77 return mpz_cmp_ui(a, b); 78 return mpz_cmp_ui(a, b);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 { 147 {
147 mpz_invert(res, a, b); 148 mpz_invert(res, a, b);
148 } 149 }
149 150
150 void tpm_bn_nextprime(tpm_bn_t res, tpm_bn_t a) 151 void tpm_bn_nextprime(tpm_bn_t res, tpm_bn_t a)
151 { 152 {
152 mpz_nextprime(res, a); 153 mpz_nextprime(res, a);
153 } 154 }
154 155
155 156
OLDNEW
« no previous file with comments | « crypto/bn.h ('k') | crypto/hmac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698