Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {$MINENUMSIZE 1}
- TOpenPGPPKAlgorithm = (
- pkRSA = 1,
- pkRSAEncryptOnly = 2,
- pkRSASignOnly = 3,
- pkElgamalEncryptOnly = 16,
- pkDSA = 17,
- pkReservedEC = 18,
- pkReservedECDSA = 19,
- pkReserved20 = 20,
- pkReservedDH = 21,
- pkPrivate100 = 100,
- pkPrivate101 = 101,
- pkPrivate102 = 102,
- pkPrivate103 = 103,
- pkPrivate104 = 104,
- pkPrivate105 = 105,
- pkPrivate106 = 106,
- pkPrivate107 = 107,
- pkPrivate108 = 108,
- pkPrivate109 = 109,
- pkPrivate110 = 110
- );
- function TPGPTag_Signature.ReadBody(PartOf: ITagStreamReader; Source: IIOReadable): OpenPGPResult; stdcall;
- var
- reader: IIOTypedReader;
- subpack: IIOReadable;
- wb: Byte;
- ww: Word;
- begin
- // some init
- reader:= TIOTypedReader.Create(Source);
- if not OpenPGPSuccess(reader.ReadByte(fVersion), Result) then
- Exit;
- case fVersion of
- 2, 3: {...};
- 4: begin
- if not OpenPGPSuccess(reader.ReadByte(wb), Result) then
- Exit;
- fSignatureType:= TOpenPGPSignatureType(wb);
- TraceDebug('V4 Signature: %s', [SignatureTypeToStr(fSignatureType)]);
- if not OpenPGPSuccess(reader.ReadByte(wb), Result) then
- Exit;
- fPKAlgo:= TOpenPGPPKAlgorithm(wb);
- {...}
- end;
- else
- TraceError('Unsupported Signature version: %d', [fVersion]);
- Exit(OPENPGP_ERROR_PACKET_INVALID_DATA);
- end;
- case fPKAlgo of
- pkRSA, pkRSASignOnly: begin
- fRSA_mdn:= TMPInteger.Create;
- if not OpenPGPSuccess(fRSA_mdn.Read(Source), Result) then
- Exit;
- end;
- pkDSA: begin
- fDSA_r:= TMPInteger.Create;
- fDSA_s:= TMPInteger.Create;
- if not OpenPGPSuccess(fDSA_r.Read(Source), Result) then
- Exit;
- if not OpenPGPSuccess(fDSA_s.Read(Source), Result) then
- Exit;
- end;
- else
- TraceWarn('Signature.ReadBody: Unknown Signature Algorithm: %s', [PKAlgorithmToStr(fPKAlgo)]);
- Exit(OPENPGP_ERROR_PACKET_INVALID_DATA);
- end;
- Result:= OPENPGP_ERROR_NOERROR;
- end;
- function SignatureTypeToStr(const X: TOpenPGPSignatureType): String;
- begin
- case X of
- stBinaryDocument : Result:= 'BinaryDocument';
- stCanonicalDocument : Result:= 'CanonicalDocument';
- stStandalone : Result:= 'Standalone';
- stUserIDCertificationGeneric : Result:= 'UserIDCertificationGeneric';
- stUserIDCertificationPersona : Result:= 'UserIDCertificationPersona';
- stUserIDCertificationCasual : Result:= 'UserIDCertificationCasual';
- stUserIDCertificationPositive : Result:= 'UserIDCertificationPositive';
- stSubkeyBinding : Result:= 'SubkeyBinding';
- stPrimaryKeyBinding : Result:= 'PrimaryKeyBinding';
- stDirectKey : Result:= 'DirectKey';
- stKeyRevocation : Result:= 'KeyRevocation';
- stSubKeyRevocation : Result:= 'SubKeyRevocation';
- stCertificationRevocation : Result:= 'CertificationRevocation';
- stTimestamp : Result:= 'Timestamp';
- stThirdPartyConfirmation : Result:= 'ThirdPartyConfirmation';
- else
- Str(Ord(X), Result);
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement