-/* $OpenBSD: x509_purp.c,v 1.8 2021/10/21 13:51:52 tb Exp $ */
+/* $OpenBSD: x509_purp.c,v 1.9 2021/10/22 18:37:15 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2001.
*/
}
return X509_V_OK;
}
+
+uint32_t
+X509_get_key_usage(X509 *x)
+{
+ /* Call for side-effect of computing hash and caching extensions */
+ if (X509_check_purpose(x, -1, -1) != 1)
+ return 0;
+
+ if (x->ex_flags & EXFLAG_KUSAGE)
+ return x->ex_kusage;
+
+ return UINT32_MAX;
+}
+
+uint32_t
+X509_get_extended_key_usage(X509 *x)
+{
+ /* Call for side-effect of computing hash and caching extensions */
+ if (X509_check_purpose(x, -1, -1) != 1)
+ return 0;
+
+ if (x->ex_flags & EXFLAG_XKUSAGE)
+ return x->ex_xkusage;
+
+ return UINT32_MAX;
+}
-/* $OpenBSD: x509v3.h,v 1.6 2021/10/21 13:51:52 tb Exp $ */
+/* $OpenBSD: x509v3.h,v 1.7 2021/10/22 18:37:15 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 1999.
*/
int X509_PURPOSE_get_trust(const X509_PURPOSE *xp);
void X509_PURPOSE_cleanup(void);
int X509_PURPOSE_get_id(const X509_PURPOSE *);
+#if defined(LIBRESSL_NEW_API)
+uint32_t X509_get_key_usage(X509 *x);
+uint32_t X509_get_extended_key_usage(X509 *x);
+#endif
STACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x);
STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x);