"X.509 CRL",
"Private Key",
"Public Key",
- "Number"
+ "Number",
+ "Arbitrary Data"
};
const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1] =
const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1] =
{
0,
- -1, /* FRIENDLYNAME: C string */
+ -1, /* FRIENDLYNAME: C string */
SHA_DIGEST_LENGTH, /* KEYID: SHA1 digest, 160 bits */
SHA_DIGEST_LENGTH, /* ISSUERKEYID: SHA1 digest, 160 bits */
- SHA_DIGEST_LENGTH, /* SUBJECTKEYID: SHA1 digest, 160 bits */
+ SHA_DIGEST_LENGTH, /* SUBJECTKEYID: SHA1 digest, 160 bits */
SHA_DIGEST_LENGTH, /* ISSUERSERIALHASH: SHA1 digest, 160 bits */
sizeof(X509_NAME *), /* ISSUER: X509_NAME * */
sizeof(BIGNUM *), /* SERIAL: BIGNUM * */
{
STORE *ret;
- ret=(STORE *)OPENSSL_malloc(sizeof(STORE));
- if (ret == NULL)
+ if (method == NULL)
{
- STOREerr(STORE_F_STORE_NEW_METHOD,ERR_R_MALLOC_FAILURE);
+ STOREerr(STORE_F_STORE_NEW_METHOD,ERR_R_PASSED_NULL_PARAMETER);
return NULL;
}
- if (method == NULL)
+
+ ret=(STORE *)OPENSSL_malloc(sizeof(STORE));
+ if (ret == NULL)
{
- STOREerr(STORE_F_STORE_NEW_METHOD,ERR_R_PASSED_NULL_PARAMETER);
+ STOREerr(STORE_F_STORE_NEW_METHOD,ERR_R_MALLOC_FAILURE);
return NULL;
}
- else
- ret->meth=method;
+
+ ret->meth=method;
CRYPTO_new_ex_data(CRYPTO_EX_INDEX_STORE, ret, &ret->ex_data);
if (ret->meth->init && !ret->meth->init(ret))
int STORE_store_certificate(STORE *s, X509 *data, OPENSSL_ITEM attributes[],
OPENSSL_ITEM parameters[])
{
- STORE_OBJECT *object = STORE_OBJECT_new();
+ STORE_OBJECT *object;
int i;
check_store(s,STORE_F_STORE_CERTIFICATE,
store_object,STORE_R_NO_STORE_OBJECT_FUNCTION);
+ object = STORE_OBJECT_new();
if (!object)
{
STOREerr(STORE_F_STORE_CERTIFICATE,
REF_PRINT("EVP_PKEY",data);
#endif
pkey = object->data.key;
- STORE_OBJECT_free(object);TORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[],
+ STORE_OBJECT_free(object);
+ return pkey;
+ }
+
+int STORE_store_private_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[],
OPENSSL_ITEM parameters[])
{
- STORE_OBJECT *object = STORE_OBJECT_new();
+ STORE_OBJECT *object;
int i;
check_store(s,STORE_F_STORE_PRIVATE_KEY,
store_object,STORE_R_NO_STORE_OBJECT_FUNCTION);
+ object = STORE_OBJECT_new();
if (!object)
{
STOREerr(STORE_F_STORE_PRIVATE_KEY,
int STORE_store_public_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[],
OPENSSL_ITEM parameters[])
{
- STORE_OBJECT *object = STORE_OBJECT_new();
+ STORE_OBJECT *object;
int i;
check_store(s,STORE_F_STORE_PUBLIC_KEY,
store_object,STORE_R_NO_STORE_OBJECT_FUNCTION);
+ object = STORE_OBJECT_new();
if (!object)
{
STOREerr(STORE_F_STORE_PUBLIC_KEY,
int STORE_store_crl(STORE *s, X509_CRL *data, OPENSSL_ITEM attributes[],
OPENSSL_ITEM parameters[])
{
- STORE_OBJECT *object = STORE_OBJECT_new();
+ STORE_OBJECT *object;
int i;
check_store(s,STORE_F_STORE_CRL,
store_object,STORE_R_NO_STORE_OBJECT_FUNCTION);
+ object = STORE_OBJECT_new();
if (!object)
{
STOREerr(STORE_F_STORE_CRL,
int STORE_store_number(STORE *s, BIGNUM *data, OPENSSL_ITEM attributes[],
OPENSSL_ITEM parameters[])
{
- STORE_OBJECT *object = STORE_OBJECT_new();
+ STORE_OBJECT *object;
int i;
check_store(s,STORE_F_STORE_NUMBER,
store_object,STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION);
+ object = STORE_OBJECT_new();
if (!object)
{
STOREerr(STORE_F_STORE_NUMBER,
int STORE_store_arbitrary(STORE *s, BUF_MEM *data, OPENSSL_ITEM attributes[],
OPENSSL_ITEM parameters[])
{
- STORE_OBJECT *object = STORE_OBJECT_new();
+ STORE_OBJECT *object;
int i;
check_store(s,STORE_F_STORE_ARBITRARY,
store_object,STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION);
+ object = STORE_OBJECT_new();
if (!object)
{
STOREerr(STORE_F_STORE_ARBITRARY,
OPENSSL_free(data);
}
-IMPLEMENT_STACK_OF(STORE_OBJECT*);
+IMPLEMENT_STACK_OF(STORE_OBJECT*)
struct STORE_attr_info_st
return 0;
}
-int STORE_ATTR_INFO_compare(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b)
+static int attr_info_compare_compute_range(
+ unsigned char *abits, unsigned char *bbits,
+ unsigned int *alowp, unsigned int *ahighp,
+ unsigned int *blowp, unsigned int *bhighp)
{
- unsigned char *abits, *bbits;
- int i;
+ unsigned int alow = (unsigned int)-1, ahigh = 0;
+ unsigned int blow = (unsigned int)-1, bhigh = 0;
+ int i, res = 0;
- if (a == b) return 0;
- if (!a) return -1;
- if (!b) return 1;
- abits = a->set;
- bbits = b->set;
for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++)
{
- if (*abits < *bbits) return -1;
- if (*abits > *bbits) return 1;
+ if (res == 0)
+ {
+ if (*abits < *bbits) res = -1;
+ if (*abits > *bbits) res = 1;
+ }
+ if (*abits)
+ {
+ if (alow == (unsigned int)-1)
+ {
+ alow = i * 8;
+ if (!(*abits & 0x01)) alow++;
+ if (!(*abits & 0x02)) alow++;
+ if (!(*abits & 0x04)) alow++;
+ if (!(*abits & 0x08)) alow++;
+ if (!(*abits & 0x10)) alow++;
+ if (!(*abits & 0x20)) alow++;
+ if (!(*abits & 0x40)) alow++;
+ }
+ ahigh = i * 8 + 7;
+ if (!(*abits & 0x80)) ahigh++;
+ if (!(*abits & 0x40)) ahigh++;
+ if (!(*abits & 0x20)) ahigh++;
+ if (!(*abits & 0x10)) ahigh++;
+ if (!(*abits & 0x08)) ahigh++;
+ if (!(*abits & 0x04)) ahigh++;
+ if (!(*abits & 0x02)) ahigh++;
+ }
+ if (*bbits)
+ {
+ if (blow == (unsigned int)-1)
+ {
+ blow = i * 8;
+ if (!(*bbits & 0x01)) blow++;
+ if (!(*bbits & 0x02)) blow++;
+ if (!(*bbits & 0x04)) blow++;
+ if (!(*bbits & 0x08)) blow++;
+ if (!(*bbits & 0x10)) blow++;
+ if (!(*bbits & 0x20)) blow++;
+ if (!(*bbits & 0x40)) blow++;
+ }
+ bhigh = i * 8 + 7;
+ if (!(*bbits & 0x80)) bhigh++;
+ if (!(*bbits & 0x40)) bhigh++;
+ if (!(*bbits & 0x20)) bhigh++;
+ if (!(*bbits & 0x10)) bhigh++;
+ if (!(*bbits & 0x08)) bhigh++;
+ if (!(*bbits & 0x04)) bhigh++;
+ if (!(*bbits & 0x02)) bhigh++;
+ }
}
+ if (ahigh + alow < bhigh + blow) res = -1;
+ if (ahigh + alow > bhigh + blow) res = 1;
+ if (alowp) *alowp = alow;
+ if (ahighp) *ahighp = ahigh;
+ if (blowp) *blowp = blow;
+ if (bhighp) *bhighp = bhigh;
+ return res;
+ }
+
+int STORE_ATTR_INFO_compare(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b)
+ {
+ if (a == b) return 0;
+ if (!a) return -1;
+ if (!b) return 1;
+ return attr_info_compare_compute_range(a->set, b->set, 0, 0, 0, 0);
+ }
+int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b)
+ {
+ unsigned int alow, ahigh, blow, bhigh;
+
+ if (a == b) return 1;
+ if (!a) return 0;
+ if (!b) return 0;
+ attr_info_compare_compute_range(a->set, b->set,
+ &alow, &ahigh, &blow, &bhigh);
+ if (alow >= blow && ahigh <= bhigh)
+ return 1;
return 0;
}
int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b)
bbits = b->set;
for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++)
{
- if (*abits && *bbits != *abits)
+ if (*abits && (*bbits & *abits) != *abits)
return 0;
}
return 1;