2011-12-29 19:39:19 +01:00
|
|
|
/*
|
2015-09-17 13:41:26 -04:00
|
|
|
* Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
2011-12-29 19:39:19 +01:00
|
|
|
* Copyright (C) 2011 Sourcefire, Inc.
|
|
|
|
|
*
|
|
|
|
|
* Authors: aCaB
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
|
* MA 02110-1301, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-12-21 19:52:34 +01:00
|
|
|
#ifndef __CRTMGR_H
|
|
|
|
|
#define __CRTMGR_H
|
|
|
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
|
|
#include "bignum.h"
|
|
|
|
|
|
2018-08-24 09:58:57 -04:00
|
|
|
typedef enum {CLI_SHA1RSA, CLI_MD5RSA, CLI_MD2RSA, CLI_RSA, CLI_SHA256RSA, CLI_SHA384RSA, CLI_SHA512RSA } cli_crt_hashtype;
|
2012-01-06 20:06:29 +01:00
|
|
|
typedef enum {VRFY_CODE, VRFY_TIME} cli_vrfy_type;
|
2011-12-21 19:52:34 +01:00
|
|
|
|
2016-03-23 15:28:51 -04:00
|
|
|
#define CRT_RAWMAXLEN 64
|
2011-12-21 22:52:46 +01:00
|
|
|
typedef struct cli_crt_t {
|
2013-02-19 09:24:19 -05:00
|
|
|
char *name;
|
2016-03-23 15:28:51 -04:00
|
|
|
uint8_t raw_subject[CRT_RAWMAXLEN];
|
|
|
|
|
uint8_t raw_issuer[CRT_RAWMAXLEN];
|
|
|
|
|
uint8_t raw_serial[CRT_RAWMAXLEN];
|
2011-12-21 19:52:34 +01:00
|
|
|
uint8_t subject[SHA1_HASH_SIZE];
|
|
|
|
|
uint8_t issuer[SHA1_HASH_SIZE];
|
2012-01-09 14:20:05 +01:00
|
|
|
uint8_t serial[SHA1_HASH_SIZE];
|
2018-08-23 11:37:40 -04:00
|
|
|
/* tbshash holds the hash we'll use for verification with data in the sig,
|
|
|
|
|
* so it must have at least enough space for the largest hash in
|
|
|
|
|
* cli_crt_hashtype */
|
2018-09-13 15:00:34 -04:00
|
|
|
uint8_t tbshash[SHA512_HASH_SIZE];
|
2011-12-21 19:52:34 +01:00
|
|
|
mp_int n;
|
|
|
|
|
mp_int e;
|
|
|
|
|
mp_int sig;
|
|
|
|
|
time_t not_before;
|
|
|
|
|
time_t not_after;
|
|
|
|
|
cli_crt_hashtype hashtype;
|
2012-01-05 19:20:34 +01:00
|
|
|
int certSign;
|
|
|
|
|
int codeSign;
|
|
|
|
|
int timeSign;
|
2012-10-18 10:41:12 -04:00
|
|
|
int isBlacklisted;
|
2011-12-21 22:52:46 +01:00
|
|
|
struct cli_crt_t *prev;
|
|
|
|
|
struct cli_crt_t *next;
|
2011-12-21 19:52:34 +01:00
|
|
|
} cli_crt;
|
|
|
|
|
|
2011-12-21 22:52:46 +01:00
|
|
|
typedef struct {
|
|
|
|
|
cli_crt *crts;
|
2011-12-25 03:49:38 +01:00
|
|
|
unsigned int items;
|
2011-12-21 22:52:46 +01:00
|
|
|
} crtmgr;
|
|
|
|
|
|
|
|
|
|
|
2011-12-21 19:52:34 +01:00
|
|
|
int cli_crt_init(cli_crt *x509);
|
|
|
|
|
void cli_crt_clear(cli_crt *x509);
|
2011-12-25 03:49:38 +01:00
|
|
|
void crtmgr_init(crtmgr *m);
|
2011-12-30 16:07:53 +01:00
|
|
|
void crtmgr_free(crtmgr *m);
|
2011-12-21 22:52:46 +01:00
|
|
|
int crtmgr_add(crtmgr *m, cli_crt *x509);
|
2011-12-22 22:36:47 +01:00
|
|
|
cli_crt *crtmgr_lookup(crtmgr *m, cli_crt *x509);
|
2011-12-25 03:49:38 +01:00
|
|
|
void crtmgr_del(crtmgr *m, cli_crt *x509);
|
2012-01-06 22:17:59 +01:00
|
|
|
cli_crt *crtmgr_verify_crt(crtmgr *m, cli_crt *x509);
|
2012-01-12 19:26:37 +01:00
|
|
|
cli_crt *crtmgr_verify_pkcs7(crtmgr *m, const uint8_t *issuer, const uint8_t *serial, const void *signature, unsigned int signature_len, cli_crt_hashtype hashtype, const uint8_t *refhash, cli_vrfy_type vrfytype);
|
2012-10-27 14:58:03 -04:00
|
|
|
int crtmgr_add_roots(struct cl_engine *engine, crtmgr *m);
|
2011-12-21 22:52:46 +01:00
|
|
|
|
2011-12-27 19:26:26 +01:00
|
|
|
|
2011-12-21 19:52:34 +01:00
|
|
|
#endif
|