From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Fioravante Subject: [PATH 9/12] VTPM mini-os: New stubdom applications Date: Fri, 11 Mar 2011 18:06:26 -0500 Message-ID: <4D7AAAF2.30302@jhuapl.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1510745431==" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a cryptographically signed message in MIME format. --===============1510745431== Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha1; boundary="------------ms090600000708010202080702" This is a cryptographically signed message in MIME format. --------------ms090600000708010202080702 Content-Type: multipart/mixed; boundary="------------090207050606030006040104" This is a multi-part message in MIME format. --------------090207050606030006040104 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable This patch ports 5 new applications to the stubdom makefile structure=20 for inclusion into stubdom domains. While these are required for=20 vtpm-stubdom and vtpmmgrdom they could be used with other stubdom=20 applications. -libgmp 4.3.2 -openssl 1.0.0a -polarssl 0.12.1 -berlios tpm_emulator 0.6.1 -vtpm_manager (from the tools directory) Signed off by: Matthew Fioravante --------------090207050606030006040104 Content-Type: text/x-patch; name="9-stubdom-newapps.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="9-stubdom-newapps.patch" diff -Naur xen-unstable-trp-sdp-pristine/stubdom/openssl.patch xen-unstab= le-trp-sdp/stubdom/openssl.patch --- xen-unstable-trp-sdp-pristine/stubdom/openssl.patch 1969-12-31 19:00:= 00.000000000 -0500 +++ xen-unstable-trp-sdp/stubdom/openssl.patch 2011-02-23 19:40:48.000000= 000 -0500 @@ -0,0 +1,945 @@ +diff -Naur openssl-1.0.0a.pristine/crypto/bio/b_print.c openssl-1.0.0a/c= rypto/bio/b_print.c +--- openssl-1.0.0a.pristine/crypto/bio/b_print.c 2010-10-21 16:08:44.000= 000000 -0400 ++++ openssl-1.0.0a/crypto/bio/b_print.c 2010-10-29 11:32:48.000000000 -0= 400 +@@ -109,660 +109,6 @@ + * o ... (for OpenSSL) + */ +=20 +-#ifdef HAVE_LONG_DOUBLE +-#define LDOUBLE long double +-#else +-#define LDOUBLE double +-#endif +- +-#ifdef HAVE_LONG_LONG +-# if defined(_WIN32) && !defined(__GNUC__) +-# define LLONG __int64 +-# else +-# define LLONG long long +-# endif +-#else +-#define LLONG long +-#endif +- +-static void fmtstr (char **, char **, size_t *, size_t *, +- const char *, int, int, int); +-static void fmtint (char **, char **, size_t *, size_t *, +- LLONG, int, int, int, int); +-static void fmtfp (char **, char **, size_t *, size_t *, +- LDOUBLE, int, int, int); +-static void doapr_outch (char **, char **, size_t *, size_t *, int); +-static void _dopr(char **sbuffer, char **buffer, +- size_t *maxlen, size_t *retlen, int *truncated, +- const char *format, va_list args); +- +-/* format read states */ +-#define DP_S_DEFAULT 0 +-#define DP_S_FLAGS 1 +-#define DP_S_MIN 2 +-#define DP_S_DOT 3 +-#define DP_S_MAX 4 +-#define DP_S_MOD 5 +-#define DP_S_CONV 6 +-#define DP_S_DONE 7 +- +-/* format flags - Bits */ +-#define DP_F_MINUS (1 << 0) +-#define DP_F_PLUS (1 << 1) +-#define DP_F_SPACE (1 << 2) +-#define DP_F_NUM (1 << 3) +-#define DP_F_ZERO (1 << 4) +-#define DP_F_UP (1 << 5) +-#define DP_F_UNSIGNED (1 << 6) +- +-/* conversion flags */ +-#define DP_C_SHORT 1 +-#define DP_C_LONG 2 +-#define DP_C_LDOUBLE 3 +-#define DP_C_LLONG 4 +- +-/* some handy macros */ +-#define char_to_int(p) (p - '0') +-#define OSSL_MAX(p,q) ((p >=3D q) ? p : q) +- +-static void +-_dopr( +- char **sbuffer, +- char **buffer, +- size_t *maxlen, +- size_t *retlen, +- int *truncated, +- const char *format, +- va_list args) +-{ +- char ch; +- LLONG value; +- LDOUBLE fvalue; +- char *strvalue; +- int min; +- int max; +- int state; +- int flags; +- int cflags; +- size_t currlen; +- +- state =3D DP_S_DEFAULT; +- flags =3D currlen =3D cflags =3D min =3D 0; +- max =3D -1; +- ch =3D *format++; +- +- while (state !=3D DP_S_DONE) { +- if (ch =3D=3D '\0' || (buffer =3D=3D NULL && currlen >=3D *maxl= en)) +- state =3D DP_S_DONE; +- +- switch (state) { +- case DP_S_DEFAULT: +- if (ch =3D=3D '%') +- state =3D DP_S_FLAGS; +- else +- doapr_outch(sbuffer,buffer, &currlen, maxlen, ch); +- ch =3D *format++; +- break; +- case DP_S_FLAGS: +- switch (ch) { +- case '-': +- flags |=3D DP_F_MINUS; +- ch =3D *format++; +- break; +- case '+': +- flags |=3D DP_F_PLUS; +- ch =3D *format++; +- break; +- case ' ': +- flags |=3D DP_F_SPACE; +- ch =3D *format++; +- break; +- case '#': +- flags |=3D DP_F_NUM; +- ch =3D *format++; +- break; +- case '0': +- flags |=3D DP_F_ZERO; +- ch =3D *format++; +- break; +- default: +- state =3D DP_S_MIN; +- break; +- } +- break; +- case DP_S_MIN: +- if (isdigit((unsigned char)ch)) { +- min =3D 10 * min + char_to_int(ch); +- ch =3D *format++; +- } else if (ch =3D=3D '*') { +- min =3D va_arg(args, int); +- ch =3D *format++; +- state =3D DP_S_DOT; +- } else +- state =3D DP_S_DOT; +- break; +- case DP_S_DOT: +- if (ch =3D=3D '.') { +- state =3D DP_S_MAX; +- ch =3D *format++; +- } else +- state =3D DP_S_MOD; +- break; +- case DP_S_MAX: +- if (isdigit((unsigned char)ch)) { +- if (max < 0) +- max =3D 0; +- max =3D 10 * max + char_to_int(ch); +- ch =3D *format++; +- } else if (ch =3D=3D '*') { +- max =3D va_arg(args, int); +- ch =3D *format++; +- state =3D DP_S_MOD; +- } else +- state =3D DP_S_MOD; +- break; +- case DP_S_MOD: +- switch (ch) { +- case 'h': +- cflags =3D DP_C_SHORT; +- ch =3D *format++; +- break; +- case 'l': +- if (*format =3D=3D 'l') { +- cflags =3D DP_C_LLONG; +- format++; +- } else +- cflags =3D DP_C_LONG; +- ch =3D *format++; +- break; +- case 'q': +- cflags =3D DP_C_LLONG; +- ch =3D *format++; +- break; +- case 'L': +- cflags =3D DP_C_LDOUBLE; +- ch =3D *format++; +- break; +- default: +- break; +- } +- state =3D DP_S_CONV; +- break; +- case DP_S_CONV: +- switch (ch) { +- case 'd': +- case 'i': +- switch (cflags) { +- case DP_C_SHORT: +- value =3D (short int)va_arg(args, int); +- break; +- case DP_C_LONG: +- value =3D va_arg(args, long int); +- break; +- case DP_C_LLONG: +- value =3D va_arg(args, LLONG); +- break; +- default: +- value =3D va_arg(args, int); +- break; +- } +- fmtint(sbuffer, buffer, &currlen, maxlen, +- value, 10, min, max, flags); +- break; +- case 'X': +- flags |=3D DP_F_UP; +- /* FALLTHROUGH */ +- case 'x': +- case 'o': +- case 'u': +- flags |=3D DP_F_UNSIGNED; +- switch (cflags) { +- case DP_C_SHORT: +- value =3D (unsigned short int)va_arg(args, unsigned= int); +- break; +- case DP_C_LONG: +- value =3D (LLONG) va_arg(args, +- unsigned long int); +- break; +- case DP_C_LLONG: +- value =3D va_arg(args, unsigned LLONG); +- break; +- default: +- value =3D (LLONG) va_arg(args, +- unsigned int); +- break; +- } +- fmtint(sbuffer, buffer, &currlen, maxlen, value, +- ch =3D=3D 'o' ? 8 : (ch =3D=3D 'u' ? 10 : 16), +- min, max, flags); +- break; +- case 'f': +- if (cflags =3D=3D DP_C_LDOUBLE) +- fvalue =3D va_arg(args, LDOUBLE); +- else +- fvalue =3D va_arg(args, double); +- fmtfp(sbuffer, buffer, &currlen, maxlen, +- fvalue, min, max, flags); +- break; +- case 'E': +- flags |=3D DP_F_UP; +- case 'e': +- if (cflags =3D=3D DP_C_LDOUBLE) +- fvalue =3D va_arg(args, LDOUBLE); +- else +- fvalue =3D va_arg(args, double); +- break; +- case 'G': +- flags |=3D DP_F_UP; +- case 'g': +- if (cflags =3D=3D DP_C_LDOUBLE) +- fvalue =3D va_arg(args, LDOUBLE); +- else +- fvalue =3D va_arg(args, double); +- break; +- case 'c': +- doapr_outch(sbuffer, buffer, &currlen, maxlen, +- va_arg(args, int)); +- break; +- case 's': +- strvalue =3D va_arg(args, char *); +- if (max < 0) { +- if (buffer) +- max =3D INT_MAX; +- else +- max =3D *maxlen; +- } +- fmtstr(sbuffer, buffer, &currlen, maxlen, strvalue, +- flags, min, max); +- break; +- case 'p': +- value =3D (long)va_arg(args, void *); +- fmtint(sbuffer, buffer, &currlen, maxlen, +- value, 16, min, max, flags|DP_F_NUM); +- break; +- case 'n': /* XXX */ +- if (cflags =3D=3D DP_C_SHORT) { +- short int *num; +- num =3D va_arg(args, short int *); +- *num =3D currlen; +- } else if (cflags =3D=3D DP_C_LONG) { /* XXX */ +- long int *num; +- num =3D va_arg(args, long int *); +- *num =3D (long int) currlen; +- } else if (cflags =3D=3D DP_C_LLONG) { /* XXX */ +- LLONG *num; +- num =3D va_arg(args, LLONG *); +- *num =3D (LLONG) currlen; +- } else { +- int *num; +- num =3D va_arg(args, int *); +- *num =3D currlen; +- } +- break; +- case '%': +- doapr_outch(sbuffer, buffer, &currlen, maxlen, ch); +- break; +- case 'w': +- /* not supported yet, treat as next char */ +- ch =3D *format++; +- break; +- default: +- /* unknown, skip */ +- break; +- } +- ch =3D *format++; +- state =3D DP_S_DEFAULT; +- flags =3D cflags =3D min =3D 0; +- max =3D -1; +- break; +- case DP_S_DONE: +- break; +- default: +- break; +- } +- } +- *truncated =3D (currlen > *maxlen - 1); +- if (*truncated) +- currlen =3D *maxlen - 1; +- doapr_outch(sbuffer, buffer, &currlen, maxlen, '\0'); +- *retlen =3D currlen - 1; +- return; +-} +- +-static void +-fmtstr( +- char **sbuffer, +- char **buffer, +- size_t *currlen, +- size_t *maxlen, +- const char *value, +- int flags, +- int min, +- int max) +-{ +- int padlen, strln; +- int cnt =3D 0; +- +- if (value =3D=3D 0) +- value =3D ""; +- for (strln =3D 0; value[strln]; ++strln) +- ; +- padlen =3D min - strln; +- if (padlen < 0) +- padlen =3D 0; +- if (flags & DP_F_MINUS) +- padlen =3D -padlen; +- +- while ((padlen > 0) && (cnt < max)) { +- doapr_outch(sbuffer, buffer, currlen, maxlen, ' '); +- --padlen; +- ++cnt; +- } +- while (*value && (cnt < max)) { +- doapr_outch(sbuffer, buffer, currlen, maxlen, *value++); +- ++cnt; +- } +- while ((padlen < 0) && (cnt < max)) { +- doapr_outch(sbuffer, buffer, currlen, maxlen, ' '); +- ++padlen; +- ++cnt; +- } +-} +- +-static void +-fmtint( +- char **sbuffer, +- char **buffer, +- size_t *currlen, +- size_t *maxlen, +- LLONG value, +- int base, +- int min, +- int max, +- int flags) +-{ +- int signvalue =3D 0; +- const char *prefix =3D ""; +- unsigned LLONG uvalue; +- char convert[DECIMAL_SIZE(value)+3]; +- int place =3D 0; +- int spadlen =3D 0; +- int zpadlen =3D 0; +- int caps =3D 0; +- +- if (max < 0) +- max =3D 0; +- uvalue =3D value; +- if (!(flags & DP_F_UNSIGNED)) { +- if (value < 0) { +- signvalue =3D '-'; +- uvalue =3D -value; +- } else if (flags & DP_F_PLUS) +- signvalue =3D '+'; +- else if (flags & DP_F_SPACE) +- signvalue =3D ' '; +- } +- if (flags & DP_F_NUM) { +- if (base =3D=3D 8) prefix =3D "0"; +- if (base =3D=3D 16) prefix =3D "0x"; +- } +- if (flags & DP_F_UP) +- caps =3D 1; +- do { +- convert[place++] =3D +- (caps ? "0123456789ABCDEF" : "0123456789abcdef") +- [uvalue % (unsigned) base]; +- uvalue =3D (uvalue / (unsigned) base); +- } while (uvalue && (place < (int)sizeof(convert))); +- if (place =3D=3D sizeof(convert)) +- place--; +- convert[place] =3D 0; +- +- zpadlen =3D max - place; +- spadlen =3D min - OSSL_MAX(max, place) - (signvalue ? 1 : 0) - strl= en(prefix); +- if (zpadlen < 0) +- zpadlen =3D 0; +- if (spadlen < 0) +- spadlen =3D 0; +- if (flags & DP_F_ZERO) { +- zpadlen =3D OSSL_MAX(zpadlen, spadlen); +- spadlen =3D 0; +- } +- if (flags & DP_F_MINUS) +- spadlen =3D -spadlen; +- +- /* spaces */ +- while (spadlen > 0) { +- doapr_outch(sbuffer, buffer, currlen, maxlen, ' '); +- --spadlen; +- } +- +- /* sign */ +- if (signvalue) +- doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue); +- +- /* prefix */ +- while (*prefix) { +- doapr_outch(sbuffer, buffer, currlen, maxlen, *prefix); +- prefix++; +- } +- +- /* zeros */ +- if (zpadlen > 0) { +- while (zpadlen > 0) { +- doapr_outch(sbuffer, buffer, currlen, maxlen, '0'); +- --zpadlen; +- } +- } +- /* digits */ +- while (place > 0) +- doapr_outch(sbuffer, buffer, currlen, maxlen, convert[--place])= ; +- +- /* left justified spaces */ +- while (spadlen < 0) { +- doapr_outch(sbuffer, buffer, currlen, maxlen, ' '); +- ++spadlen; +- } +- return; +-} +- +-static LDOUBLE +-abs_val(LDOUBLE value) +-{ +- LDOUBLE result =3D value; +- if (value < 0) +- result =3D -value; +- return result; +-} +- +-static LDOUBLE +-pow_10(int in_exp) +-{ +- LDOUBLE result =3D 1; +- while (in_exp) { +- result *=3D 10; +- in_exp--; +- } +- return result; +-} +- +-static long +-roundv(LDOUBLE value) +-{ +- long intpart; +- intpart =3D (long) value; +- value =3D value - intpart; +- if (value >=3D 0.5) +- intpart++; +- return intpart; +-} +- +-static void +-fmtfp( +- char **sbuffer, +- char **buffer, +- size_t *currlen, +- size_t *maxlen, +- LDOUBLE fvalue, +- int min, +- int max, +- int flags) +-{ +- int signvalue =3D 0; +- LDOUBLE ufvalue; +- char iconvert[20]; +- char fconvert[20]; +- int iplace =3D 0; +- int fplace =3D 0; +- int padlen =3D 0; +- int zpadlen =3D 0; +- int caps =3D 0; +- long intpart; +- long fracpart; +- long max10; +- +- if (max < 0) +- max =3D 6; +- ufvalue =3D abs_val(fvalue); +- if (fvalue < 0) +- signvalue =3D '-'; +- else if (flags & DP_F_PLUS) +- signvalue =3D '+'; +- else if (flags & DP_F_SPACE) +- signvalue =3D ' '; +- +- intpart =3D (long)ufvalue; +- +- /* sorry, we only support 9 digits past the decimal because of our +- conversion method */ +- if (max > 9) +- max =3D 9; +- +- /* we "cheat" by converting the fractional part to integer by +- multiplying by a factor of 10 */ +- max10 =3D roundv(pow_10(max)); +- fracpart =3D roundv(pow_10(max) * (ufvalue - intpart)); +- +- if (fracpart >=3D max10) { +- intpart++; +- fracpart -=3D max10; +- } +- +- /* convert integer part */ +- do { +- iconvert[iplace++] =3D +- (caps ? "0123456789ABCDEF" +- : "0123456789abcdef")[intpart % 10]; +- intpart =3D (intpart / 10); +- } while (intpart && (iplace < (int)sizeof(iconvert))); +- if (iplace =3D=3D sizeof iconvert) +- iplace--; +- iconvert[iplace] =3D 0; +- +- /* convert fractional part */ +- do { +- fconvert[fplace++] =3D +- (caps ? "0123456789ABCDEF" +- : "0123456789abcdef")[fracpart % 10]; +- fracpart =3D (fracpart / 10); +- } while (fplace < max); +- if (fplace =3D=3D sizeof fconvert) +- fplace--; +- fconvert[fplace] =3D 0; +- +- /* -1 for decimal point, another -1 if we are printing a sign */ +- padlen =3D min - iplace - max - 1 - ((signvalue) ? 1 : 0); +- zpadlen =3D max - fplace; +- if (zpadlen < 0) +- zpadlen =3D 0; +- if (padlen < 0) +- padlen =3D 0; +- if (flags & DP_F_MINUS) +- padlen =3D -padlen; +- +- if ((flags & DP_F_ZERO) && (padlen > 0)) { +- if (signvalue) { +- doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue); +- --padlen; +- signvalue =3D 0; +- } +- while (padlen > 0) { +- doapr_outch(sbuffer, buffer, currlen, maxlen, '0'); +- --padlen; +- } +- } +- while (padlen > 0) { +- doapr_outch(sbuffer, buffer, currlen, maxlen, ' '); +- --padlen; +- } +- if (signvalue) +- doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue); +- +- while (iplace > 0) +- doapr_outch(sbuffer, buffer, currlen, maxlen, iconvert[--iplace= ]); +- +- /* +- * Decimal point. This should probably use locale to find the corre= ct +- * char to print out. +- */ +- if (max > 0 || (flags & DP_F_NUM)) { +- doapr_outch(sbuffer, buffer, currlen, maxlen, '.'); +- +- while (fplace > 0) +- doapr_outch(sbuffer, buffer, currlen, maxlen, fconvert[--fp= lace]); +- } +- while (zpadlen > 0) { +- doapr_outch(sbuffer, buffer, currlen, maxlen, '0'); +- --zpadlen; +- } +- +- while (padlen < 0) { +- doapr_outch(sbuffer, buffer, currlen, maxlen, ' '); +- ++padlen; +- } +-} +- +-static void +-doapr_outch( +- char **sbuffer, +- char **buffer, +- size_t *currlen, +- size_t *maxlen, +- int c) +-{ +- /* If we haven't at least one buffer, someone has doe a big booboo = */ +- assert(*sbuffer !=3D NULL || buffer !=3D NULL); +- +- if (buffer) { +- while (*currlen >=3D *maxlen) { +- if (*buffer =3D=3D NULL) { +- if (*maxlen =3D=3D 0) +- *maxlen =3D 1024; +- *buffer =3D OPENSSL_malloc(*maxlen); +- if (*currlen > 0) { +- assert(*sbuffer !=3D NULL); +- memcpy(*buffer, *sbuffer, *currlen); +- } +- *sbuffer =3D NULL; +- } else { +- *maxlen +=3D 1024; +- *buffer =3D OPENSSL_realloc(*buffer, *maxlen); +- } +- } +- /* What to do if *buffer is NULL? */ +- assert(*sbuffer !=3D NULL || *buffer !=3D NULL); +- } +- +- if (*currlen < *maxlen) { +- if (*sbuffer) +- (*sbuffer)[(*currlen)++] =3D (char)c; +- else +- (*buffer)[(*currlen)++] =3D (char)c; +- } +- +- return; +-} +- + /**********************************************************************= *****/ +=20 + int BIO_printf (BIO *bio, const char *format, ...) +@@ -780,31 +126,7 @@ +=20 + int BIO_vprintf (BIO *bio, const char *format, va_list args) + { +- int ret; +- size_t retlen; +- char hugebuf[1024*2]; /* Was previously 10k, which is unreasonable +- in small-stack environments, like threads +- or DOS programs. */ +- char *hugebufp =3D hugebuf; +- size_t hugebufsize =3D sizeof(hugebuf); +- char *dynbuf =3D NULL; +- int ignored; +- +- dynbuf =3D NULL; +- CRYPTO_push_info("doapr()"); +- _dopr(&hugebufp, &dynbuf, &hugebufsize, +- &retlen, &ignored, format, args); +- if (dynbuf) +- { +- ret=3DBIO_write(bio, dynbuf, (int)retlen); +- OPENSSL_free(dynbuf); +- } +- else +- { +- ret=3DBIO_write(bio, hugebuf, (int)retlen); +- } +- CRYPTO_pop_info(); +- return(ret); ++ return -1; + } +=20 + /* As snprintf is not available everywhere, we provide our own implemen= tation. +@@ -826,17 +148,5 @@ +=20 + int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args= ) + { +- size_t retlen; +- int truncated; +- +- _dopr(&buf, NULL, &n, &retlen, &truncated, format, args); +- +- if (truncated) +- /* In case of truncation, return -1 like traditional snprintf. +- * (Current drafts for ISO/IEC 9899 say snprintf should return +- * the number of characters that would have been written, +- * had the buffer been large enough.) */ +- return -1; +- else +- return (retlen <=3D INT_MAX) ? (int)retlen : -1; ++ return -1; + } +diff -Naur openssl-1.0.0a.pristine/crypto/rand/rand_egd.c openssl-1.0.0a= /crypto/rand/rand_egd.c +--- openssl-1.0.0a.pristine/crypto/rand/rand_egd.c 2010-10-21 16:08:44.0= 00000000 -0400 ++++ openssl-1.0.0a/crypto/rand/rand_egd.c 2010-10-29 11:31:16.000000000 = -0400 +@@ -95,7 +95,6 @@ + * RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=3D255. + */ +=20 +-#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(O= PENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_= NETWARE) || defined(OPENSSL_SYS_VOS) || defined(OPENSSL_SYS_BEOS) + int RAND_query_egd_bytes(const char *path, unsigned char *buf, int byte= s) + { + return(-1); +@@ -109,195 +108,3 @@ + { + return(-1); + } +-#else +-#include +-#include OPENSSL_UNISTD +-#include +-#include +-#ifndef NO_SYS_UN_H +-# ifdef OPENSSL_SYS_VXWORKS +-# include +-# else +-# include +-# endif +-#else +-struct sockaddr_un { +- short sun_family; /* AF_UNIX */ +- char sun_path[108]; /* path name (gag) */ +-}; +-#endif /* NO_SYS_UN_H */ +-#include +-#include +- +-#ifndef offsetof +-# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +-#endif +- +-int RAND_query_egd_bytes(const char *path, unsigned char *buf, int byte= s) +- { +- int ret =3D 0; +- struct sockaddr_un addr; +- int len, num, numbytes; +- int fd =3D -1; +- int success; +- unsigned char egdbuf[2], tempbuf[255], *retrievebuf; +- +- memset(&addr, 0, sizeof(addr)); +- addr.sun_family =3D AF_UNIX; +- if (strlen(path) >=3D sizeof(addr.sun_path)) +- return (-1); +- BUF_strlcpy(addr.sun_path,path,sizeof addr.sun_path); +- len =3D offsetof(struct sockaddr_un, sun_path) + strlen(path); +- fd =3D socket(AF_UNIX, SOCK_STREAM, 0); +- if (fd =3D=3D -1) return (-1); +- success =3D 0; +- while (!success) +- { +- if (connect(fd, (struct sockaddr *)&addr, len) =3D=3D 0) +- success =3D 1; +- else +- { +- switch (errno) +- { +-#ifdef EINTR +- case EINTR: +-#endif +-#ifdef EAGAIN +- case EAGAIN: +-#endif +-#ifdef EINPROGRESS +- case EINPROGRESS: +-#endif +-#ifdef EALREADY +- case EALREADY: +-#endif +- /* No error, try again */ +- break; +-#ifdef EISCONN +- case EISCONN: +- success =3D 1; +- break; +-#endif +- default: +- goto err; /* failure */ +- } +- } +- } +- +- while(bytes > 0) +- { +- egdbuf[0] =3D 1; +- egdbuf[1] =3D bytes < 255 ? bytes : 255; +- numbytes =3D 0; +- while (numbytes !=3D 2) +- { +- num =3D write(fd, egdbuf + numbytes, 2 - numbytes); +- if (num >=3D 0) +- numbytes +=3D num; +- else +- { +- switch (errno) +- { +-#ifdef EINTR +- case EINTR: +-#endif +-#ifdef EAGAIN +- case EAGAIN: +-#endif +- /* No error, try again */ +- break; +- default: +- ret =3D -1; +- goto err; /* failure */ +- } +- } +- } +- numbytes =3D 0; +- while (numbytes !=3D 1) +- { +- num =3D read(fd, egdbuf, 1); +- if (num =3D=3D 0) +- goto err; /* descriptor closed */ +- else if (num > 0) +- numbytes +=3D num; +- else +- { +- switch (errno) +- { +-#ifdef EINTR +- case EINTR: +-#endif +-#ifdef EAGAIN +- case EAGAIN: +-#endif +- /* No error, try again */ +- break; +- default: +- ret =3D -1; +- goto err; /* failure */ +- } +- } +- } +- if(egdbuf[0] =3D=3D 0) +- goto err; +- if (buf) +- retrievebuf =3D buf + ret; +- else +- retrievebuf =3D tempbuf; +- numbytes =3D 0; +- while (numbytes !=3D egdbuf[0]) +- { +- num =3D read(fd, retrievebuf + numbytes, egdbuf[0] - numbytes)= ; +- if (num =3D=3D 0) +- goto err; /* descriptor closed */ +- else if (num > 0) +- numbytes +=3D num; +- else +- { +- switch (errno) +- { +-#ifdef EINTR +- case EINTR: +-#endif +-#ifdef EAGAIN +- case EAGAIN: +-#endif +- /* No error, try again */ +- break; +- default: +- ret =3D -1; +- goto err; /* failure */ +- } +- } +- } +- ret +=3D egdbuf[0]; +- bytes -=3D egdbuf[0]; +- if (!buf) +- RAND_seed(tempbuf, egdbuf[0]); +- } +- err: +- if (fd !=3D -1) close(fd); +- return(ret); +- } +- +- +-int RAND_egd_bytes(const char *path, int bytes) +- { +- int num, ret =3D 0; +- +- num =3D RAND_query_egd_bytes(path, NULL, bytes); +- if (num < 1) goto err; +- if (RAND_status() =3D=3D 1) +- ret =3D num; +- err: +- return(ret); +- } +- +- +-int RAND_egd(const char *path) +- { +- return (RAND_egd_bytes(path, 255)); +- } +- +- +-#endif +diff -Naur openssl-1.0.0a.pristine/e_os.h openssl-1.0.0a/e_os.h +--- openssl-1.0.0a.pristine/e_os.h 2010-10-21 16:08:44.000000000 -0400 ++++ openssl-1.0.0a/e_os.h 2010-10-29 11:31:16.000000000 -0400 +@@ -76,18 +76,6 @@ + #define REF_PRINT(a,b) fprintf(stderr,"%08X:%4d:%s\n",(int)b,b->referen= ces,a) + #endif +=20 +-#ifndef DEVRANDOM +-/* set this to a comma-separated list of 'random' device files to try o= ut. +- * My default, we will try to read at least one of these files */ +-#define DEVRANDOM "/dev/urandom","/dev/random","/dev/srandom" +-#endif +-#ifndef DEVRANDOM_EGD +-/* set this to a comma-seperated list of 'egd' sockets to try out. Thes= e +- * sockets will be tried in the order listed in case accessing the devi= ce files +- * listed in DEVRANDOM did not return enough entropy. */ +-#define DEVRANDOM_EGD "/var/run/egd-pool","/dev/egd-pool","/etc/egd-poo= l","/etc/entropy" +-#endif +- + #if defined(OPENSSL_SYS_VXWORKS) + # define NO_SYS_PARAM_H + # define NO_CHMOD diff -Naur xen-unstable-trp-sdp-pristine/stubdom/polarssl.patch xen-unsta= ble-trp-sdp/stubdom/polarssl.patch --- xen-unstable-trp-sdp-pristine/stubdom/polarssl.patch 1969-12-31 19:00= :00.000000000 -0500 +++ xen-unstable-trp-sdp/stubdom/polarssl.patch 2011-02-23 19:40:48.00000= 0000 -0500 @@ -0,0 +1,23 @@ +diff -Naur polarssl-0.12.1-pristine/include/polarssl/config.h polarssl-0= =2E12.1/include/polarssl/config.h +--- polarssl-0.12.1-pristine/include/polarssl/config.h 2010-11-03 14:50:= 09.000000000 -0400 ++++ polarssl-0.12.1/include/polarssl/config.h 2010-11-04 10:24:29.000000= 000 -0400 +@@ -221,7 +221,7 @@ + * + * This module provides TCP/IP networking routines. + */ +-#define POLARSSL_NET_C ++//#define POLARSSL_NET_C +=20 + /* + * Module: library/padlock.c +diff -Naur polarssl-0.12.1-pristine/library/timing.c polarssl-0.12.1/lib= rary/timing.c +--- polarssl-0.12.1-pristine/library/timing.c 2010-11-03 14:50:09.000000= 000 -0400 ++++ polarssl-0.12.1/library/timing.c 2010-11-04 10:30:56.000000000 -0400= +@@ -42,6 +42,7 @@ + #include + #include + #include ++#include + #include + #include +=20 diff -Naur xen-unstable-trp-sdp-pristine/stubdom/tpmemu-0.6.1.patch xen-u= nstable-trp-sdp/stubdom/tpmemu-0.6.1.patch --- xen-unstable-trp-sdp-pristine/stubdom/tpmemu-0.6.1.patch 1969-12-31 1= 9:00:00.000000000 -0500 +++ xen-unstable-trp-sdp/stubdom/tpmemu-0.6.1.patch 2011-02-23 19:40:48.0= 00000000 -0500 @@ -0,0 +1,78 @@ +diff -Naur tpm_emulator-0.6.1-pristine/tpm/tpm_data.c tpm_emulator-0.6.1= /tpm/tpm_data.c +--- tpm_emulator-0.6.1-pristine/tpm/tpm_data.c 2009-10-09 05:07:22.00000= 0000 -0400 ++++ tpm_emulator-0.6.1/tpm/tpm_data.c 2011-02-18 14:23:16.000000000 -050= 0 +@@ -246,8 +246,7 @@ + || tpm_unmarshal_TPM_PERMANENT_DATA(&ptr, &len, &tpmData.permanen= t.data) + || tpm_unmarshal_TPM_STCLEAR_FLAGS(&ptr, &len, &tpmData.stclear.f= lags) =20 + || tpm_unmarshal_TPM_STCLEAR_DATA(&ptr, &len, &tpmData.stclear.da= ta) +- || tpm_unmarshal_TPM_STANY_DATA(&ptr, &len, &tpmData.stany.data) +- || len > 0) { ++ || tpm_unmarshal_TPM_STANY_DATA(&ptr, &len, &tpmData.stany.data))= { + tpm_free(buf); + return -1; + } +diff -Naur tpm_emulator-0.6.1-pristine/tpmd/Makefile tpm_emulator-0.6.1/= tpmd/Makefile +--- tpm_emulator-0.6.1-pristine/tpmd/Makefile 2009-10-09 05:07:22.000000= 000 -0400 ++++ tpm_emulator-0.6.1/tpmd/Makefile 2011-02-18 14:23:16.000000000 -0500= +@@ -39,3 +39,5 @@ +=20 + .PHONY: all clean install +=20 ++.PHONY: objs ++objs: $(OBJS) +diff -Naur tpm_emulator-0.6.1-pristine/tpmd/tpm_emulator_config.h tpm_em= ulator-0.6.1/tpmd/tpm_emulator_config.h +--- tpm_emulator-0.6.1-pristine/tpmd/tpm_emulator_config.h 2009-10-09 05= :07:22.000000000 -0400 ++++ tpm_emulator-0.6.1/tpmd/tpm_emulator_config.h 2011-02-18 14:25:22.00= 0000000 -0500 +@@ -21,16 +21,12 @@ + #include + #include + #include +-#if defined(__linux__) +-#include +-#elif (defined(__OpenBSD__) || defined(__FreeBSD__)) +-#include +-#endif=20 ++#include +=20 + /* TPM emulator configuration */ +=20 +-#undef TPM_STRONG_PERSISTENCE +-#undef TPM_GENERATE_EK ++#define TPM_STRONG_PERSISTENCE ++#define TPM_GENERATE_EK + #undef TPM_GENERATE_SEED_DAA + #undef TPM_MEMORY_ALIGNMENT_MANDATORY + #undef TPM_USE_INTERNAL_PRNG +@@ -85,19 +81,19 @@ +=20 + #if defined(__linux__) +=20 +-#define CPU_TO_BE64(x) __cpu_to_be64(x) +-#define CPU_TO_LE64(x) __cpu_to_le64(x) +-#define CPU_TO_BE32(x) __cpu_to_be32(x) +-#define CPU_TO_LE32(x) __cpu_to_le32(x) +-#define CPU_TO_BE16(x) __cpu_to_be16(x) +-#define CPU_TO_LE16(x) __cpu_to_le16(x) +- +-#define BE64_TO_CPU(x) __be64_to_cpu(x) +-#define LE64_TO_CPU(x) __le64_to_cpu(x) +-#define BE32_TO_CPU(x) __be32_to_cpu(x) +-#define LE32_TO_CPU(x) __le32_to_cpu(x) +-#define BE16_TO_CPU(x) __be16_to_cpu(x) +-#define LE16_TO_CPU(x) __le16_to_cpu(x) ++#define CPU_TO_BE64(x) cpu_to_be64(x) ++#define CPU_TO_LE64(x) cpu_to_le64(x) ++#define CPU_TO_BE32(x) cpu_to_be32(x) ++#define CPU_TO_LE32(x) cpu_to_le32(x) ++#define CPU_TO_BE16(x) cpu_to_be16(x) ++#define CPU_TO_LE16(x) cpu_to_le16(x) ++ ++#define BE64_TO_CPU(x) be64_to_cpu(x) ++#define LE64_TO_CPU(x) le64_to_cpu(x) ++#define BE32_TO_CPU(x) be32_to_cpu(x) ++#define LE32_TO_CPU(x) le32_to_cpu(x) ++#define BE16_TO_CPU(x) be16_to_cpu(x) ++#define LE16_TO_CPU(x) le16_to_cpu(x) +=20 + #elif defined(__OpenBSD__) +=20 diff -Naur xen-unstable-trp-sdp-pristine/stubdom/Makefile xen-unstable-tr= p-sdp/stubdom/Makefile --- xen-unstable-trp-sdp-pristine/stubdom/Makefile 2011-02-23 14:47:26.00= 0000000 -0500 +++ xen-unstable-trp-sdp/stubdom/Makefile 2011-02-23 19:40:48.000000000 -= 0500 @@ -27,6 +27,22 @@ #OCAML_URL?=3D$(XEN_EXTFILES_URL) OCAML_URL?=3Dhttp://caml.inria.fr/pub/distrib/ocaml-3.11 OCAML_VERSION=3D3.11.0 + +GMP_VERSION=3D4.3.2 +#GMP_URL?=3D$(XEN_EXTFILES_URL) +GMP_URL?=3Dftp://ftp.gmplib.org/pub/gmp-$(GMP_VERSION) + +POLARSSL_VERSION=3D0.12.1 +#POLARSSL_URL?=3D$(XEN_EXTFILES_URL) +POLARSSL_URL?=3Dhttp://polarssl.org/code/releases + +OPENSSL_VERSION=3D1.0.0a +#OPENSSL_URL?=3D$(XEN_EXTFILES_URL) +OPENSSL_URL?=3Dhttp://www.openssl.org/source + +TPMEMU_VERSION=3D0.6.1 +#TPMEMU_URL?=3D$(XEN_EXTFILES_URL) +TPMEMU_URL?=3Dhttp://download.berlios.de/tpm-emulator =20 WGET=3Dwget -c =20 @@ -177,6 +209,125 @@ touch $@ =20 ############# +# cross-gmp +############# +gmp-$(GMP_VERSION).tar.bz2: + $(WGET) $(GMP_URL)/$@ + +.PHONY: cross-gmp +ifeq ($(XEN_TARGET_ARCH), x86_32) + GMPEXT=3DABI=3D32 +endif +gmp-$(XEN_TARGET_ARCH): gmp-$(GMP_VERSION).tar.bz2 $(NEWLIB_STAMPFILE) + tar xjf $< + mv gmp-$(GMP_VERSION) $@ + #patch -d $@ -p0 < gmp.patch + cd $@; CPPFLAGS=3D"-isystem $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/= include $(TARGET_CPPFLAGS)" CFLAGS=3D"$(TARGET_CFLAGS)" CC=3D$(CC) $(GMPE= XT) ./configure --disable-shared --enable-static --disable-fft --without-= readline --prefix=3D$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf=20 + sed -i 's/#define HAVE_OBSTACK_VPRINTF 1/\/\/#define HAVE_OBSTACK_VPRIN= TF 1/' $@/config.h + touch $@ + +GMP_STAMPFILE=3D$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libgmp.a +cross-gmp: $(GMP_STAMPFILE)=20 +$(GMP_STAMPFILE): gmp-$(XEN_TARGET_ARCH) + ( cd $< && \ + $(MAKE) && \ + $(MAKE) install ) + +############# +# cross-polarssl +############# +polarssl-$(POLARSSL_VERSION)-gpl.tgz: + $(WGET) $(POLARSSL_URL)/$@ + +polarssl-$(XEN_TARGET_ARCH): polarssl-$(POLARSSL_VERSION)-gpl.tgz + tar xzf $< + mv polarssl-$(POLARSSL_VERSION) $@ + patch -d $@ -p1 < polarssl.patch + touch $@ + +POLARSSL_STAMPFILE=3D$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libpol= arssl.a +cross-polarssl: $(POLARSSL_STAMPFILE)=20 +$(POLARSSL_STAMPFILE): polarssl-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE) l= wip-$(XEN_TARGET_ARCH) + ( cd $\"]@#includ= e @" $${file}; done; \ + done + install -m 0644 $