[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] vtpmmgr: fix 32-bit compilation



The internal MPI word size matches the word size of the platform rather
than using uint32_t/uint64_t, so constant MPI objects need to be
initialized with that in mind.

Signed-off-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
---
 stubdom/vtpmmgr/vtpm_cmd_handler.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/stubdom/vtpmmgr/vtpm_cmd_handler.c 
b/stubdom/vtpmmgr/vtpm_cmd_handler.c
index 000cce8..4ef1da8 100644
--- a/stubdom/vtpmmgr/vtpm_cmd_handler.c
+++ b/stubdom/vtpmmgr/vtpm_cmd_handler.c
@@ -451,6 +451,7 @@ static TPM_RESULT vtpmmgr_GroupActivate(tpmcmd_t* tpmcmd)
  * mpi objects use little endian word ordering
  */
 static t_uint Pp[256 / sizeof(t_uint)] = {
+#ifdef __x86_64__
        0xFFFFFFFFFFFFFFFFUL, 0x15728E5A8AACAA68UL, 0x15D2261898FA0510UL,
        0x3995497CEA956AE5UL, 0xDE2BCBF695581718UL, 0xB5C55DF06F4C52C9UL,
        0x9B2783A2EC07A28FUL, 0xE39E772C180E8603UL, 0x32905E462E36CE3BUL,
@@ -462,6 +463,19 @@ static t_uint Pp[256 / sizeof(t_uint)] = {
        0x302B0A6DF25F1437UL, 0xEF9519B3CD3A431BUL, 0x514A08798E3404DDUL,
        0x020BBEA63B139B22UL, 0x29024E088A67CC74UL, 0xC4C6628B80DC1CD1UL,
        0xC90FDAA22168C234UL, 0xFFFFFFFFFFFFFFFFUL,
+#else
+       0xFFFFFFFF, 0xFFFFFFFF, 0x8AACAA68, 0x15728E5A, 0x98FA0510, 0x15D22618,
+       0xEA956AE5, 0x3995497C, 0x95581718, 0xDE2BCBF6, 0x6F4C52C9, 0xB5C55DF0,
+       0xEC07A28F, 0x9B2783A2, 0x180E8603, 0xE39E772C, 0x2E36CE3B, 0x32905E46,
+       0xCA18217C, 0xF1746C08, 0x4ABC9804, 0x670C354E, 0x7096966D, 0x9ED52907,
+       0x208552BB, 0x1C62F356, 0xDCA3AD96, 0x83655D23, 0xFD24CF5F, 0x69163FA8,
+       0x1C55D39A, 0x98DA4836, 0xA163BF05, 0xC2007CB8, 0xECE45B3D, 0x49286651,
+       0x7C4B1FE6, 0xAE9F2411, 0x5A899FA5, 0xEE386BFB, 0xF406B7ED, 0x0BFF5CB6,
+       0xA637ED6B, 0xF44C42E9, 0x625E7EC6, 0xE485B576, 0x6D51C245, 0x4FE1356D,
+       0xF25F1437, 0x302B0A6D, 0xCD3A431B, 0xEF9519B3, 0x8E3404DD, 0x514A0879,
+       0x3B139B22, 0x020BBEA6, 0x8A67CC74, 0x29024E08, 0x80DC1CD1, 0xC4C6628B,
+       0x2168C234, 0xC90FDAA2, 0xFFFFFFFF, 0xFFFFFFFF,
+#endif
 };
 static t_uint Gp[] = { 2 };
 
@@ -469,15 +483,16 @@ static void tm_dhkx_gen(void* dhkx1, void* dhkx2, void* 
out)
 {
        mpi GX = { 0 }, GY = { 0 }, K = { 0 }, RP = { 0 };
 
-       t_uint Xp[256 / sizeof(t_uint)];
+       int XpElts = 256 / sizeof(t_uint);
+       t_uint Xp[XpElts];
        mpi X = {
                .s = 1,
-               .n = sizeof(Xp)/sizeof(Xp[0]),
+               .n = XpElts,
                .p = Xp
        };
        mpi P = {
                .s = 1,
-               .n = sizeof(Pp)/sizeof(Pp[0]),
+               .n = XpElts,
                .p = Pp,
        };
        mpi G = {
@@ -487,8 +502,8 @@ static void tm_dhkx_gen(void* dhkx1, void* dhkx2, void* out)
        };
 
        do_random(Xp, sizeof(Xp));
-       while (Xp[31] == 0 || Xp[31] == -1UL)
-               do_random(Xp + 31, sizeof(Xp[31]));
+       while (Xp[XpElts - 1] == 0 || Xp[XpElts - 1] == -1UL)
+               do_random(Xp + XpElts - 1, sizeof(Xp[0]));
 
        mpi_exp_mod(&GX, &G, &X, &P, &RP);
        mpi_write_binary(&GX, dhkx2, 256);
-- 
1.9.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.