pgpkeys.pas
来自「用DELPHI实现的 PGP 加密算法」· PAS 代码 · 共 1,703 行 · 第 1/5 页
PAS
1,703 行
{$J+,Z4}
unit pgpKeys;
{**********************************************************************************}
{ }
{ The contents of this file are subject to the Mozilla Public License Version 1.1 }
{ (the "License"); you may not use this file except in compliance with the }
{ License. You may obtain a copy of the License at http://www.mozilla.org/MPL/. }
{ }
{ Software distributed under the License is distributed on an "AS IS" basis, }
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the }
{ specific language governing rights and limitations under the License. }
{ }
{ The Original Code is the "Borland Delphi Runtime Library PGPsdk" released 10 Apr }
{ 2000, available at http://www.oz.net/~srheller/dpgp/sdk/. }
{ }
{ The Initial Developer of the Original Code is Steven R. Heller. }
{ }
{ Portions created by Steven R. Heller are Copyright (C) 2000 Steven R. Heller. }
{ All Rights Reserved. }
{ }
{ Contributor(s): Michael in der Wiesche <idw.doc@t-online.de> ("idw"). }
{ }
{ The original file is pgpKeys.pas based on pgpKeys.h from the PGP sources }
{ which are Copyright (C) Network Associates Inc. and affiliated companies. }
{ }
{ Modifications by "idw" (other than stated in the code below): }
{ }
{ Lots of stuff removed (especially from PGP versions 5.5.X and 6.0.X); }
{ all functions taking OptionLists modified according to a suggestion }
{ by Steven R. Heller, for details see pgpOptionList.pas; wrapper }
{ functions added for version specific implementations }
{ }
{**********************************************************************************}
interface
uses
pgpBase,
pgpErrors,
pgpPubTypes,
pgpEvents;
type
{ Key Ordering }
PGPKeyOrdering = PGPEnumType;
const
// PGP 6.5.X
kPGPInvalidOrdering = 00;
kPGPAnyOrdering = 01;
kPGPUserIDOrdering = 02;
kPGPReverseUserIDOrdering = 03;
kPGPKeyIDOrdering = 04;
kPGPReverseKeyIDOrdering = 05;
kPGPValidityOrdering = 06;
kPGPReverseValidityOrdering = 07;
kPGPTrustOrdering = 08;
kPGPReverseTrustOrdering = 09;
kPGPEncryptKeySizeOrdering = 10;
kPGPReverseEncryptKeySizeOrdering = 11;
kPGPSigKeySizeOrdering = 12;
kPGPReverseSigKeySizeOrdering = 13;
kPGPCreationOrdering = 14;
kPGPReverseCreationOrdering = 15;
kPGPExpirationOrdering = 16;
kPGPReverseExpirationOrdering = 17;
// PGP 7.X
kPGPKeyOrdering_Invalid = 0;
kPGPKeyOrdering_Any = 1;
kPGPKeyOrdering_UserID = 2;
kPGPKeyOrdering_KeyID = 3;
kPGPKeyOrdering_Validity = 4;
kPGPKeyOrdering_Trust = 5;
kPGPKeyOrdering_EncryptionKeySize = 6;
kPGPKeyOrdering_SigningKeySize = 7;
kPGPKeyOrdering_CreationDate = 8;
kPGPKeyOrdering_ExpirationDate = 9;
// properties PGP 6.5.X
type
{ Key Properties }
PGPKeyPropName = PGPEnumType;
const
// String Properties
kPGPKeyPropFingerprint = 001;
kPGPKeyPropPreferredAlgorithms = 002;
kPGPKeyPropThirdPartyRevocationKeyID = 003;
// Number Properties
kPGPKeyPropAlgID = 020;
kPGPKeyPropBits = 021;
kPGPKeyPropTrust = 022;
kPGPKeyPropValidity = 023;
kPGPKeyPropLockingAlgID = 024;
kPGPKeyPropLockingBits = 025;
kPGPKeyPropFlags = 026;
// Time Properties
kPGPKeyPropCreation = 040;
kPGPKeyPropExpiration = 041;
// PGPBoolean Properties
kPGPKeyPropIsSecret = 060;
kPGPKeyPropIsAxiomatic = 061;
kPGPKeyPropIsRevoked = 062;
kPGPKeyPropIsDisabled = 063;
kPGPKeyPropIsNotCorrupt = 064;
kPGPKeyPropIsExpired = 065;
kPGPKeyPropNeedsPassphrase = 066;
kPGPKeyPropHasUnverifiedRevocation = 067;
kPGPKeyPropCanEncrypt = 068;
kPGPKeyPropCanDecrypt = 069;
kPGPKeyPropCanSign = 070;
kPGPKeyPropCanVerify = 071;
kPGPKeyPropIsEncryptionKey = 072;
kPGPKeyPropIsSigningKey = 073;
kPGPKeyPropIsSecretShared = 074;
kPGPKeyPropIsRevocable = 075;
kPGPKeyPropHasThirdPartyRevocation = 076;
type
{ User ID Properties }
PGPUserIDPropName = PGPEnumType;
const
// String Properties
kPGPUserIDPropName = 080;
kPGPUserIDPropAttributeData = 081;
// Number Properties
kPGPUserIDPropValidity = 100;
kPGPUserIDPropConfidence = 101;
kPGPUserIDPropAttributeType = 102;
// PGPBoolean Properties
kPGPUserIDPropIsAttribute = 110;
type
{ Signature Properties }
PGPSigPropName = PGPEnumType;
const
// String Properties
kPGPSigPropKeyID = 120;
kPGPSigPropX509Certificate = 121;
// Number Properties
kPGPSigPropAlgID = 140;
kPGPSigPropTrustLevel = 141;
kPGPSigPropTrustValue = 142;
// Time Properties
kPGPSigPropCreation = 160;
kPGPSigPropExpiration = 161;
// PGPBoolean Properties
kPGPSigPropIsRevoked = 180;
kPGPSigPropIsNotCorrupt = 181;
kPGPSigPropIsTried = 182;
kPGPSigPropIsVerified = 183;
kPGPSigPropIsMySig = 184;
kPGPSigPropIsExportable = 185;
kPGPSigPropHasUnverifiedRevocation = 186;
kPGPSigPropIsExpired = 187;
kPGPSigPropIsX509 = 188;
// properties PGP 7.X
type
PGPKeyDBObjProperty = PGPEnumType;
const
kPGPKeyDBObjProperty_Invalid = 000;
// Generic numeric properties
kPGPKeyDBObjProperty_ObjectType = 020;
// Key boolean properties
kPGPKeyProperty_IsSecret = 100;
kPGPKeyProperty_IsAxiomatic = 101;
kPGPKeyProperty_IsRevoked = 102;
kPGPKeyProperty_IsDisabled = 103;
kPGPKeyProperty_IsNotCorrupt = 104;
kPGPKeyProperty_IsExpired = 105;
kPGPKeyProperty_NeedsPassphrase = 106;
kPGPKeyProperty_HasUnverifiedRevocation = 107;
kPGPKeyProperty_CanEncrypt = 108;
kPGPKeyProperty_CanDecrypt = 109;
kPGPKeyProperty_CanSign = 110;
kPGPKeyProperty_CanVerify = 111;
kPGPKeyProperty_IsEncryptionKey = 112;
kPGPKeyProperty_IsSigningKey = 113;
kPGPKeyProperty_IsSecretShared = 114;
kPGPKeyProperty_IsRevocable = 115;
kPGPKeyProperty_HasThirdPartyRevocation = 116;
kPGPKeyProperty_HasCRL = 117;
kPGPKeyProperty_IsOnToken = 118;
// Key numeric properties
kPGPKeyProperty_AlgorithmID = 200;
kPGPKeyProperty_Bits = 201;
kPGPKeyProperty_Trust = 202;
kPGPKeyProperty_Validity = 203;
kPGPKeyProperty_LockingAlgorithmID = 204;
kPGPKeyProperty_LockingBits = 205;
kPGPKeyProperty_Flags = 206;
kPGPKeyProperty_HashAlgorithmID = 207;
kPGPKeyProperty_Version = 208;
kPGPKeyProperty_KeyServerPreferences = 209;
kPGPKeyProperty_TokenNum = 210;
// Key time properties
kPGPKeyProperty_Creation = 300;
kPGPKeyProperty_Expiration = 301;
kPGPKeyProperty_CRLThisUpdate = 302;
kPGPKeyProperty_CRLNextUpdate = 303;
// Key data (variable sized) properties
kPGPKeyProperty_Fingerprint = 401;
kPGPKeyProperty_KeyID = 402;
kPGPKeyProperty_PreferredAlgorithms = 403;
kPGPKeyProperty_ThirdPartyRevocationKeyID = 404;
kPGPKeyProperty_KeyData = 405;
kPGPKeyProperty_X509MD5Hash = 406;
kPGPKeyProperty_PreferredKeyServer = 407;
// SubKey boolean properties
kPGPSubKeyProperty_IsRevoked = 501;
kPGPSubKeyProperty_IsNotCorrupt = 502;
kPGPSubKeyProperty_IsExpired = 503;
kPGPSubKeyProperty_NeedsPassphrase = 504;
kPGPSubKeyProperty_HasUnverifiedRevocation = 505;
kPGPSubKeyProperty_IsRevocable = 506;
kPGPSubKeyProperty_HasThirdPartyRevocation = 507;
kPGPSubKeyProperty_IsOnToken = 508;
// SubKey numeric properties
kPGPSubKeyProperty_AlgorithmID = 600;
kPGPSubKeyProperty_Bits = 601;
kPGPSubKeyProperty_LockingAlgorithmID = 602;
kPGPSubKeyProperty_LockingBits = 603;
kPGPSubKeyProperty_Version = 604;
kPGPSubKeyProperty_Flags = 605;
// SubKey time properties
kPGPSubKeyProperty_Creation = 700;
kPGPSubKeyProperty_Expiration = 701;
// SubKey data (variable sized) properties
kPGPSubKeyProperty_KeyData = 800;
kPGPSubKeyProperty_KeyID = 801;
// User ID boolean properties
kPGPUserIDProperty_IsAttribute = 900;
// User ID numeric properties
kPGPUserIDProperty_Validity = 1000;
kPGPUserIDProperty_Confidence = 1001;
kPGPUserIDProperty_AttributeType = 1002;
// User ID data (variable sized) properties
kPGPUserIDProperty_Name = 1200;
kPGPUserIDProperty_AttributeData = 1201;
kPGPUserIDProperty_CommonName = 1202;
kPGPUserIDProperty_EmailAddress = 1203;
// Signature boolean properties
kPGPSigProperty_IsRevoked = 1300;
kPGPSigProperty_IsNotCorrupt = 1301;
kPGPSigProperty_IsTried = 1302;
kPGPSigProperty_IsVerified = 1303;
kPGPSigProperty_IsMySig = 1304;
kPGPSigProperty_IsExportable = 1305;
kPGPSigProperty_HasUnverifiedRevocation = 1306;
kPGPSigProperty_IsExpired = 1307;
kPGPSigProperty_IsX509 = 1308;
// Signature numeric properties
kPGPSigProperty_AlgorithmID = 1400;
kPGPSigProperty_TrustLevel = 1401;
kPGPSigProperty_TrustValue = 1402;
// Signature time properties
kPGPSigProperty_Creation = 1500;
kPGPSigProperty_Expiration = 1501;
// Signature data (variable sized) properties
kPGPSigProperty_KeyID = 1600;
kPGPSigProperty_X509Certificate = 1601;
kPGPSigProperty_X509IASN = 1602;
kPGPSigProperty_X509LongName = 1603;
kPGPSigProperty_X509IssuerLongName = 1604;
kPGPSigProperty_X509DNSName = 1605;
kPGPSigProperty_X509IPAddress = 1606;
kPGPSigProperty_X509DERDName = 1607;
// PGP 7.X only
type
{ For kPGPKeyProperty_Version }
PGPKeyVersion = PGPEnumType;
const
kPGPKeyVersion_V3 = 3;
kPGPKeyVersion_V4 = 4;
// both versions
type
{ kPGPKeyPropFlags bits }
PGPKeyPropertyFlags = PGPEnumType; // PGPKeyPropFlags in PGP 6.5.X
const
kPGPKeyPropertyFlags_UsageSignUserIDs = (1 shl 0);
kPGPKeyPropertyFlags_UsageSignMessages = (1 shl 1);
kPGPKeyPropertyFlags_UsageEncryptCommunications = (1 shl 2);
kPGPKeyPropertyFlags_UsageEncryptStorage = (1 shl 3);
kPGPKeyPropertyFlags_PrivateSplit = (1 shl 4);
kPGPKeyPropertyFlags_PrivateShared = (1 shl 7);
kPGPKeyPropertyFlags_UsageSign = kPGPKeyPropertyFlags_UsageSignUserIDs // PGP 7.X
or kPGPKeyPropertyFlags_UsageSignMessages;
kPGPKeyPropertyFlags_UsageEncrypt = kPGPKeyPropertyFlags_UsageEncryptCommunications // PGP 7.X
or kPGPKeyPropertyFlags_UsageEncryptStorage;
kPGPKeyPropertyFlags_UsageSignEncrypt = kPGPKeyPropertyFlags_UsageSign // PGP 7.X
or kPGPKeyPropertyFlags_UsageEncrypt;
// PGP 6.5.X only
type
{ PGPKeyRingOpenFlags }
PGPKeyRingOpenFlags = PGPUInt32;
const
kPGPKeyRingOpenFlags_Reserved = (1 shl 0);
kPGPKeyRingOpenFlags_Mutable = (1 shl 1);
kPGPKeyRingOpenFlags_Create = (1 shl 2);
// The following flags are only used by PGPOpenKeyRing
kPGPKeyRingOpenFlags_Private = (1 shl 8);
kPGPKeyRingOpenFlags_Trusted = (1 shl 9);
// PGP 7.X only
type
{ PGPKeyDBFileOptions }
PGPOpenKeyDBFileOptions = PGPEnumType;
const
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?