to minimise the effects on existing code.
[23-Dec-1998] down below; but in later
versions, these hyphens are gone.]
+ *) New functions sk_num, sk_value and sk_set to replace the previous macros.
+ These are required because of the typesafe stack would otherwise break
+ existing code. If old code used a structure member which used to be STACK
+ and is now STACK_OF (for example cert in a PKCS7_SIGNED structure) with
+ sk_num or sk_value it would produce an error because the num, data members
+ are not present in STACK_OF. Now it just produces a warning. sk_set
+ replaces the old method of assigning a value to sk_value
+ (e.g. sk_value(x, i) = y) which the library used in a few cases. Any code
+ that does this will no longer work (and should use sk_set instead) but
+ this could be regarded as a "questionable" behaviour anyway.
+ [Steve Henson]
+
*) Fix most of the other PKCS#7 bugs. The "experimental" code can now
correctly handle encrypted S/MIME data.
[Steve Henson]
EVP_CIPHER *enc;
-#define _ITER_ 2048
#define NOKEYS 0x1
#define NOCERTS 0x2
int options = 0;
int chain = 0;
int badarg = 0;
- int iter = _ITER_;
+ int iter = PKCS12_DEFAULT_ITER;
int maciter = 1;
int twopass = 0;
int keytype = 0;
#endif
else if (!strcmp (*args, "-des3")) enc = EVP_des_ede3_cbc();
else if (!strcmp (*args, "-noiter")) iter = 1;
- else if (!strcmp (*args, "-maciter")) maciter = _ITER_;
+ else if (!strcmp (*args, "-maciter"))
+ maciter = PKCS12_DEFAULT_ITER;
else if (!strcmp (*args, "-nodes")) enc=NULL;
else if (!strcmp (*args, "-inkey")) {
if (args[1]) {
goto err;
}
}
- sk_value(*skp,idx)=(char *)a;
+ sk_set(*skp,idx, (char *)a);
ret=idx;
err:
MemCheck_on();
}
i++;
}
- sk_value(ad->sk,idx)=val;
+ sk_set(ad->sk,idx,val);
return(1);
}
MemCheck_on();
}
if (hash_func != NULL)
- sk_value(names_hash,ret)=(char *)hash_func;
+ sk_set(names_hash,ret,(char *)hash_func);
if (cmp_func != NULL)
- sk_value(names_cmp,ret)= (char *)cmp_func;
+ sk_set(names_cmp,ret,(char *)cmp_func);
if (free_func != NULL)
- sk_value(names_free,ret)=(char *)free_func;
+ sk_set(names_free,ret,(char *)free_func);
return(ret);
}
/* Set defaults */
if(!nid_cert) nid_cert = NID_pbe_WithSHA1And40BitRC2_CBC;
if(!nid_key) nid_key = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
- if(!iter) iter = 2048;
+ if(!iter) iter = PKCS12_DEFAULT_ITER;
if(!mac_iter) mac_iter = 1;
if(!pkey || !cert) {
#define PKCS12_IV_ID 2
#define PKCS12_MAC_ID 3
+/* Default iteration count */
+#ifndef PKCS12_DEFAULT_ITER
+#define PKCS12_DEFAULT_ITER 2048
+#endif
+
#define PKCS12_MAC_KEY_LENGTH 20
#define PKCS12_SALT_LEN 8
p7si->auth_attr=sk_dup(sk);
for (i=0; i<sk_num(sk); i++)
{
- if ((sk_value(p7si->auth_attr,i)=(char *)X509_ATTRIBUTE_dup(
- (X509_ATTRIBUTE *)sk_value(sk,i))) == NULL)
+ if ((sk_set(p7si->auth_attr,i,(char *)X509_ATTRIBUTE_dup(
+ (X509_ATTRIBUTE *)sk_value(sk,i)))) == NULL)
return(0);
}
return(1);
p7si->unauth_attr=sk_dup(sk);
for (i=0; i<sk_num(sk); i++)
{
- if ((sk_value(p7si->unauth_attr,i)=(char *)X509_ATTRIBUTE_dup(
- (X509_ATTRIBUTE *)sk_value(sk,i))) == NULL)
+ if ((sk_set(p7si->unauth_attr,i,(char *)X509_ATTRIBUTE_dup(
+ (X509_ATTRIBUTE *)sk_value(sk,i)))) == NULL)
return(0);
}
return(1);
{
X509_ATTRIBUTE_free(attr);
attr=X509_ATTRIBUTE_create(nid,atrtype,value);
- sk_value(*sk,i)=(char *)attr;
+ sk_set(*sk,i,(char *)attr);
goto end;
}
}
void sk_##type##_free(STACK_OF(type) *sk) \
{ sk_free((STACK *)sk); } \
int sk_##type##_num(const STACK_OF(type) *sk) \
- { return sk_num((const STACK *)sk); } \
+ { return M_sk_num((const STACK *)sk); } \
type *sk_##type##_value(const STACK_OF(type) *sk,int n) \
{ return (type *)sk_value((STACK *)sk,n); } \
type *sk_##type##_set(STACK_OF(type) *sk,int n,type *v) \
- { return (type *)(sk_value((STACK *)sk,n)=(char *)v); } \
+ { return (type *)(sk_set((STACK *)sk,n,(char *)v)); } \
void sk_##type##_zero(STACK_OF(type) *sk) \
{ sk_zero((STACK *)sk); } \
int sk_##type##_push(STACK_OF(type) *sk,type *v) \
Free((char *)st);
}
+int sk_num(STACK *st)
+{
+ if(st == NULL) return -1;
+ return st->num;
+}
+
+char *sk_value(STACK *st, int i)
+{
+ if(st == NULL) return NULL;
+ return st->data[i];
+}
+
+char *sk_set(STACK *st, int i, char *value)
+{
+ if(st == NULL) return NULL;
+ return (st->data[i] = value);
+}
int (*comp)();
} STACK;
-#define sk_num(sk) ((sk)->num)
-#define sk_value(sk,n) ((sk)->data[n])
#define sk_new_null() sk_new(NULL)
+#define M_sk_num(sk) ((sk)->num)
+#define M_sk_value(sk,n) ((sk)->data[n])
+
+int sk_num(STACK *);
+char *sk_value(STACK *, int);
+
+char *sk_set(STACK *, int, char *);
+
STACK *sk_new(int (*cmp)());
void sk_free(STACK *);
void sk_pop_free(STACK *st, void (*func)());
EVP_PBE_CipherInit 1650
X509V3_add_value_bool_nf 1651
d2i_ASN1_UINTEGER 1652
+sk_value 1653
+sk_num 1654
+sk_set 1655