Difference between revisions of "Unit X.509"

From Ultibo.org
Jump to: navigation, search
 
(3 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
----
 
----
  
'''Ultibo X.509 interface unit'''
+
'''Ultibo X.509 Interface unit'''
  
 
X.509 is a standard that defines the format of public key certificates. An X.509 certificate contains a public key and an identity (a hostname, or an organization, or an individual), and is either signed by a certificate authority or self-signed. When a certificate is signed by a trusted certificate authority, or validated by other means, someone holding that certificate can rely on the public key it contains to establish secure communications with another party, or validate documents digitally signed by the corresponding private key.
 
X.509 is a standard that defines the format of public key certificates. An X.509 certificate contains a public key and an identity (a hostname, or an organization, or an individual), and is either signed by a certificate authority or self-signed. When a certificate is signed by a trusted certificate authority, or validated by other means, someone holding that certificate can rely on the public key it contains to establish secure communications with another party, or validate documents digitally signed by the corresponding private key.
Line 139: Line 139:
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Note: RFC5280 Section 4.2.1.3. - Key Usage
 
|-
 
|-
 
| <code>X509_KEY_USAGE_DIGITAL_SIGNATURE = (1 shl 0);</code>
 
| <code>X509_KEY_USAGE_DIGITAL_SIGNATURE = (1 shl 0);</code>
| style="width: 50%;"|&nbsp;
+
| digitalSignature - The digitalSignature bit is asserted when the subject public key is used for verifying digital signatures, other than signatures on certificates.
 
|-
 
|-
 
| <code>X509_KEY_USAGE_NON_REPUDIATION = (1 shl 1);</code>
 
| <code>X509_KEY_USAGE_NON_REPUDIATION = (1 shl 1);</code>
| &nbsp;
+
| nonRepudiation - The nonRepudiation bit is asserted when the subject public key is used to verify digital signatures, other than signatures on certificates.
 
|-
 
|-
 
| <code>X509_KEY_USAGE_KEY_ENCIPHERMENT = (1 shl 2);</code>
 
| <code>X509_KEY_USAGE_KEY_ENCIPHERMENT = (1 shl 2);</code>
| &nbsp;
+
| keyEncipherment - The keyEncipherment bit is asserted when the subject public key is used for enciphering private or secret keys, i.e., for key transport
 
|-
 
|-
 
| <code>X509_KEY_USAGE_DATA_ENCIPHERMENT = (1 shl 3);</code>
 
| <code>X509_KEY_USAGE_DATA_ENCIPHERMENT = (1 shl 3);</code>
| &nbsp;
+
| dataEncipherment - The dataEncipherment bit is asserted when the subject public key is used for directly enciphering raw user data without the use of an intermediate symmetric cipher.
 
|-
 
|-
 
| <code>X509_KEY_USAGE_KEY_AGREEMENT = (1 shl 4);</code>
 
| <code>X509_KEY_USAGE_KEY_AGREEMENT = (1 shl 4);</code>
| &nbsp;
+
| keyAgreement - The keyAgreement bit is asserted when the subject public key is used for key agreement
 
|-
 
|-
 
| <code>X509_KEY_USAGE_KEY_CERT_SIGN = (1 shl 5);</code>
 
| <code>X509_KEY_USAGE_KEY_CERT_SIGN = (1 shl 5);</code>
| &nbsp;
+
| keyCertSign - The keyCertSign bit is asserted when the subject public key is used for verifying signatures on public key certificates
 
|-
 
|-
 
| <code>X509_KEY_USAGE_CRL_SIGN = (1 shl 6);</code>
 
| <code>X509_KEY_USAGE_CRL_SIGN = (1 shl 6);</code>
| &nbsp;
+
| cRLSign - The cRLSign bit is asserted when the subject public key is used for verifying signatures on certificate revocation lists
 
|-
 
|-
 
| <code>X509_KEY_USAGE_ENCIPHER_ONLY = (1 shl 7);</code>
 
| <code>X509_KEY_USAGE_ENCIPHER_ONLY = (1 shl 7);</code>
| &nbsp;
+
| encipherOnly -  When the encipherOnly bit is asserted and the keyAgreement bit is also set, the subject public key may be used only for enciphering data while performing key agreement.
 
|-
 
|-
 
| <code>X509_KEY_USAGE_DECIPHER_ONLY = (1 shl 8);</code>
 
| <code>X509_KEY_USAGE_DECIPHER_ONLY = (1 shl 8);</code>
| &nbsp;
+
| decipherOnly - When the decipherOnly bit is asserted and the keyAgreement bit is also set, the subject public key may be used only for deciphering data while performing key agreement.
 
|-
 
|-
 
|}
 
|}
 
</div></div>
 
</div></div>
<br />  
+
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<div style="font-size: 14px; padding-left: 12px;">'''X509 certificate extended key usage''' <code> X509_EXT_KEY_USAGE_* </code></div>
 
<div style="font-size: 14px; padding-left: 12px;">'''X509 certificate extended key usage''' <code> X509_EXT_KEY_USAGE_* </code></div>
Line 175: Line 177:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
| <code>X509_EXT_KEY_USAGE_ANY = (1 shl 0);</code>
+
| <code>X509_EXT_KEY_USAGE_ANY = (1 shl 0);</code>
 
| style="width: 50%;"|&nbsp;
 
| style="width: 50%;"|&nbsp;
 
|-
 
|-
Line 185: Line 187:
 
|-
 
|-
 
| <code>X509_EXT_KEY_USAGE_OCSP = (1 shl 3);</code>
 
| <code>X509_EXT_KEY_USAGE_OCSP = (1 shl 3);</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''X509 certificate file types''' <code> NAME_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>X509_FILETYPE_PEM = 1;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>X509_FILETYPE_ASN1 = 2;</code>
 
| &nbsp;
 
| &nbsp;
 
|-
 
|-
Line 284: Line 300:
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Algorithm:TX509AlgorithmIdentifier;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>Key:PByte;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Length:Integer;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>procedure Release;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function ToString:String;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''X509 private key'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PX509PrivateKey = ^TX509PrivateKey;</code>
 +
 +
<code>TX509PrivateKey = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Note: RFC3447 - Appendix A.1.2 - RSA private key syntax
 +
|-
 +
|colspan="2"|&nbsp;
 
|-
 
|-
 
| <code>Algorithm:TX509AlgorithmIdentifier;</code>
 
| <code>Algorithm:TX509AlgorithmIdentifier;</code>
Line 481: Line 532:
  
  
'''X509 name'''
+
'''X509 specific classes'''
  
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 
+
<code>TX509Name = class(TObject)</code>
+
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
+
{| class="wikitable" style="font-size: 14px; background: white;"
+
 
|-
 
|-
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
+
| [[TX509Name|<code>TX509Name = class(TObject)</code>]]
|-
+
| <code>function StringCompare(const AValue1,AValue2:String):Integer;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
+
|-
+
| <code>NameAttributes:TX509NameAttributes;</code>
+
| &nbsp;
+
|-
+
| <code>NameAttributeCount:LongWord;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>Email:String;</code>
+
| emailAddress
+
|-
+
|colspan="2"|''From subjectAltName extension''
+
|-
+
| <code>AltEmail:String;</code>
+
| rfc822Name
+
|-
+
| <code>DNS:String;</code>
+
| dNSName
+
|-
+
| <code>URI:String;</code>
+
| uniformResourceIdentifier
+
|-
+
| <code>IP:PByte;</code>
+
| iPAddress
+
|-
+
| <code>IPLen:Longword;</code>
+
| IPv4 = 4,IPv6 = 16
+
|-
+
| <code>RegisteredID:TASN1OID;</code>
+
| registeredID
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>destructor Destroy; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function GetCN:String;</code>
+
| &nbsp;
+
|-
+
| <code>function GetDN:String;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function Compare(AName:TX509Name):Integer;</code>
+
| &nbsp;
+
 
|-
 
|-
 
|}
 
|}
</div></div>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
+
'''X509 certificate''' 
+
+
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
+
 
+
<code>TX509Certificate = class;</code>
+
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
+
{| class="wikitable" style="font-size: 14px; background: white;"
+
 
|-
 
|-
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
+
| [[TX509CertificateList|<code>TX509CertificateList = class(TObject)</code>]]
|-
+
|colspan="2"|&nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
+
|-
+
|colspan="2"|&nbsp;
+
 
|-
 
|-
 
|}
 
|}
</div></div>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
+
'''X509 certificate list''' 
+
 
+
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
+
 
+
<code>TX509CertificateList = class(TObject)</code>
+
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
+
{| class="wikitable" style="font-size: 14px; background: white;"
+
 
|-
 
|-
|colspan="2"|<div style="font-family: monospace,courier;">'''protected'''</div>
+
| [[TX509CertificateChain|<code>TX509CertificateChain = class(TObject)</code>]]
|-
+
| <code>FList:TList;</code>
+
| style="width: 50%;"|&nbsp;
+
|-
+
| <code>FLock: TCriticalSectionHandle;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>procedure Clear;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function AcquireLock:Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function ReleaseLock:Boolean;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
+
|-
+
| <code>constructor Create;</code>
+
| &nbsp;
+
|-
+
| <code>destructor Destroy; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function First:TX509Certificate; virtual;</code>
+
| &nbsp;
+
|-
+
| <code>function Last:TX509Certificate; virtual;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function Prev(ACertificate:TX509Certificate):TX509Certificate; virtual;</code>
+
| &nbsp;
+
|-
+
| <code>function Next(ACertificate:TX509Certificate):TX509Certificate; virtual;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function Add(ACertificate:TX509Certificate):Boolean; virtual;</code>
+
| &nbsp;
+
|-
+
| <code>function Remove(ACertificate:TX509Certificate):Boolean; virtual;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function FindByIssuer(AName:TX509Name):TX509Certificate; virtual;</code>
+
| &nbsp;
+
|-
+
| <code>function FindBySubject(AName:TX509Name):TX509Certificate; virtual;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function ImportDER(ABuffer:Pointer; ASize:Integer):TX509Certificate; virtual;</code>
+
| &nbsp;
+
|-
+
| <code>function ImportPEM(ABuffer:Pointer; var ASize:Integer):TX509Certificate; virtual;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function ExportDER(ABuffer:Pointer; var ASize:Integer; ACertificate:TX509Certificate):Boolean; virtual;</code>
+
| &nbsp;
+
|-
+
| <code>function ExportPEM(ABuffer:Pointer; var ASize:Integer; AStart:TX509Certificate):Boolean; virtual;</code>
+
| &nbsp;
+
 
|-
 
|-
 
|}
 
|}
</div></div>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 
+
'''X509 certificate chain'''
+
 
+
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
+
 
+
<code>TX509CertificateChain = class(TObject)</code>
+
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
+
{| class="wikitable" style="font-size: 14px; background: white;"
+
 
|-
 
|-
|colspan="2"|<div style="font-family: monospace,courier;">'''protected'''</div>
+
| [[TX509Certificate|<code>TX509Certificate = class(TObject)</code>]]
|-
+
| <code>FRoot:TX509Certificate;</code>
+
|  style="width: 50%;"|&nbsp;
+
|-
+
| <code>FLock: TCriticalSectionHandle;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>procedure Clear; virtual;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function AcquireLock:Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function ReleaseLock:Boolean;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
+
|-
+
| <code>property Root:TX509Certificate read FRoot;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>constructor Create(ARoot:TX509Certificate); virtual;</code>
+
| &nbsp;
+
|-
+
| <code>destructor Destroy; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function Last:TX509Certificate; virtual;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function Prev(ACertificate:TX509Certificate):TX509Certificate; virtual;</code>
+
| &nbsp;
+
|-
+
| <code>function Next(ACertificate:TX509Certificate):TX509Certificate; virtual;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function InsertAfter(AParent,ACertificate:TX509Certificate):Boolean; virtual;</code>
+
| &nbsp;
+
|-
+
| <code>function InsertBefore(AChild,ACertificate:TX509Certificate):Boolean; virtual;</code>
+
| &nbsp;
+
|-
+
| <code>function Remove(ACertificate:TX509Certificate):Boolean; virtual;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function FindByIssuer(AName:TX509Name):TX509Certificate; virtual;</code>
+
| &nbsp;
+
|-
+
| <code>function FindBySubject(AName:TX509Name):TX509Certificate; virtual;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function FindBySubjectCN(const AName:String):TX509Certificate; virtual;</code>
+
| &nbsp;
+
|-
+
| <code>function FindBySubjectDN(const AName:String):TX509Certificate; virtual;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function ImportDER(ABuffer:Pointer; ASize:Integer; AParent:TX509Certificate):TX509Certificate; virtual;</code>
+
| &nbsp;
+
|-
+
| <code>function ImportPEM(ABuffer:Pointer; var ASize:Integer; AParent:TX509Certificate):TX509Certificate; virtual;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function ExportDER(ABuffer:Pointer; var ASize:Integer; ACertificate:TX509Certificate):Boolean; virtual;</code>
+
| &nbsp;
+
|-
+
| <code>function ExportPEM(ABuffer:Pointer; var ASize:Integer; AStart:TX509Certificate):Boolean; virtual;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function GetPathLength(ACertificate:TX509Certificate):LongWord; virtual;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function ValidateChain(ATrust:TX509CertificateList):Integer; virtual;</code>
+
| &nbsp;
+
 
|-
 
|-
 
|}
 
|}
</div></div>
 
 
 
'''X509 certificate'''
 
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 
 
<code>TX509Certificate = class(TObject)</code>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|colspan="2"|<div style="font-family: monospace,courier;">'''protected'''</div>
 
|-
 
| <code>FList:TX509CertificateList;</code>
 
| &nbsp;
 
|-
 
| <code>FChain:TX509CertificateChain;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>FParent:TX509Certificate;</code>
 
| &nbsp;
 
|-
 
| <code>FChild:TX509Certificate;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>FData:PByte;</code>
 
| Copy of certificate data from import
 
|-
 
| <code>FSize:LongWord;</code>
 
| Total size of certificate data
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>FTBSData:PByte;</code>
 
| Pointer to start of TBS (To Be Signed) data
 
|-
 
| <code>FTBSSize:LongWord;</code>
 
| Length of TBS (To Be Signed) data
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>function ImportTime(ABuffer:PByte; ASize:Integer; ATag:LongWord  ADateTime:TDateTime):Boolean;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>function ImportName(ABuffer:PByte; ASize:Integer; AName:TX509Name; var ANext:PByte):Boolean;</code>
 
| &nbsp;
 
|-
 
| <code>function ImportExtensionAltName(ABuffer:PByte; ASize:Integer; AName:TX509Name):Boolean;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>function ImportAlgorithmIdentifier(ABuffer:PByte; ASize:Integer; var AIdentifier:TX509AlgorithmIdentifier; var ANext:PByte):Boolean;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>function ImportValidity(ABuffer:PByte; ASize:Integer; var ANext:PByte):Boolean;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>function ImportPublicKey(ABuffer:PByte; ASize:Integer; var ANext:PByte):Boolean;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>function ImportExtension(ABuffer:PByte; ASize:Integer; var ANext:PByte):Boolean;</code>
 
| &nbsp;
 
|-
 
| <code>function ImportExtensionData(ABuffer:PByte; ASize:Integer; const AOID:TASN1OID):Boolean;</code>
 
| &nbsp;
 
|-
 
| <code>function ImportExtensionKeyUsage(ABuffer:PByte; ASize:Integer):Boolean;</code>
 
| &nbsp;
 
|-
 
| <code>function ImportExtensionSubjectAltName(ABuffer:PByte; ASize:Integer):Boolean;</code>
 
| &nbsp;
 
|-
 
| <code>function ImportExtensionIssuerAltName(ABuffer:PByte; ASize:Integer):Boolean;</code>
 
| &nbsp;
 
|-
 
| <code>function ImportExtensionBasicContraints(ABuffer:PByte; ASize:Integer):Boolean;</code>
 
| &nbsp;
 
|-
 
| <code>function ImportExtensionExtKeyUsage(ABuffer:PByte; ASize:Integer):Boolean;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>function ImportExtensions(ABuffer:PByte; ASize:Integer):Boolean;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>function ImportTBSCertificate(ABuffer:PByte; ASize:Integer; var ANext:PByte):Boolean;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>function VerifyRSASignature(AIssuer:TX509Certificate):Boolean;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>function VerifyMD5Digest(ABuffer:PByte; ASize:Integer):Boolean;</code>
 
| &nbsp;
 
|-
 
| <code>function VerifySHA1Digest(ABuffer:PByte; ASize:Integer):Boolean;</code>
 
| &nbsp;
 
|-
 
| <code>function VerifySHA256Digest(ABuffer:PByte; ASize:Integer):Boolean;</code>
 
| &nbsp;
 
|-
 
| <code>function VerifySHA384Digest(ABuffer:PByte; ASize:Integer):Boolean;</code>
 
| &nbsp;
 
|-
 
| <code>function VerifySHA512Digest(ABuffer:PByte; ASize:Integer):Boolean;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 
|-
 
|colspan="2"|''Properties''
 
|-
 
| <code>Version:LongWord;</code>
 
| &nbsp;
 
|-
 
| <code>SerialNumber:TX509SerialNumber;</code>
 
| &nbsp;
 
|-
 
| <code>SignatureAlgorithm:TX509AlgorithmIdentifier;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>Issuer:TX509Name;</code>
 
| &nbsp;
 
|-
 
| <code>Subject:TX509Name;</code>
 
| &nbsp;
 
|-
 
| <code>SubjectDN:String;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>NotBefore:TDateTime;</code>
 
| &nbsp;
 
|-
 
| <code>NotAfter:TDateTime;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>PublicKey:TX509PublicKey;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>Signature:TX509Signature;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|''Extensions''
 
|-
 
| <code>ExtensionsPresent:LongWord;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>CA:Boolean;</code>
 
| &nbsp;
 
|-
 
| <code>PathLenConstraint:LongWord;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>KeyUsage:LongWord;</code>
 
| &nbsp;
 
|-
 
| <code>ExtendedKeyUsage:LongWord;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>property List:TX509CertificateList read FList;</code>
 
| &nbsp;
 
|-
 
| <code>property Chain:TX509CertificateChain read FChain;</code>
 
| &nbsp;
 
|-
 
| <code>property Parent:TX509Certificate read FParent;</code>
 
| &nbsp;
 
|-
 
| <code>property Child:TX509Certificate read FChild;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>constructor Create(AChain:TX509CertificateChain; AParent:TX509Certificate); virtual;</code>
 
| &nbsp;
 
|-
 
| <code>destructor Destroy; override;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>function ImportDER(ABuffer:Pointer; ASize:Integer):Boolean; virtual;</code>
 
| &nbsp;
 
|-
 
| <code>function ImportPEM(ABuffer:Pointer; var ASize:Integer):Boolean; virtual;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>function ExportDER(ABuffer:Pointer; var ASize:Integer):Boolean; virtual;</code>
 
| &nbsp;
 
|-
 
| <code>function ExportPEM(ABuffer:Pointer; var ASize:Integer):Boolean; virtual;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>function IsValidIssuer:Boolean; virtual;</code>
 
| &nbsp;
 
|-
 
| <code>function IsSelfSigned:Boolean; virtual;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>function VerifySignature(AIssuer:TX509Certificate):Boolean; virtual;</code>
 
| &nbsp;
 
|-
 
| <code>function ValidateCertificate(AIssuer:TX509Certificate):Integer; virtual;</code>
 
| &nbsp;
 
|-
 
|}
 
</div></div>
 
 
<br />
 
<br />
  

Latest revision as of 04:48, 31 August 2021

Return to Unit Reference


Description


Ultibo X.509 Interface unit

X.509 is a standard that defines the format of public key certificates. An X.509 certificate contains a public key and an identity (a hostname, or an organization, or an individual), and is either signed by a certificate authority or self-signed. When a certificate is signed by a trusted certificate authority, or validated by other means, someone holding that certificate can rely on the public key it contains to establish secure communications with another party, or validate documents digitally signed by the corresponding private key.

This unit currently only provides the basic functionality required to read and parse an X.509 certificate in DER or PEM format and extract basic information such as the issuer, subject, validity, algorithm and public key.

It is expected that this unit will be expanded to incorporate additional functions over time.

Constants



[Expand]
X509 specific constants X509_*


[Expand]
X509 name attribute X509_NAME_ATTR_*


[Expand]
X509 validate X509_VALIDATE_*


[Expand]
X509 certificate version X509_CERT_V*


[Expand]
X509 certificate extension X509_EXT_*


[Expand]
X509 certificate key usage X509_KEY_USAGE_*


[Expand]
X509 certificate extended key usage X509_EXT_KEY_USAGE_*


[Expand]
X509 certificate file types NAME_*


Type definitions



X509 serial number

[Expand]

PX509SerialNumber = ^TX509SerialNumber;

TX509SerialNumber = record

X509 name attribute

[Expand]

PX509NameAttribute = ^TX509NameAttribute;

TX509NameAttribute = record

X509 name attributes

[Expand]

PX509NameAttributes = ^TX509NameAttributes;

TX509NameAttributes = array[0..X509_MAX_NAME_ATTRIBUTES - 1] of TX509NameAttribute;

X509 algorithm identifier

[Expand]

PX509AlgorithmIdentifier = ^TX509AlgorithmIdentifier;

TX509AlgorithmIdentifier = record

X509 public key

[Expand]

PX509PublicKey = ^TX509PublicKey;

TX509PublicKey = record

X509 private key

[Expand]

PX509PrivateKey = ^TX509PrivateKey;

TX509PrivateKey = record

X509 signature

[Expand]

PX509Signature = ^TX509Signature;

TX509Signature = record

X509 RSA public key

[Expand]

PX509RSAPublicKey = ^TX509RSAPublicKey;

TX509RSAPublicKey = record

X509 RSA private key

[Expand]

PX509RSAPrivateKey = ^TX509RSAPrivateKey;

TX509RSAPrivateKey = record

X509 ECDSA public key

[Expand]

PX509ECDSAPublicKey = ^TX509ECDSAPublicKey;

TX509ECDSAPublicKey = record

X509 ECDSA private key

[Expand]

PX509ECDSAPrivateKey = ^TX509ECDSAPrivateKey;

TX509ECDSAPrivateKey = record


Class definitions



X509 specific classes

TX509Name = class(TObject)
TX509CertificateList = class(TObject)
TX509CertificateChain = class(TObject)
TX509Certificate = class(TObject)


Public variables


None defined

Function declarations



X509 helper functions

[Expand]
function X509NameAttributeTypeToString(AType:LongWord):String;
Description: To be documented


Return to Unit Reference