pgpgroups.pas
来自「用DELPHI实现的 PGP 加密算法」· PAS 代码 · 共 380 行 · 第 1/2 页
PAS
380 行
{$J+,Z4}
unit pgpGroups;
{**********************************************************************************}
{ }
{ 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 pgpGroups.pas based on pgpGroups.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) }
{ }
{**********************************************************************************}
interface
uses
pgpBase,
pgpPubTypes;
const
kPGPMaxGroupNameLength = 63;
kPGPMaxGroupDescriptionLength = 63;
type
PGPGroupName = Array[0..kPGPMaxGroupNameLength] of Char;
PGPGroupDescription = Array[0..kPGPMaxGroupDescriptionLength] of Char;
pPGPGroupSet = Pointer;
pPGPGroupItemIter = Pointer;
// any type will do that is distinct
PGPGroupID = PGPUInt32;
type
PGPGroupItemType = PGPEnumType;
const
kPGPGroupItem_KeyID = 1;
kPGPGroupItem_Group = 2;
{____________________________________________________________________________
A run-time group item, used when iterating through a group.
For client use; not necessarily the internal storage format.
____________________________________________________________________________}
type
// substructures for TPGPGroupItem union by SRH, modified by idw
TSubstructGroup = Packed Record
GroupID: PGPGroupID;
end;
TSubstructKey6 = Packed Record
Algorithm: PGPPublicKeyAlgorithm;
KeyID: TPGPKeyID7;
end;
TSubstructKey7 = Packed Record
KeyID: TPGPKeyID7;
end;
// TPGPGroupItem union by SRH, modified by idw
pPGPGroupItem = ^TPGPGroupItem;
TPGPGroupItem = Packed Record
ItemType : PGPGroupItemType; // selects which substructure
UserValue : PGPUserValue; // is *not* saved to disk
Item : Record case Longint of
1: (Group: TSubstructGroup); // if kGroupItem_Group
2: (Key: Record case Longint of // if kGroupItem_KeyID
6: (KeyStruct6: TSubstructKey6);
7: (KeyStruct7: TSubstructKey7);
end);
end;
Reserved: Array[0..3] of PGPUInt32; // PGP 6.5.X only
end;
type
TPGPGroupItemCompareProc = function(var Group1: pPGPGroupItem;
Group2: pPGPGroupItem; UserValue: PGPUserValue): PGPInt32; cdecl;
{____________________________________________________________________________
Info obtained via PGPGetGroupInfo.
____________________________________________________________________________}
type
TPGPGroupInfo = Record
ID : PGPGroupID;
Name : PGPGroupName;
Description : PGPGroupDescription;
UserValue : PGPUserValue;
end;
type
TPGPGroupItemIterFlags = PGPFlags;
const
// flag (1 shl 0 ) is reserved
kPGPGroupIterFlags_Recursive = (1 shl 1);
kPGPGroupIterFlags_Keys = (1 shl 2);
kPGPGroupIterFlags_Groups = (1 shl 3);
kPGPGroupIterFlags_AllKeysRecursive = kPGPGroupIterFlags_Recursive or kPGPGroupIterFlags_Keys;
kPGPGroupIterFlags_AllGroupsRecursive = kPGPGroupIterFlags_Recursive or kPGPGroupIterFlags_Groups;
kPGPGroupIterFlags_AllItems = kPGPGroupIterFlags_Keys or kPGPGroupIterFlags_Groups;
kPGPGroupIterFlags_AllRecursive = kPGPGroupIterFlags_Recursive or kPGPGroupIterFlags_AllItems;
{____________________________________________________________________________
Manipulating pgp group sets (pPGPGroupSet)
____________________________________________________________________________}
{ create a new, empty groups collection }
var PGPNewGroupSet: function(Context: pPGPContext;
var OutRef: pPGPGroupSet): PGPError; cdecl;
{ file is *not* left open; all data is loaded into memory }
var PGPNewGroupSetFromFile: function(Context: pPGPContext;
aFile: pPGPFileSpec;
var OutRef: pPGPGroupSet): PGPError; cdecl;
{ overwrites existing. Don't bother unless PGPGroupSetNeedsCommit() }
var PGPSaveGroupSetToFile: function(TheSet: pPGPGroupSet; aFile: pPGPFileSpec): PGPError; cdecl;
{ free all data structures; be sure to save first if you want }
var PGPFreeGroupSet: function(TheSet: pPGPGroupSet): PGPError; cdecl;
{ has the group changed? }
var PGPGroupSetNeedsCommit: function(TheSet: pPGPGroupSet): PGPBoolean; cdecl;
var PGPGetGroupSetContext: function(TheSet: pPGPGroupSet): pPGPContext; cdecl;
{ export the groupset to a buffer. Use PGPFreeData to free the buffer }
var PGPExportGroupSetToBuffer: function(TheSet: pPGPGroupSet;
var Buffer: Pointer;
var BufSize: PGPSize): PGPError; cdecl;
{ import a groupset from a buffer }
var PGPImportGroupSetFromBuffer: function(Context: pPGPContext;
var Buffer: Pointer;
BufSize: PGPSize;
var OutSet: pPGPGroupSet): PGPError; cdecl;
{____________________________________________________________________________
Manipulating groups
Groups are always referred to by IDs which remain valid until the set
is disposed.
____________________________________________________________________________}
{ initial parent ID is kPGPInvalidGroupID }
var PGPNewGroup: function(TheSet: pPGPGroupSet;
const Name: PChar;
const Description: PChar;
var Id: PGPGroupID): PGPError; cdecl;
var PGPCountGroupsInSet: function(TheSet: pPGPGroupSet;
var NumGroups: PGPUInt32): PGPError; cdecl;
var PGPGetIndGroupID: function(TheSet: pPGPGroupSet;
GroupIndex: PGPUInt32;
var Id: PGPGroupID): PGPError; cdecl;
{ delete this group from the Set: }
{ all references to it are removed in all sets }
var PGPDeleteGroup: function(TheSet: pPGPGroupSet;
Id: PGPGroupID): PGPError; cdecl;
{ delete the indexed item from the group }
{ the item may be a group or a key }
var PGPDeleteIndItemFromGroup: function(TheSet: pPGPGroupSet;
Id: PGPGroupID;
Item: PGPUInt32): PGPError; cdecl;
{ same as PGPDeleteIndItemFromGroup, but accepts an item }
var PGPDeleteItemFromGroup: function(TheSet: pPGPGroupSet;
Id: PGPGroupID;
const Item: pPGPGroupItem): PGPError; cdecl;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?