Blame include/libssh/pki_priv.h

Packit Service 31306d
/*
Packit Service 31306d
 * This file is part of the SSH Library
Packit Service 31306d
 *
Packit Service 31306d
 * Copyright (c) 2010 by Aris Adamantiadis
Packit Service 31306d
 *
Packit Service 31306d
 * This library is free software; you can redistribute it and/or
Packit Service 31306d
 * modify it under the terms of the GNU Lesser General Public
Packit Service 31306d
 * License as published by the Free Software Foundation; either
Packit Service 31306d
 * version 2.1 of the License, or (at your option) any later version.
Packit Service 31306d
 *
Packit Service 31306d
 * This library is distributed in the hope that it will be useful,
Packit Service 31306d
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 31306d
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 31306d
 * Lesser General Public License for more details.
Packit Service 31306d
 *
Packit Service 31306d
 * You should have received a copy of the GNU Lesser General Public
Packit Service 31306d
 * License along with this library; if not, write to the Free Software
Packit Service 31306d
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Packit Service 31306d
 */
Packit Service 31306d
Packit Service 31306d
#ifndef PKI_PRIV_H_
Packit Service 31306d
#define PKI_PRIV_H_
Packit Service 31306d
Packit Service 31306d
#include "libssh/pki.h"
Packit Service 31306d
Packit Service 31306d
/* defined in bcrypt_pbkdf.c */
Packit Service 31306d
int bcrypt_pbkdf(const char *pass,
Packit Service 31306d
                 size_t passlen,
Packit Service 31306d
                 const uint8_t *salt,
Packit Service 31306d
                 size_t saltlen,
Packit Service 31306d
                 uint8_t *key,
Packit Service 31306d
                 size_t keylen,
Packit Service 31306d
                 unsigned int rounds);
Packit Service 31306d
Packit Service 31306d
#define RSA_HEADER_BEGIN "-----BEGIN RSA PRIVATE KEY-----"
Packit Service 31306d
#define RSA_HEADER_END "-----END RSA PRIVATE KEY-----"
Packit Service 31306d
#define DSA_HEADER_BEGIN "-----BEGIN DSA PRIVATE KEY-----"
Packit Service 31306d
#define DSA_HEADER_END "-----END DSA PRIVATE KEY-----"
Packit Service 31306d
#define ECDSA_HEADER_BEGIN "-----BEGIN EC PRIVATE KEY-----"
Packit Service 31306d
#define ECDSA_HEADER_END "-----END EC PRIVATE KEY-----"
Packit Service 31306d
#define OPENSSH_HEADER_BEGIN "-----BEGIN OPENSSH PRIVATE KEY-----"
Packit Service 31306d
#define OPENSSH_HEADER_END "-----END OPENSSH PRIVATE KEY-----"
Packit Service 31306d
/* Magic defined in OpenSSH/PROTOCOL.key */
Packit Service 31306d
#define OPENSSH_AUTH_MAGIC      "openssh-key-v1"
Packit Service 31306d
Packit Service 31306d
int pki_key_ecdsa_nid_from_name(const char *name);
Packit Service 31306d
const char *pki_key_ecdsa_nid_to_name(int nid);
Packit Service 31306d
const char *ssh_key_signature_to_char(enum ssh_keytypes_e type,
Packit Service 31306d
                                      enum ssh_digest_e hash_type);
Packit Service 31306d
enum ssh_digest_e ssh_key_type_to_hash(ssh_session session,
Packit Service 31306d
                                       enum ssh_keytypes_e type);
Packit Service 31306d
Packit Service 31306d
/* SSH Key Functions */
Packit Service 31306d
ssh_key pki_key_dup(const ssh_key key, int demote);
Packit Service 31306d
int pki_key_generate_rsa(ssh_key key, int parameter);
Packit Service 31306d
int pki_key_generate_dss(ssh_key key, int parameter);
Packit Service 31306d
int pki_key_generate_ecdsa(ssh_key key, int parameter);
Packit Service 31306d
int pki_key_generate_ed25519(ssh_key key);
Packit Service 31306d
Packit Service 31306d
int pki_key_compare(const ssh_key k1,
Packit Service 31306d
                    const ssh_key k2,
Packit Service 31306d
                    enum ssh_keycmp_e what);
Packit Service 31306d
Packit Service 31306d
int pki_key_check_hash_compatible(ssh_key key,
Packit Service 31306d
                                  enum ssh_digest_e hash_type);
Packit Service 31306d
/* SSH Private Key Functions */
Packit Service 31306d
enum ssh_keytypes_e pki_privatekey_type_from_string(const char *privkey);
Packit Service 31306d
ssh_key pki_private_key_from_base64(const char *b64_key,
Packit Service 31306d
                                    const char *passphrase,
Packit Service 31306d
                                    ssh_auth_callback auth_fn,
Packit Service 31306d
                                    void *auth_data);
Packit Service 31306d
Packit Service 31306d
ssh_string pki_private_key_to_pem(const ssh_key key,
Packit Service 31306d
                                  const char *passphrase,
Packit Service 31306d
                                  ssh_auth_callback auth_fn,
Packit Service 31306d
                                  void *auth_data);
Packit Service 31306d
int pki_import_privkey_buffer(enum ssh_keytypes_e type,
Packit Service 31306d
                              ssh_buffer buffer,
Packit Service 31306d
                              ssh_key *pkey);
Packit Service 31306d
Packit Service 31306d
/* SSH Public Key Functions */
Packit Service 31306d
int pki_pubkey_build_dss(ssh_key key,
Packit Service 31306d
                         ssh_string p,
Packit Service 31306d
                         ssh_string q,
Packit Service 31306d
                         ssh_string g,
Packit Service 31306d
                         ssh_string pubkey);
Packit Service 31306d
int pki_pubkey_build_rsa(ssh_key key,
Packit Service 31306d
                         ssh_string e,
Packit Service 31306d
                         ssh_string n);
Packit Service 31306d
int pki_pubkey_build_ecdsa(ssh_key key, int nid, ssh_string e);
Packit Service 31306d
ssh_string pki_publickey_to_blob(const ssh_key key);
Packit Service 31306d
Packit Service 31306d
/* SSH Private Key Functions */
Packit Service 31306d
int pki_privkey_build_dss(ssh_key key,
Packit Service 31306d
                          ssh_string p,
Packit Service 31306d
                          ssh_string q,
Packit Service 31306d
                          ssh_string g,
Packit Service 31306d
                          ssh_string pubkey,
Packit Service 31306d
                          ssh_string privkey);
Packit Service 31306d
int pki_privkey_build_rsa(ssh_key key,
Packit Service 31306d
                          ssh_string n,
Packit Service 31306d
                          ssh_string e,
Packit Service 31306d
                          ssh_string d,
Packit Service 31306d
                          ssh_string iqmp,
Packit Service 31306d
                          ssh_string p,
Packit Service 31306d
                          ssh_string q);
Packit Service 31306d
int pki_privkey_build_ecdsa(ssh_key key,
Packit Service 31306d
                            int nid,
Packit Service 31306d
                            ssh_string e,
Packit Service 31306d
                            ssh_string exp);
Packit Service 31306d
ssh_string pki_publickey_to_blob(const ssh_key key);
Packit Service 31306d
Packit Service 31306d
/* SSH Signature Functions */
Packit Service 31306d
ssh_signature pki_sign_data(const ssh_key privkey,
Packit Service 31306d
                            enum ssh_digest_e hash_type,
Packit Service 31306d
                            const unsigned char *input,
Packit Service 31306d
                            size_t input_len);
Packit Service 31306d
int pki_verify_data_signature(ssh_signature signature,
Packit Service 31306d
                              const ssh_key pubkey,
Packit Service 31306d
                              const unsigned char *input,
Packit Service 31306d
                              size_t input_len);
Packit Service 31306d
ssh_string pki_signature_to_blob(const ssh_signature sign);
Packit Service 31306d
ssh_signature pki_signature_from_blob(const ssh_key pubkey,
Packit Service 31306d
                                      const ssh_string sig_blob,
Packit Service 31306d
                                      enum ssh_keytypes_e type,
Packit Service 31306d
                                      enum ssh_digest_e hash_type);
Packit Service 31306d
Packit Service 31306d
/* SSH Signing Functions */
Packit Service 31306d
ssh_signature pki_do_sign(const ssh_key privkey,
Packit Service 31306d
                          const unsigned char *input,
Packit Service 31306d
                          size_t input_len,
Packit Service 31306d
                          enum ssh_digest_e hash_type);
Packit Service 31306d
ssh_signature pki_do_sign_hash(const ssh_key privkey,
Packit Service 31306d
                               const unsigned char *hash,
Packit Service 31306d
                               size_t hlen,
Packit Service 31306d
                               enum ssh_digest_e hash_type);
Packit Service 31306d
int pki_ed25519_sign(const ssh_key privkey, ssh_signature sig,
Packit Service 31306d
        const unsigned char *hash, size_t hlen);
Packit Service 31306d
int pki_ed25519_verify(const ssh_key pubkey, ssh_signature sig,
Packit Service 31306d
        const unsigned char *hash, size_t hlen);
Packit Service 31306d
int pki_ed25519_key_cmp(const ssh_key k1,
Packit Service 31306d
                const ssh_key k2,
Packit Service 31306d
                enum ssh_keycmp_e what);
Packit Service 31306d
int pki_ed25519_key_dup(ssh_key new, const ssh_key key);
Packit Service 31306d
int pki_ed25519_public_key_to_blob(ssh_buffer buffer, ssh_key key);
Packit Service 31306d
ssh_string pki_ed25519_signature_to_blob(ssh_signature sig);
Packit Service 31306d
int pki_signature_from_ed25519_blob(ssh_signature sig, ssh_string sig_blob);
Packit Service 31306d
int pki_privkey_build_ed25519(ssh_key key,
Packit Service 31306d
                              ssh_string pubkey,
Packit Service 31306d
                              ssh_string privkey);
Packit Service 31306d
Packit Service 31306d
/* PKI Container OpenSSH */
Packit Service 31306d
ssh_key ssh_pki_openssh_pubkey_import(const char *text_key);
Packit Service 31306d
ssh_key ssh_pki_openssh_privkey_import(const char *text_key,
Packit Service 31306d
        const char *passphrase, ssh_auth_callback auth_fn, void *auth_data);
Packit Service 31306d
ssh_string ssh_pki_openssh_privkey_export(const ssh_key privkey,
Packit Service 31306d
        const char *passphrase, ssh_auth_callback auth_fn, void *auth_data);
Packit Service 31306d
Packit Service 31306d
#endif /* PKI_PRIV_H_ */