1 /* GnuTLS --- Guile bindings for GnuTLS.
2 Copyright (C) 2007-2012 Free Software Foundation, Inc.
4 GnuTLS is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 GnuTLS is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with GnuTLS; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
18 /* Written by Ludovic Courtès <ludo@chbouib.org>. */
26 #include <gnutls/gnutls.h>
35 scm_from_gnutls_key_usage_flags (unsigned int c_usage
)
39 #define MATCH_USAGE(_value) \
40 if (c_usage & (_value)) \
42 usage = scm_cons (scm_from_gnutls_key_usage (_value), \
44 c_usage &= ~(_value); \
47 /* when the key is to be used for signing: */
48 MATCH_USAGE (GNUTLS_KEY_DIGITAL_SIGNATURE
);
49 MATCH_USAGE (GNUTLS_KEY_NON_REPUDIATION
);
50 /* when the key is to be used for encryption: */
51 MATCH_USAGE (GNUTLS_KEY_KEY_ENCIPHERMENT
);
52 MATCH_USAGE (GNUTLS_KEY_DATA_ENCIPHERMENT
);
53 MATCH_USAGE (GNUTLS_KEY_KEY_AGREEMENT
);
54 MATCH_USAGE (GNUTLS_KEY_KEY_CERT_SIGN
);
55 MATCH_USAGE (GNUTLS_KEY_CRL_SIGN
);
56 MATCH_USAGE (GNUTLS_KEY_ENCIPHER_ONLY
);
57 MATCH_USAGE (GNUTLS_KEY_DECIPHER_ONLY
);
59 if (EXPECT_FALSE (c_usage
!= 0))
60 /* XXX: We failed to interpret one of the usage flags. */
61 scm_gnutls_error (GNUTLS_E_UNIMPLEMENTED_FEATURE
, __func__
);
68 /* arch-tag: a55fe230-ead7-495d-ab11-dfe18452ca2a