Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

stDERUtils

Feature notes: PKIX / CMS implementation notes

Classes, interfaces and records

classeInvalidDERData

inherits from Exception

(no public members)

classeInternalASN1Error

inherits from Exception

(no public members)

classeInvalidTag

inherits from eAbort

(no public members)

recordObjectIdentifier

fData: ObjectIdentifierString; function GetChar(aIndex: Integer): AnsiChar; inline;
Reader behind the default Char property: returns the (1-based) character at aIndex of the dotted OID string. Full description »
procedure SetChar(aIndex: Integer; aValue: AnsiChar); inline;
Writer behind the default Char property: overwrites the (1-based) character at aIndex of the dotted OID string. Internal wiring an application rarely invokes directly; present only so aOID[i] := c compiles the same way whether ObjectIdentifier is a plain string or this record.
function Copy(aOffset, aLength: Integer): ObjectIdentifier;
Substring of the dotted OID, as an ObjectIdentifier. A METHOD rather than a Copy() overload on purpose: declaring a user Copy makes the compiler resolve Copy against the user overload set, which shadows the intrinsic for dynamic arrays (Copy(TBytes,...) then fails to compile). Full description »
property Char[aIndex: Integer]: AnsiChar read GetChar write SetChar; default;
Default indexer giving 1-based character access into the dotted OID string, mirroring how a plain-AnsiString ObjectIdentifier would be subscripted. Full description »

recordtSafeBytes

function Length: Integer;
Delegates to System.Length, forwarding fData, and returns its result.
function GetData: Pointer;
Returns the current value of the fData field.
procedure SetLength(aNewLength: Integer);

recordtSystemTime

wYear: Word; wMonth: Word; wDayOfWeek: Word; wDay: Word; wHour: Word; wMinute: Word; wSecond: Word; wMilliseconds: Word;

interfaceiDERDateTime

function UTCTimeToSystemTime(const aStr : tBytes; aOffset, aCount : Integer; var aTime : tSystemTime) : Boolean; function UTCTimeToDateTime(const aStr : tBytes; aOffset, aCount : Integer; var aTime: tDateTime) : Boolean; function X509GeneralizedTimeToDateTime(const aStr : tBytes; aOffset, aCount : Integer; var aTime : tDateTime) : Boolean; function GeneralizedTimeToSystemTime(const aStr : tBytes; aOffset, aCount : Integer; var aTime : tSystemTime) : Boolean; function GeneralizedTimeToDateTime(const aStr : tBytes; aOffset, aCount : Integer; var aTime : tDateTime) : Boolean; function SystemTimeToUTCTime(const aTime: tSystemTime): OctetString; function DateTimeToUTCTime(const aTime: tDateTime): OctetString; function SystemTimeToX509GeneralizedTime(const aTime: tSystemTime): OctetString; function DateTimeToX509GeneralizedTime(const aTime: tDateTime): OctetString; function SystemTimeToGeneralizedTime(const aTime: tSystemTime): OctetString; function DateTimeToGeneralizedTime(const aTime: tDateTime): OctetString;

interfaceiDERString

function BytesToOS(const aBuf: tBytes): OctetString; function OSToBytes(const aOS: OctetString): tBytes; function OSToHex(const aOSStr : OctetString; aNoSpaces: Boolean = False) : AnsiString; function HexToOS(const aHexStr: AnsiString): OctetString; function BytesToHex(const aOSStr : tBytes; aOffset, aCount : Integer; aNoSpaces: Boolean = False) : string; overload; function BytesToHex(const aOSStr : tBytes; aNoSpaces: Boolean = False) : string; overload; function HexToBytes(const aHexStr: AnsiString): tBytes; function ExtractSubIden(const aOID : ObjectIdentifier; var aStartPos: Integer) : Int64; function OIDToBytes(const aOID : ObjectIdentifier; aPrefix: tOIDPrefix = opNone) : tBytes; function Utf8ToUnicode(const aStr: OctetString): string; function UnicodeToUtf8(const aStr: string): OctetString; function BMPToUnicode(const aStr: OctetString; aLen: Integer): string; function UnicodeToBMP(const aStr: string): OctetString; function TrimPrintable(const aStr: string): string;

interfaceiReadOnlyDERHeader

inherits from iBaseInterface

function GetCheckType: Boolean; function GetConstructed: Boolean; function GetCls: Byte; function GetTag: Cardinal; function GetActualTag: Cardinal; function GetLength: Int64; function GetVarName: string; function GetTypeName: string; property CheckType: Boolean read GetCheckType; property Constructed: Boolean read GetConstructed; property Cls: Byte read GetCls; property Tag: Cardinal read GetTag; property ActualTag: Cardinal read GetActualTag; property Length: Int64 read GetLength; property VarName: string read GetVarName; property TypeName: string read GetTypeName;

classtBaseDERHeader

inherits from tMappedObject

implements iUnknown, iBaseInterface

procedure AfterConstruction; override; procedure BeforeDestruction; override; class function NewInstance: tObject; override; property RefCount: Integer read fRefCount; constructor CreateTag(aCls : Byte; aConstructed: Boolean; aTag : Cardinal; aCheckType : Boolean; const aName : string); procedure Assign(aSource: tMappedObject; aAddMustResolve: tAddMustResolveEvent = nil); override; property CheckType: Boolean read fCheckType write SetCheckType; property VarName: string read fVarName write SetVarName; property NamePath: string read GetNamePath; property Cls: Byte read fCls write SetCls; property Constructed: Boolean read fConstructed write SetConstructed; property Tag: Cardinal read fTag write SetTag; property Length: Int64 read fLength write SetLength; property Header: tBytes read fHeader;

classtDERHeader

(no public members)

interfaceiDERHeader

inherits from iBaseInterface

function GetCheckType: Boolean; function GetConstructed: Boolean; function GetCls: Byte; function GetTag: Cardinal; function GetLength: Int64; function GetVarName: string; function GetTypeName: string; procedure SetCheckType(const Value: Boolean); procedure SetCls(const Value: Byte); procedure SetConstructed(const Value: Boolean); procedure SetLength(const Value: Int64); procedure SetTag(const Value: Cardinal); procedure SetVarName(const Value: string); procedure SetTypeName(const Value: string); function ReadHeaderFromBuf(const aBuf : tBytes; var aOffset: Integer; var aCount : Integer) : Boolean; function ReadHeaderFromStream(aStream: tStream): Boolean; procedure WriteHeaderToBuf(const aBuf : tBytes; var aOffset: Integer; var aCount : Integer); procedure WriteHeaderToStream(aStream: tStream); property CheckType: Boolean read GetCheckType write SetCheckType; property Constructed: Boolean read GetConstructed write SetConstructed; property Cls: Byte read GetCls write SetCls; property Tag: Cardinal read GetTag write SetTag; property Length: Int64 read GetLength write SetLength; property VarName: string read GetVarName write SetVarName; property TypeName: string read GetTypeName write SetTypeName;

interfaceiDERData

inherits from iReadOnlyDERHeader

function CalculateLength(aWithTag: Boolean = False): Int64; function DERContents: OctetString; function DisplayContent: string; procedure LoadFromFile(const aFileName: string; aFormat: Byte); function LoadFromStream(const aStream: tStream; aFormat: Byte) : Int64; procedure SaveToFile(const aFileName: string; aFormat: Byte); function SaveToStream(const aStream: tStream; aFormat: Byte) : Int64;

interfaceiDERDataReadWrite

inherits from iDERHeader

function CalculateLength(aWithTag: Boolean = False): Int64; function DERContents: OctetString; function DisplayContent: string; function Compare(const aStruct: iDERDataReadWrite): Boolean; procedure CopyStreamedContents(const aSource: iDERDataReadWrite); procedure LoadFromFile(const aFileName: string; aFormat: Byte); function LoadFromStream(const aStream: tStream; aFormat: Byte) : Int64; procedure SaveToFile(const aFileName: string; aFormat: Byte); function SaveToStream(const aStream: tStream; aFormat: Byte) : Int64;

classtDERHeader

inherits from tBaseDERHeader

constructor Create(aOwner: tDERHeader); virtual; constructor CreateIntf(aOwner: iBaseInterface); virtual; constructor CreateTag(aOwner : tDERHeader; aParent : tDERHeader; aCls : Byte; aConstructed: Boolean; aTag : Cardinal; aCheckType : Boolean; const aName : string); virtual; constructor CreateBuf(aOwner : tDERHeader; aParent : tDERHeader; const aBuf : tBytes; var aOffset: Integer; var aCount : Integer; const aName : string); virtual; destructor Destroy; override; procedure Assign(aSource : tMappedObject; aAddMustResolve: tAddMustResolveEvent = nil); override; function CloneOwned(aOwner: iBaseInterface): iBaseInterface; function IndexOf(aItem: iDERHeader): Integer; virtual; abstract; property Owner: tDERHeader read fOwner; property Parent: tDERHeader read fParent; property Delegate: tDERHeader read fDelegate;

classtInterfacedDERHeader

inherits from tBaseDERHeader

implements iDERHeader

constructor CreateInitialize(); override;

interfaceiDERSetParent

function GetOwner: tDERHeader; function GetParent: tDERHeader; procedure SetOwner(Value: tDERHeader); procedure SetParent(Value: tDERHeader); property Owner: tDERHeader read GetOwner write SetOwner; property Parent: tDERHeader read GetParent write SetParent;

Types (enumerations, sets, aliases)

typetBytes

  tBytes = stMemoryMapFiler.tByteArray;

typeUInt8

  UInt8 = Byte;

typeUInt32

  UInt32 = Cardinal;

typeInt32

  Int32 = Integer;

typePtrUInt

  PtrUInt = UIntPtr;

typePtrUInt

  PtrUInt = NativeUInt;

typePtrUInt

  PtrUInt = Cardinal;    // 32-bit-only compiler: a pointer is four bytes

typeUnicodeString

  UnicodeString = WideString;

typeObjectIdentifierString

  ObjectIdentifierString = string;

typeObjectIdentifierString

  ObjectIdentifierString = AnsiString;

typeObjectIdentifier

  ObjectIdentifier = type ObjectIdentifierString;

arrayOctetString

  OctetString = array of OctetChar;

typePOctetChar

  POctetChar = ^OctetChar;

typeOctetString

  OctetString = type RawByteString;

typeOctetString

  OctetString = type AnsiString;

typePOctetChar

  POctetChar = PAnsiChar;

arraytSafeByteArray

tSafeBytes is a RTTI compatible replacement for TBytes. Some compilers will not output extended RTTI for methods that have an argument or a result of a generic type instance, such as TBytes = TArray<Byte>.

  tSafeByteArray = array of Byte;

enumtOIDPrefix

  tOIDPrefix = (opNone,opOIDTag,opOIDandSEQUENCETag);

typetDERHeaderClass

  tDERHeaderClass = class of tDERHeader;

Routines