summaryrefslogtreecommitdiff
path: root/key.h
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2010-02-27 07:55:05 +1100
committerDamien Miller <djm@mindrot.org>2010-02-27 07:55:05 +1100
commit0a80ca190a39943029719facf7edb990def7ae62 (patch)
treee423e30d8412de67170b8240ba919df10ed8e391 /key.h
parentd27d85d5320bb946d4bb734dcf45a8d20bad6020 (diff)
- OpenBSD CVS Sync
- djm@cvs.openbsd.org 2010/02/26 20:29:54 [PROTOCOL PROTOCOL.agent PROTOCOL.certkeys addrmatch.c auth-options.c] [auth-options.h auth.h auth2-pubkey.c authfd.c dns.c dns.h hostfile.c] [hostfile.h kex.h kexdhs.c kexgexs.c key.c key.h match.h monitor.c] [myproposal.h servconf.c servconf.h ssh-add.c ssh-agent.c ssh-dss.c] [ssh-keygen.1 ssh-keygen.c ssh-rsa.c ssh.1 ssh.c ssh2.h sshconnect.c] [sshconnect2.c sshd.8 sshd.c sshd_config.5] Add support for certificate key types for users and hosts. OpenSSH certificate key types are not X.509 certificates, but a much simpler format that encodes a public key, identity information and some validity constraints and signs it with a CA key. CA keys are regular SSH keys. This certificate style avoids the attack surface of X.509 certificates and is very easy to deploy. Certified host keys allow automatic acceptance of new host keys when a CA certificate is marked as sh/known_hosts. see VERIFYING HOST KEYS in ssh(1) for details. Certified user keys allow authentication of users when the signing CA key is marked as trusted in authorized_keys. See "AUTHORIZED_KEYS FILE FORMAT" in sshd(8) for details. Certificates are minted using ssh-keygen(1), documentation is in the "CERTIFICATES" section of that manpage. Documentation on the format of certificates is in the file PROTOCOL.certkeys feedback and ok markus@
Diffstat (limited to 'key.h')
-rw-r--r--key.h32
1 files changed, 29 insertions, 3 deletions
diff --git a/key.h b/key.h
index 14aac79c2..6a2e049af 100644
--- a/key.h
+++ b/key.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: key.h,v 1.27 2008/06/11 21:01:35 grunk Exp $ */ 1/* $OpenBSD: key.h,v 1.28 2010/02/26 20:29:54 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
@@ -26,6 +26,7 @@
26#ifndef KEY_H 26#ifndef KEY_H
27#define KEY_H 27#define KEY_H
28 28
29#include "buffer.h"
29#include <openssl/rsa.h> 30#include <openssl/rsa.h>
30#include <openssl/dsa.h> 31#include <openssl/dsa.h>
31 32
@@ -34,6 +35,8 @@ enum types {
34 KEY_RSA1, 35 KEY_RSA1,
35 KEY_RSA, 36 KEY_RSA,
36 KEY_DSA, 37 KEY_DSA,
38 KEY_RSA_CERT,
39 KEY_DSA_CERT,
37 KEY_UNSPEC 40 KEY_UNSPEC
38}; 41};
39enum fp_type { 42enum fp_type {
@@ -49,20 +52,35 @@ enum fp_rep {
49/* key is stored in external hardware */ 52/* key is stored in external hardware */
50#define KEY_FLAG_EXT 0x0001 53#define KEY_FLAG_EXT 0x0001
51 54
55#define CERT_MAX_PRINCIPALS 256
56struct KeyCert {
57 Buffer certblob; /* Kept around for use on wire */
58 u_int type; /* SSH2_CERT_TYPE_USER or SSH2_CERT_TYPE_HOST */
59 char *key_id;
60 u_int nprincipals;
61 char **principals;
62 u_int64_t valid_after, valid_before;
63 Buffer constraints;
64 Key *signature_key;
65};
66
52struct Key { 67struct Key {
53 int type; 68 int type;
54 int flags; 69 int flags;
55 RSA *rsa; 70 RSA *rsa;
56 DSA *dsa; 71 DSA *dsa;
72 struct KeyCert *cert;
57}; 73};
58 74
59Key *key_new(int); 75Key *key_new(int);
76void key_add_private(Key *);
60Key *key_new_private(int); 77Key *key_new_private(int);
61void key_free(Key *); 78void key_free(Key *);
62Key *key_demote(const Key *); 79Key *key_demote(const Key *);
80int key_equal_public(const Key *, const Key *);
63int key_equal(const Key *, const Key *); 81int key_equal(const Key *, const Key *);
64char *key_fingerprint(const Key *, enum fp_type, enum fp_rep); 82char *key_fingerprint(Key *, enum fp_type, enum fp_rep);
65u_char *key_fingerprint_raw(const Key *, enum fp_type, u_int *); 83u_char *key_fingerprint_raw(Key *, enum fp_type, u_int *);
66const char *key_type(const Key *); 84const char *key_type(const Key *);
67int key_write(const Key *, FILE *); 85int key_write(const Key *, FILE *);
68int key_read(Key *, char **); 86int key_read(Key *, char **);
@@ -71,6 +89,14 @@ u_int key_size(const Key *);
71Key *key_generate(int, u_int); 89Key *key_generate(int, u_int);
72Key *key_from_private(const Key *); 90Key *key_from_private(const Key *);
73int key_type_from_name(char *); 91int key_type_from_name(char *);
92int key_is_cert(const Key *);
93int key_type_plain(int);
94int key_to_certified(Key *);
95int key_drop_cert(Key *);
96int key_certify(Key *, Key *);
97void key_cert_copy(const Key *, struct Key *);
98int key_cert_check_authority(const Key *, int, int, const char *,
99 const char **);
74 100
75Key *key_from_blob(const u_char *, u_int); 101Key *key_from_blob(const u_char *, u_int);
76int key_to_blob(const Key *, u_char **, u_int *); 102int key_to_blob(const Key *, u_char **, u_int *);