usr/src/lib/trousers/Patches/tspps.c.patch
changeset 10 612517e396e0
parent 0 b34509ac961f
child 54 c8df60226931
equal deleted inserted replaced
9:502b128296a2 10:612517e396e0
     1 --- src/tspi/ps/tspps.c.old	Mon Jul 20 11:44:30 2009
     1 --- src/tspi/ps/tspps.c.orig	Fri Jan 29 11:54:49 2010
     2 +++ src/tspi/ps/tspps.c	Wed Aug  5 13:18:26 2009
     2 +++ src/tspi/ps/tspps.c	Fri Jan 29 11:54:15 2010
     3 @@ -19,6 +19,11 @@
     3 @@ -19,6 +19,21 @@
     4  #include <sys/file.h>
     4  #include <sys/file.h>
     5  #include <sys/stat.h>
     5  #include <sys/stat.h>
     6  #include <assert.h>
     6  #include <assert.h>
     7 +#if defined (SOLARIS)
       
     8 +#include <fcntl.h>
     7 +#include <fcntl.h>
     9 +#include <limits.h>
     8 +#include <limits.h>
    10 +#include <netdb.h>
     9 +#include <netdb.h>
       
    10 +#if defined (HAVE_BYTEORDER_H)
       
    11 +#include <sys/byteorder.h>
       
    12 +#elif defined(HAVE_ENDIAN_H)
       
    13 +#include <endian.h>
       
    14 +#define LE_16 htole16
       
    15 +#define LE_32 htole32
       
    16 +#define LE_64 htole64
       
    17 +#else
       
    18 +#define LE_16(x) (x)
       
    19 +#define LE_32(x) (x)
       
    20 +#define LE_64(x) (x)
    11 +#endif
    21 +#endif
    12  
    22  
    13  #include "trousers/tss.h"
    23  #include "trousers/tss.h"
    14  #include "trousers/trousers.h"
    24  #include "trousers/trousers.h"
    15 @@ -33,6 +38,17 @@
    25 @@ -33,6 +48,17 @@
    16  #if (defined (__FreeBSD__) || defined (__OpenBSD__))
    26  #if (defined (__FreeBSD__) || defined (__OpenBSD__))
    17  static MUTEX_DECLARE_INIT(user_ps_path);
    27  static MUTEX_DECLARE_INIT(user_ps_path);
    18  #endif
    28  #endif
    19 +#if defined (SOLARIS)
    29 +#if defined (SOLARIS)
    20 +static struct flock fl = {
    30 +static struct flock fl = {
    28 +};
    38 +};
    29 +#endif
    39 +#endif
    30  
    40  
    31  
    41  
    32  /*
    42  /*
    33 @@ -62,6 +78,16 @@
    43 @@ -62,6 +88,16 @@
    34  
    44  
    35  	euid = geteuid();
    45  	euid = geteuid();
    36  
    46  
    37 +#if defined (SOLARIS)
    47 +#if defined (SOLARIS)
    38 +	/*
    48 +	/*
    39 +         * Solaris keeps user PS in a local directory to avoid NFS problems
    49 +         * Solaris keeps user PS in a local directory instead of
    40 +         * and potential conflicts when sharing the same PS file among
    50 +         * in the user's home directory, which may be shared
    41 +         * multiple machines with different TPMs.
    51 +         * by multiple systems.
    42 +         *
    52 +         *
    43 +         * The directory path is /var/tpm/userps/[EUID]/
    53 +         * The directory path on Solaris is /var/tpm/userps/[EUID]/
    44 +         */
    54 +         */
    45 +        rc = snprintf(buf, sizeof (buf), "%s/%d", TSS_USER_PS_DIR, euid);
    55 +        rc = snprintf(buf, sizeof (buf), "%s/%d", TSS_USER_PS_DIR, euid);
    46 +#else
    56 +#else
    47  	setpwent();
    57  	setpwent();
    48  	while (1) {
    58  	while (1) {
    49  #if (defined (__linux) || defined (linux))
    59  #if (defined (__linux) || defined (linux))
    50 @@ -93,8 +119,9 @@
    60 @@ -93,8 +129,9 @@
    51  		return TSPERR(TSS_E_OUTOFMEMORY);
    61  		return TSPERR(TSS_E_OUTOFMEMORY);
    52  
    62  
    53  	/* Tack on TSS_USER_PS_DIR and see if it exists */
    63  	/* Tack on TSS_USER_PS_DIR and see if it exists */
    54 -	rc = snprintf(buf, PASSWD_BUFSIZE, "%s/%s", home_dir, TSS_USER_PS_DIR);
    64 -	rc = snprintf(buf, PASSWD_BUFSIZE, "%s/%s", home_dir, TSS_USER_PS_DIR);
    55 -	if (rc == PASSWD_BUFSIZE) {
    65 -	if (rc == PASSWD_BUFSIZE) {
    57 +#endif /* SOLARIS */
    67 +#endif /* SOLARIS */
    58 +	if (rc == sizeof (buf)) {
    68 +	if (rc == sizeof (buf)) {
    59  		LogDebugFn("USER PS: Path to file too long! (> %d bytes)", PASSWD_BUFSIZE);
    69  		LogDebugFn("USER PS: Path to file too long! (> %d bytes)", PASSWD_BUFSIZE);
    60  		result = TSPERR(TSS_E_INTERNAL_ERROR);
    70  		result = TSPERR(TSS_E_INTERNAL_ERROR);
    61  		goto done;
    71  		goto done;
    62 @@ -104,7 +131,7 @@
    72 @@ -104,7 +141,7 @@
    63  	if ((rc = stat(buf, &stat_buf)) == -1) {
    73  	if ((rc = stat(buf, &stat_buf)) == -1) {
    64  		if (errno == ENOENT) {
    74  		if (errno == ENOENT) {
    65  			errno = 0;
    75  			errno = 0;
    66 -			/* Create the base directory, $HOME/.trousers */
    76 -			/* Create the base directory, $HOME/.trousers */
    67 +			/* Create the user's ps directory if it is not there. */
    77 +			/* Create the user's ps directory if it is not there. */
    68  			if ((rc = mkdir(buf, 0700)) == -1) {
    78  			if ((rc = mkdir(buf, 0700)) == -1) {
    69  				LogDebugFn("USER PS: Error creating dir: %s: %s", buf,
    79  				LogDebugFn("USER PS: Error creating dir: %s: %s", buf,
    70  					   strerror(errno));
    80  					   strerror(errno));
    71 @@ -119,10 +146,15 @@
    81 @@ -119,10 +156,15 @@
    72  	}
    82  	}
    73  
    83  
    74  	/* Directory exists or has been created, return the path to the file */
    84  	/* Directory exists or has been created, return the path to the file */
    75 -	rc = snprintf(buf, PASSWD_BUFSIZE, "%s/%s/%s", home_dir, TSS_USER_PS_DIR,
    85 -	rc = snprintf(buf, PASSWD_BUFSIZE, "%s/%s/%s", home_dir, TSS_USER_PS_DIR,
    76 +#if defined (SOLARIS)
    86 +#if defined (SOLARIS)
    85 +	if (rc == sizeof (buf)) {
    95 +	if (rc == sizeof (buf)) {
    86 +		LogDebugFn("USER PS: Path to file too long! (> %d bytes)", sizeof (buf));
    96 +		LogDebugFn("USER PS: Path to file too long! (> %d bytes)", sizeof (buf));
    87  	} else
    97  	} else
    88  		*file = strdup(buf);
    98  		*file = strdup(buf);
    89  
    99  
    90 @@ -143,12 +175,16 @@
   100 @@ -143,12 +185,16 @@
    91  
   101  
    92  	/* check the global file handle first.  If it exists, lock it and return */
   102  	/* check the global file handle first.  If it exists, lock it and return */
    93  	if (user_ps_fd != -1) {
   103  	if (user_ps_fd != -1) {
    94 +#if defined (SOLARIS)
   104 +#if defined (SOLARIS)
    95 +		fl.l_type = F_WRLCK;
   105 +		fl.l_type = F_WRLCK;
   103  		}
   113  		}
   104 -
   114 -
   105  		*fd = user_ps_fd;
   115  		*fd = user_ps_fd;
   106  		return TSS_SUCCESS;
   116  		return TSS_SUCCESS;
   107  	}
   117  	}
   108 @@ -167,8 +203,12 @@
   118 @@ -167,8 +213,12 @@
   109  		MUTEX_UNLOCK(user_ps_lock);
   119  		MUTEX_UNLOCK(user_ps_lock);
   110  		return TSPERR(TSS_E_INTERNAL_ERROR);
   120  		return TSPERR(TSS_E_INTERNAL_ERROR);
   111  	}
   121  	}
   112 -
   122 -
   113 +#if defined (SOLARIS)
   123 +#if defined (SOLARIS)
   117  	if ((rc = flock(user_ps_fd, LOCK_EX))) {
   127  	if ((rc = flock(user_ps_fd, LOCK_EX))) {
   118 +#endif /* SOLARIS */
   128 +#endif /* SOLARIS */
   119  		LogDebug("USER PS: failed to get lock of %s: %s", file_name, strerror(errno));
   129  		LogDebug("USER PS: failed to get lock of %s: %s", file_name, strerror(errno));
   120  		free(file_name);
   130  		free(file_name);
   121  		close(user_ps_fd);
   131  		close(user_ps_fd);
   122 @@ -190,7 +230,12 @@
   132 @@ -190,7 +240,12 @@
   123  	fsync(fd);
   133  	fsync(fd);
   124  
   134  
   125  	/* release the file lock */
   135  	/* release the file lock */
   126 +#if defined (SOLARIS)
   136 +#if defined (SOLARIS)
   127 +	fl.l_type = F_UNLCK;
   137 +	fl.l_type = F_UNLCK;
   130  	if ((rc = flock(fd, LOCK_UN))) {
   140  	if ((rc = flock(fd, LOCK_UN))) {
   131 +#endif /* SOLARIS */
   141 +#endif /* SOLARIS */
   132  		LogDebug("USER PS: failed to unlock file: %s", strerror(errno));
   142  		LogDebug("USER PS: failed to unlock file: %s", strerror(errno));
   133  		rc = -1;
   143  		rc = -1;
   134  	}
   144  	}
   135 @@ -365,6 +410,9 @@
   145 @@ -365,6 +420,7 @@
   136  		LogDebug("read of %zd bytes: %s", sizeof(UINT32), strerror(errno));
   146  		LogDebug("read of %zd bytes: %s", sizeof(UINT32), strerror(errno));
   137  		return TSPERR(TSS_E_INTERNAL_ERROR);
   147  		return TSPERR(TSS_E_INTERNAL_ERROR);
   138  	}
   148  	}
   139 +#if defined(_BIG_ENDIAN)
   149 +	num_keys = LE_32(num_keys);
   140 +	num_keys = BSWAP_32(num_keys);
       
   141 +#endif
       
   142  
   150  
   143  	if (increment)
   151  	if (increment)
   144  		num_keys++;
   152  		num_keys++;
   145 @@ -377,6 +425,9 @@
   153 @@ -377,6 +433,7 @@
   146  		return TSPERR(TSS_E_INTERNAL_ERROR);
   154  		return TSPERR(TSS_E_INTERNAL_ERROR);
   147  	}
   155  	}
   148  
   156  
   149 +#if defined(_BIG_ENDIAN)
   157 +	num_keys = LE_32(num_keys);
   150 +	num_keys = BSWAP_32(num_keys);
       
   151 +#endif
       
   152  	if ((result = write_data(fd, (void *)&num_keys, sizeof(UINT32)))) {
   158  	if ((result = write_data(fd, (void *)&num_keys, sizeof(UINT32)))) {
   153  		LogDebug("%s", __FUNCTION__);
   159  		LogDebug("%s", __FUNCTION__);
   154  		return result;
   160  		return result;
   155 @@ -498,16 +549,28 @@
   161 @@ -498,16 +555,20 @@
   156  	}
   162  	}
   157  
   163  
   158  	/* [UINT16   pub_data_size0  ] yes */
   164  	/* [UINT16   pub_data_size0  ] yes */
   159 +#if defined(_BIG_ENDIAN)
   165 +	pub_key_size = LE_16(pub_key_size);
   160 +	pub_key_size = BSWAP_16(pub_key_size);
       
   161 +#endif
       
   162          if ((result = write_data(fd, &pub_key_size, sizeof(UINT16)))) {
   166          if ((result = write_data(fd, &pub_key_size, sizeof(UINT16)))) {
   163  		LogDebug("%s", __FUNCTION__);
   167  		LogDebug("%s", __FUNCTION__);
   164  		goto done;
   168  		goto done;
   165  	}
   169  	}
   166 +#if defined(_BIG_ENDIAN)
   170 +	pub_key_size = LE_16(pub_key_size);
   167 +	pub_key_size = BSWAP_16(pub_key_size);
       
   168 +#endif
       
   169  
   171  
   170  	/* [UINT16   blob_size0      ] yes */
   172  	/* [UINT16   blob_size0      ] yes */
   171 +#if defined(_BIG_ENDIAN)
   173 +	key_blob_size = LE_16(key_blob_size);
   172 +	key_blob_size = BSWAP_16(key_blob_size);
       
   173 +#endif
       
   174          if ((result = write_data(fd, &key_blob_size, sizeof(UINT16)))) {
   174          if ((result = write_data(fd, &key_blob_size, sizeof(UINT16)))) {
   175  		LogDebug("%s", __FUNCTION__);
   175  		LogDebug("%s", __FUNCTION__);
   176  		goto done;
   176  		goto done;
   177  	}
   177  	}
   178 +#if defined(_BIG_ENDIAN)
   178 +	key_blob_size = LE_16(key_blob_size);
   179 +	key_blob_size = BSWAP_16(key_blob_size);
       
   180 +#endif
       
   181  
   179  
   182  	/* [UINT32   vendor_data_size0 ] yes */
   180  	/* [UINT32   vendor_data_size0 ] yes */
   183          if ((result = write_data(fd, &zero, sizeof(UINT32)))) {
   181          if ((result = write_data(fd, &zero, sizeof(UINT32)))) {
   184 @@ -516,10 +579,16 @@
   182 @@ -516,10 +577,12 @@
   185  	}
   183  	}
   186  
   184  
   187  	/* [UINT16   cache_flags0    ] yes */
   185  	/* [UINT16   cache_flags0    ] yes */
   188 +#if defined(_BIG_ENDIAN)
   186 +	cache_flags = LE_16(cache_flags);
   189 +	cache_flags = BSWAP_16(cache_flags);
       
   190 +#endif
       
   191          if ((result = write_data(fd, &cache_flags, sizeof(UINT16)))) {
   187          if ((result = write_data(fd, &cache_flags, sizeof(UINT16)))) {
   192  		LogDebug("%s", __FUNCTION__);
   188  		LogDebug("%s", __FUNCTION__);
   193  		goto done;
   189  		goto done;
   194  	}
   190  	}
   195 +#if defined(_BIG_ENDIAN)
   191 +	cache_flags = LE_16(cache_flags);
   196 +	cache_flags = BSWAP_16(cache_flags);
       
   197 +#endif
       
   198  
   192  
   199  	/* [BYTE[]   pub_data0       ] no */
   193  	/* [BYTE[]   pub_data0       ] no */
   200          if ((result = write_data(fd, (void *)key.pubKey.key, pub_key_size))) {
   194          if ((result = write_data(fd, (void *)key.pubKey.key, pub_key_size))) {
   201 @@ -685,6 +754,9 @@
   195 @@ -685,6 +748,7 @@
   202  			LogDebug("%s", __FUNCTION__);
   196  			LogDebug("%s", __FUNCTION__);
   203  			goto err_exit;
   197  			goto err_exit;
   204  		}
   198  		}
   205 +#if defined(_BIG_ENDIAN)
   199 +		tmp[i].pub_data_size = LE_16(tmp[i].pub_data_size);
   206 +		tmp[i].pub_data_size = BSWAP_16(tmp[i].pub_data_size);
       
   207 +#endif
       
   208  
   200  
   209  		DBG_ASSERT(tmp[i].pub_data_size <= 2048);
   201  		DBG_ASSERT(tmp[i].pub_data_size <= 2048);
   210  
   202  
   211 @@ -693,6 +765,9 @@
   203 @@ -693,6 +757,7 @@
   212  			LogDebug("%s", __FUNCTION__);
   204  			LogDebug("%s", __FUNCTION__);
   213  			goto err_exit;
   205  			goto err_exit;
   214  		}
   206  		}
   215 +#if defined(_BIG_ENDIAN)
   207 +		tmp[i].blob_size = LE_16(tmp[i].blob_size);
   216 +		tmp[i].blob_size = BSWAP_16(tmp[i].blob_size);
       
   217 +#endif
       
   218  
   208  
   219  		DBG_ASSERT(tmp[i].blob_size <= 4096);
   209  		DBG_ASSERT(tmp[i].blob_size <= 4096);
   220  
   210  
   221 @@ -701,6 +776,9 @@
   211 @@ -701,6 +766,7 @@
   222  			LogDebug("%s", __FUNCTION__);
   212  			LogDebug("%s", __FUNCTION__);
   223  			goto err_exit;
   213  			goto err_exit;
   224  		}
   214  		}
   225 +#if defined(_BIG_ENDIAN)
   215 +		tmp[i].vendor_data_size = LE_32(tmp[i].vendor_data_size);
   226 +		tmp[i].vendor_data_size = BSWAP_32(tmp[i].vendor_data_size);
       
   227 +#endif
       
   228  
   216  
   229  		/* cache flags */
   217  		/* cache flags */
   230  		if ((result = read_data(fd, &tmp[i].flags, sizeof(UINT16)))) {
   218  		if ((result = read_data(fd, &tmp[i].flags, sizeof(UINT16)))) {
   231 @@ -707,6 +785,9 @@
   219 @@ -707,6 +773,7 @@
   232  			LogDebug("%s", __FUNCTION__);
   220  			LogDebug("%s", __FUNCTION__);
   233  			goto err_exit;
   221  			goto err_exit;
   234  		}
   222  		}
   235 +#if defined(_BIG_ENDIAN)
   223 +		tmp[i].flags = LE_16(tmp[i].flags);
   236 +		tmp[i].flags = BSWAP_16(tmp[i].flags);
       
   237 +#endif
       
   238  
   224  
   239  		/* fast forward over the pub key */
   225  		/* fast forward over the pub key */
   240  		offset = lseek(fd, tmp[i].pub_data_size, SEEK_CUR);
   226  		offset = lseek(fd, tmp[i].pub_data_size, SEEK_CUR);
   241 @@ -1031,6 +1112,10 @@
   227 @@ -1031,6 +1098,8 @@
   242  		num_keys = 0;
   228  		num_keys = 0;
   243  	}
   229  	}
   244  
   230  
   245 +#if defined(_BIG_ENDIAN)
       
   246 +	/* The system PS file is written in little-endian */
   231 +	/* The system PS file is written in little-endian */
   247 +	num_keys = BSWAP_32(num_keys);
   232 +	num_keys = LE_32(num_keys);
   248 +#endif
       
   249  	return num_keys;
   233  	return num_keys;
   250  }
   234  }
   251  
   235  
   252 @@ -1109,7 +1194,9 @@
   236 @@ -1109,7 +1178,7 @@
   253  			LogDebug("%s", __FUNCTION__);
   237  			LogDebug("%s", __FUNCTION__);
   254  			return result;
   238  			return result;
   255  		}
   239  		}
   256 -
   240 -
   257 +#if defined(_BIG_ENDIAN)
   241 +		c->pub_data_size = LE_16(c->pub_data_size);
   258 +		c->pub_data_size = BSWAP_16(c->pub_data_size);
       
   259 +#endif
       
   260  		DBG_ASSERT(c->pub_data_size <= 2048 && c->pub_data_size > 0);
   242  		DBG_ASSERT(c->pub_data_size <= 2048 && c->pub_data_size > 0);
   261  
   243  
   262  		/* blob size */
   244  		/* blob size */
   263 @@ -1117,7 +1204,9 @@
   245 @@ -1117,7 +1186,7 @@
   264  			LogDebug("%s", __FUNCTION__);
   246  			LogDebug("%s", __FUNCTION__);
   265  			return result;
   247  			return result;
   266  		}
   248  		}
   267 -
   249 -
   268 +#if defined(_BIG_ENDIAN)
   250 +		c->blob_size = LE_16(c->blob_size); 
   269 +		c->blob_size = BSWAP_16(c->blob_size); 
       
   270 +#endif
       
   271  		DBG_ASSERT(c->blob_size <= 4096 && c->blob_size > 0);
   251  		DBG_ASSERT(c->blob_size <= 4096 && c->blob_size > 0);
   272  
   252  
   273  		/* vendor data size */
   253  		/* vendor data size */
   274 @@ -1125,6 +1214,9 @@
   254 @@ -1125,6 +1194,7 @@
   275  			LogDebug("%s", __FUNCTION__);
   255  			LogDebug("%s", __FUNCTION__);
   276  			return result;
   256  			return result;
   277  		}
   257  		}
   278 +#if defined(_BIG_ENDIAN)
   258 +		c->vendor_data_size = LE_32(c->vendor_data_size); 
   279 +		c->vendor_data_size = BSWAP_32(c->vendor_data_size); 
       
   280 +#endif
       
   281  
   259  
   282  		/* cache flags */
   260  		/* cache flags */
   283  		if ((result = read_data(fd, &c->flags, sizeof(UINT16)))) {
   261  		if ((result = read_data(fd, &c->flags, sizeof(UINT16)))) {
   284 @@ -1131,6 +1223,9 @@
   262 @@ -1131,6 +1201,7 @@
   285  			LogDebug("%s", __FUNCTION__);
   263  			LogDebug("%s", __FUNCTION__);
   286  			return result;
   264  			return result;
   287  		}
   265  		}
   288 +#if defined(_BIG_ENDIAN)
   266 +		c->flags = LE_16(c->flags); 
   289 +		c->flags = BSWAP_16(c->flags); 
       
   290 +#endif
       
   291  
   267  
   292  		/* fast forward over the pub key */
   268  		/* fast forward over the pub key */
   293  		offset = lseek(fd, c->pub_data_size, SEEK_CUR);
   269  		offset = lseek(fd, c->pub_data_size, SEEK_CUR);
   294 @@ -1198,6 +1293,9 @@
   270 @@ -1198,6 +1269,7 @@
   295  			return result;
   271  			return result;
   296  		}
   272  		}
   297  
   273  
   298 +#if defined(_BIG_ENDIAN)
   274 +		c->pub_data_size = LE_16(c->pub_data_size);
   299 +		c->pub_data_size = BSWAP_16(c->pub_data_size);
       
   300 +#endif
       
   301  		DBG_ASSERT(c->pub_data_size <= 2048 && c->pub_data_size > 0);
   275  		DBG_ASSERT(c->pub_data_size <= 2048 && c->pub_data_size > 0);
   302  
   276  
   303  		/* blob size */
   277  		/* blob size */
   304 @@ -1206,6 +1304,9 @@
   278 @@ -1206,6 +1278,7 @@
   305  			return result;
   279  			return result;
   306  		}
   280  		}
   307  
   281  
   308 +#if defined(_BIG_ENDIAN)
   282 +		c->blob_size = LE_16(c->blob_size);
   309 +		c->blob_size = BSWAP_16(c->blob_size);
       
   310 +#endif
       
   311  		DBG_ASSERT(c->blob_size <= 4096 && c->blob_size > 0);
   283  		DBG_ASSERT(c->blob_size <= 4096 && c->blob_size > 0);
   312  
   284  
   313  		/* vendor data size */
   285  		/* vendor data size */
   314 @@ -1213,6 +1314,9 @@
   286 @@ -1213,6 +1286,7 @@
   315  			LogDebug("%s", __FUNCTION__);
   287  			LogDebug("%s", __FUNCTION__);
   316  			return result;
   288  			return result;
   317  		}
   289  		}
   318 +#if defined(_BIG_ENDIAN)
   290 +		c->vendor_data_size = LE_32(c->vendor_data_size);
   319 +		c->vendor_data_size = BSWAP_32(c->vendor_data_size);
       
   320 +#endif
       
   321  
   291  
   322  		/* cache flags */
   292  		/* cache flags */
   323  		if ((result = read_data(fd, &c->flags, sizeof(UINT16)))) {
   293  		if ((result = read_data(fd, &c->flags, sizeof(UINT16)))) {
   324 @@ -1219,6 +1323,9 @@
   294 @@ -1219,6 +1293,7 @@
   325  			LogDebug("%s", __FUNCTION__);
   295  			LogDebug("%s", __FUNCTION__);
   326  			return result;
   296  			return result;
   327  		}
   297  		}
   328 +#if defined(_BIG_ENDIAN)
   298 +		c->flags = LE_16(c->flags);
   329 +		c->flags = BSWAP_16(c->flags);
       
   330 +#endif
       
   331  
   299  
   332  		if (c->pub_data_size == pub_size) {
   300  		if (c->pub_data_size == pub_size) {
   333  			/* read in the pub key */
   301  			/* read in the pub key */