⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 keyutils.h

📁 伯克利做的SFTP安全文件传输协议
💻 H
字号:
//  $Archive:: /STP/SafeTP/keyutils.h                                          $//     $Date: 2000/09/01 22:55:03 $// $Revision: 1.18 $// Description: key storage abstraction - used for storing key pairs// Copyright 1998, Dan Bonachea#ifndef _KEYUTILS_H#define _KEYUTILS_H#include "xassert.h"#include "str.h"#include "datablok.h"#if defined(SFTPD_PROJECT) || defined(SFTPC_PROJECT) || defined(VIEWKEY)#define SIMPLE_REGISTRY#endif#define SIMPLE_REGISTRY_BASE   "Software/UCB/sftp/" // need trailing slash// This module allows keys to be saved & retrieved from permanent storage,// while abstracting away the actual way they're stored// forceProtectedArea is used by NT Makekeys when the admin is //   creating DSA & ElGamal keys to be used by the SYSTEM user//   (parameter ignored on other platforms)int LoadKey(string& pathname, DataBlock& keydata, bool forceProtectedArea=false);// Load a key given the relative pathname, and store it in data// returns TRUE if successful, or FALSE on failure (key not found)int SaveKey(string& pathname, const DataBlock& keydata, bool forceProtectedArea=false);// Save a key to the relative pathname of the form: "dir/.../dir/keyname"// returns TRUE if successful, or FALSE on failure (disk full, permission problems)#define KEY_LINE_LENGTH   32int ReformatKey(char *key, bool includeCR=false);// adds newlines to make it look nice. // Be sure to base64 the key before calling this function// Assumes there's enough space in buffer to add them// returns new lengthunsigned long GetKeyChecksum(const unsigned char* data, int len);// returns a checksum derived from the key for ease of human verification// key should be in binary (not base64) formatstring GetKeyShaString(const DataBlock& key);// returns a sha of the DataBlock for ease of human verification// key should be in binary (not base64) format// This class is used by the client to perform searches based on keydata#if defined(__WIN32__) && !defined(SIMPLE_REGISTRY) // only on client  class KeySearch {    private:      string** pathlist;      int cnt;    public:      KeySearch(string& searchroot, string& keyname, const DataBlock& keydata);      ~KeySearch();      int count() { return cnt; }      string operator[](int index) {         xassert(index >= 0 && index < cnt);        return *(pathlist[index]);        }      void sortentries(); // simple strcmp sort of entries    };#endif// Scott's wrappers on Dan's key load/save routinesDataBlock sm_loadKey(char const *name, bool forceProtectedArea=false);void sm_saveKey(char const *name, DataBlock const &block, bool forceProtectedArea=false);bool sm_testKey(char const *name, bool forceProtectedArea=false);    // return true if key exists#endif // _KEYUTILS_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -