Przeglądaj źródła

some refactorings

Ugochukwu Mmaduekwe 22 godzin temu
rodzic
commit
fc94532d2f

+ 4 - 2
CryptoLib.Examples/Delphi.Examples/CryptoLib.Examples.dpr

@@ -225,7 +225,8 @@ uses
   ClpIPascalCoinECIESKdfBytesGenerator in '..\..\CryptoLib\src\Interfaces\Crypto\Generators\ClpIPascalCoinECIESKdfBytesGenerator.pas',
   ClpIPascalCoinIesEngine in '..\..\CryptoLib\src\Interfaces\Crypto\Engines\ClpIPascalCoinIesEngine.pas',
   ClpIPbeParametersGenerator in '..\..\CryptoLib\src\Interfaces\Crypto\Generators\ClpIPbeParametersGenerator.pas',
-  ClpIPemObjects in '..\..\CryptoLib\src\Interfaces\Pem\ClpIPemObjects.pas',
+  ClpIPemHeader in '..\..\CryptoLib\src\Interfaces\Pem\ClpIPemHeader.pas',
+  ClpIPemObject in '..\..\CryptoLib\src\Interfaces\Pem\ClpIPemObject.pas',
   ClpIPkcs1Encoding in '..\..\CryptoLib\src\Interfaces\Crypto\Encodings\ClpIPkcs1Encoding.pas',
   ClpIPkcs5S2ParametersGenerator in '..\..\CryptoLib\src\Interfaces\Crypto\Generators\ClpIPkcs5S2ParametersGenerator.pas',
   ClpIPkcsAsn1Objects in '..\..\CryptoLib\src\Interfaces\Asn1\Pkcs\ClpIPkcsAsn1Objects.pas',
@@ -319,7 +320,8 @@ uses
   ClpPascalCoinECIESKdfBytesGenerator in '..\..\CryptoLib\src\Crypto\Generators\ClpPascalCoinECIESKdfBytesGenerator.pas',
   ClpPascalCoinIesEngine in '..\..\CryptoLib\src\Crypto\Engines\ClpPascalCoinIesEngine.pas',
   ClpPbeParametersGenerator in '..\..\CryptoLib\src\Crypto\Generators\ClpPbeParametersGenerator.pas',
-  ClpPemObjects in '..\..\CryptoLib\src\Pem\ClpPemObjects.pas',
+  ClpPemHeader in '..\..\CryptoLib\src\Pem\ClpPemHeader.pas',
+  ClpPemObject in '..\..\CryptoLib\src\Pem\ClpPemObject.pas',
   ClpPkcs1Encoding in '..\..\CryptoLib\src\Crypto\Encodings\ClpPkcs1Encoding.pas',
   ClpPkcs5S2ParametersGenerator in '..\..\CryptoLib\src\Crypto\Generators\ClpPkcs5S2ParametersGenerator.pas',
   ClpPkcsAsn1Objects in '..\..\CryptoLib\src\Asn1\Pkcs\ClpPkcsAsn1Objects.pas',

+ 4 - 2
CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.dpr

@@ -236,7 +236,8 @@ uses
   ClpIPascalCoinECIESKdfBytesGenerator in '..\..\CryptoLib\src\Interfaces\Crypto\Generators\ClpIPascalCoinECIESKdfBytesGenerator.pas',
   ClpIPascalCoinIesEngine in '..\..\CryptoLib\src\Interfaces\Crypto\Engines\ClpIPascalCoinIesEngine.pas',
   ClpIPbeParametersGenerator in '..\..\CryptoLib\src\Interfaces\Crypto\Generators\ClpIPbeParametersGenerator.pas',
-  ClpIPemObjects in '..\..\CryptoLib\src\Interfaces\Pem\ClpIPemObjects.pas',
+  ClpIPemHeader in '..\..\CryptoLib\src\Interfaces\Pem\ClpIPemHeader.pas',
+  ClpIPemObject in '..\..\CryptoLib\src\Interfaces\Pem\ClpIPemObject.pas',
   ClpIPkcs1Encoding in '..\..\CryptoLib\src\Interfaces\Crypto\Encodings\ClpIPkcs1Encoding.pas',
   ClpIPkcs5S2ParametersGenerator in '..\..\CryptoLib\src\Interfaces\Crypto\Generators\ClpIPkcs5S2ParametersGenerator.pas',
   ClpIPkcsAsn1Objects in '..\..\CryptoLib\src\Interfaces\Asn1\Pkcs\ClpIPkcsAsn1Objects.pas',
@@ -330,7 +331,8 @@ uses
   ClpPascalCoinECIESKdfBytesGenerator in '..\..\CryptoLib\src\Crypto\Generators\ClpPascalCoinECIESKdfBytesGenerator.pas',
   ClpPascalCoinIesEngine in '..\..\CryptoLib\src\Crypto\Engines\ClpPascalCoinIesEngine.pas',
   ClpPbeParametersGenerator in '..\..\CryptoLib\src\Crypto\Generators\ClpPbeParametersGenerator.pas',
-  ClpPemObjects in '..\..\CryptoLib\src\Pem\ClpPemObjects.pas',
+  ClpPemHeader in '..\..\CryptoLib\src\Pem\ClpPemHeader.pas',
+  ClpPemObject in '..\..\CryptoLib\src\Pem\ClpPemObject.pas',
   ClpPkcs1Encoding in '..\..\CryptoLib\src\Crypto\Encodings\ClpPkcs1Encoding.pas',
   ClpPkcs5S2ParametersGenerator in '..\..\CryptoLib\src\Crypto\Generators\ClpPkcs5S2ParametersGenerator.pas',
   ClpPkcsAsn1Objects in '..\..\CryptoLib\src\Asn1\Pkcs\ClpPkcsAsn1Objects.pas',

+ 1 - 1
CryptoLib.Tests/FreePascal.Tests/CryptoLib.lpr

@@ -21,7 +21,7 @@ uses
   ScryptTests, DigestTests, CertTests, Curve25519KeyUtilitiesTests,
   DigestUtilitiesTests, DHTests, Asn1IntegerTests, BitStringTests,
   GeneralizedTimeTests, OctetStringTests, RelativeOidTests, UtcTimeTests,
-  InputStreamTests, SetTests, X9Tests, PrivateKeyInfoTests,
+  InputStreamTests, SetTests, X9Tests, PrivateKeyInfoTests, DerUtf8StringTests,
   Pkcs10CertRequestTests, DeltaCertificateTests, CertificateTests, X509AltTests,
   X509ExtensionsTests, X509NameTests, SubjectKeyIdentifierTests, KeyUsageTests,
   GeneralNameTests, KMacTests, RSATests, PssTests, ISO9796Tests,

+ 7 - 7
CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpr

@@ -21,13 +21,13 @@ uses
   ScryptTests, DigestTests, CertTests, DigestUtilitiesTests, DHTests,
   Asn1IntegerTests, GeneralizedTimeTests, BitStringTests, InputStreamTests,
   UtcTimeTests, RelativeOidTests, OctetStringTests, SetTests, X9Tests,
-  PrivateKeyInfoTests, Pkcs10CertRequestTests, DeltaCertificateTests,
-  CertificateTests, X509AltTests, X509ExtensionsTests, X509NameTests,
-  SubjectKeyIdentifierTests, KeyUsageTests, GeneralNameTests, KMacTests,
-  PssTests, ISO9796Tests, RSABlindedTests, RSADigestSignerTests, RSATests,
-  X931SignerTests, CryptoLibTestBase, OpenSslReaderTests, OpenSslWriterTests,
-  X509CertGenTests, ClpFixedSecureRandom, ClpShortenedDigest,
-  IPAddressUtilitiesTests, PemReaderTests;
+  PrivateKeyInfoTests, DerUtf8StringTests, Pkcs10CertRequestTests,
+  DeltaCertificateTests, CertificateTests, X509AltTests, X509ExtensionsTests,
+  X509NameTests, SubjectKeyIdentifierTests, KeyUsageTests, GeneralNameTests,
+  KMacTests, PssTests, ISO9796Tests, RSABlindedTests, RSADigestSignerTests,
+  RSATests, X931SignerTests, CryptoLibTestBase, OpenSslReaderTests,
+  OpenSslWriterTests, X509CertGenTests, ClpFixedSecureRandom,
+  ClpShortenedDigest, IPAddressUtilitiesTests, PemReaderTests;
 
 type
 

+ 4 - 2
CryptoLib.Tests/src/Asn1/X509/DeltaCertificateTests.pas

@@ -39,8 +39,10 @@ uses
   ClpX509Certificate,
   ClpIX509Certificate,
   ClpDeltaCertificateTool,
-  ClpPemObjects,
-  ClpIPemObjects,
+  ClpPemHeader,
+  ClpPemObject,
+  ClpIPemHeader,
+  ClpIPemObject,
   ClpIPemReader,
   ClpPemReader,
   ClpArrayUtilities,

+ 4 - 2
CryptoLib.Tests/src/OpenSsl/OpenSslReaderTests.pas

@@ -33,8 +33,10 @@ uses
 {$ELSE}
   TestFramework,
 {$ENDIF FPC}
-  ClpPemObjects,
-  ClpIPemObjects,
+  ClpPemHeader,
+  ClpPemObject,
+  ClpIPemHeader,
+  ClpIPemObject,
   ClpIPemWriter,
   ClpPemWriter,
   ClpIOpenSslPemWriter,

+ 4 - 2
CryptoLib.Tests/src/OpenSsl/OpenSslWriterTests.pas

@@ -33,8 +33,10 @@ uses
 {$ELSE}
   TestFramework,
 {$ENDIF FPC}
-  ClpPemObjects,
-  ClpIPemObjects,
+  ClpPemHeader,
+  ClpPemObject,
+  ClpIPemHeader,
+  ClpIPemObject,
   ClpIPemWriter,
   ClpPemWriter,
   ClpIOpenSslPemWriter,

+ 4 - 2
CryptoLib.Tests/src/Utils/Pem/PemReaderTests.pas

@@ -32,8 +32,10 @@ uses
 {$ELSE}
   TestFramework,
 {$ENDIF FPC}
-  ClpPemObjects,
-  ClpIPemObjects,
+  ClpPemHeader,
+  ClpPemObject,
+  ClpIPemHeader,
+  ClpIPemObject,
   ClpIPemReader,
   ClpPemReader,
   ClpIPemWriter,

+ 59 - 0
CryptoLib/src/Interfaces/Pem/ClpIPemHeader.pas

@@ -0,0 +1,59 @@
+{ *********************************************************************************** }
+{ *                              CryptoLib Library                                  * }
+{ *                Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe                    * }
+{ *                 Github Repository <https://github.com/Xor-el>                   * }
+
+{ *  Distributed under the MIT software license, see the accompanying file LICENSE  * }
+{ *          or visit http://www.opensource.org/licenses/mit-license.php.           * }
+
+{ *                              Acknowledgements:                                  * }
+{ *                                                                                 * }
+{ *      Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring     * }
+{ *                           development of this library                           * }
+
+{ * ******************************************************************************* * }
+
+(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
+
+unit ClpIPemHeader;
+
+{$I ..\..\Include\CryptoLib.inc}
+
+interface
+
+type
+  /// <summary>
+  /// Interface for PEM header objects.
+  /// </summary>
+  IPemHeader = interface(IInterface)
+    ['{ED7A5DF3-5307-427B-8B47-63820438FEF1}']
+
+    function GetName: String;
+    function GetValue: String;
+
+    /// <summary>
+    /// Get the header name.
+    /// </summary>
+    property Name: String read GetName;
+    /// <summary>
+    /// Get the header value.
+    /// </summary>
+    property Value: String read GetValue;
+
+    /// <summary>
+    /// Get hash code for this header.
+    /// </summary>
+    function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI}
+    /// <summary>
+    /// Check if this header equals another object.
+    /// </summary>
+    function Equals(const AObj: IPemHeader): Boolean;
+    /// <summary>
+    /// Get string representation of this header.
+    /// </summary>
+    function ToString(): String;
+  end;
+
+implementation
+
+end.

+ 2 - 36
CryptoLib/src/Interfaces/Pem/ClpIPemObjects.pas → CryptoLib/src/Interfaces/Pem/ClpIPemObject.pas

@@ -15,53 +15,20 @@
 
 (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
 
-unit ClpIPemObjects;
+unit ClpIPemObject;
 
 {$I ..\..\Include\CryptoLib.inc}
 
 interface
 
 uses
-  Classes,
+  ClpIPemHeader,
   ClpCryptoLibTypes;
 
 type
-  IPemHeader = interface;
   IPemObject = interface;
   IPemObjectGenerator = interface;
 
-  /// <summary>
-  /// Interface for PEM header objects.
-  /// </summary>
-  IPemHeader = interface(IInterface)
-    ['{ED7A5DF3-5307-427B-8B47-63820438FEF1}']
-
-    function GetName: String;
-    function GetValue: String;
-
-    /// <summary>
-    /// Get the header name.
-    /// </summary>
-    property Name: String read GetName;
-    /// <summary>
-    /// Get the header value.
-    /// </summary>
-    property Value: String read GetValue;
-
-    /// <summary>
-    /// Get hash code for this header.
-    /// </summary>
-    function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI}
-    /// <summary>
-    /// Check if this header equals another object.
-    /// </summary>
-    function Equals(const AObj: IPemHeader): Boolean;
-    /// <summary>
-    /// Get string representation of this header.
-    /// </summary>
-    function ToString(): String;
-  end;
-
   /// <summary>
   /// Interface for PEM object generator.
   /// </summary>
@@ -102,4 +69,3 @@ type
 implementation
 
 end.
-

+ 1 - 1
CryptoLib/src/Interfaces/Pem/ClpIPemReader.pas

@@ -23,7 +23,7 @@ interface
 
 uses
   Classes,
-  ClpIPemObjects;
+  ClpIPemObject;
 
 type
   /// <summary>

+ 1 - 1
CryptoLib/src/Interfaces/Pem/ClpIPemWriter.pas

@@ -23,7 +23,7 @@ interface
 
 uses
   Classes,
-  ClpIPemObjects;
+  ClpIPemObject;
 
 type
   /// <summary>

+ 2 - 2
CryptoLib/src/OpenSsl/ClpOpenSslMiscPemGenerator.pas

@@ -24,8 +24,8 @@ interface
 uses
   SysUtils,
   Rtti,
-  ClpIPemObjects,
-  ClpPemObjects,
+  ClpIPemObject,
+  ClpPemObject,
   ClpIAsymmetricKeyParameter,
   ClpPrivateKeyInfoFactory,
   ClpSubjectPublicKeyInfoFactory,

+ 2 - 1
CryptoLib/src/OpenSsl/ClpOpenSslPemReader.pas

@@ -26,7 +26,8 @@ uses
   Classes,
   Generics.Collections,
   Rtti,
-  ClpIPemObjects,
+  ClpIPemHeader,
+  ClpIPemObject,
   ClpPemReader,
   ClpIOpenSslPemReader,
   ClpIAsymmetricKeyParameter,

+ 1 - 1
CryptoLib/src/OpenSsl/ClpOpenSslPemWriter.pas

@@ -26,7 +26,7 @@ uses
   Rtti,
   SysUtils,
   ClpIOpenSslPemWriter,
-  ClpIPemObjects,
+  ClpIPemObject,
   ClpPemWriter,
   ClpOpenSslMiscPemGenerator,
   ClpCryptoLibTypes;

+ 13 - 5
CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk

@@ -25,7 +25,7 @@
  Acknowledgements: 
 Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the development of this library "/>
     <Version Major="3" Minor="3"/>
-    <Files Count="489">
+    <Files Count="491">
       <Item1>
         <Filename Value="..\..\Asn1\ClpOidTokenizer.pas"/>
         <UnitName Value="ClpOidTokenizer"/>
@@ -1364,8 +1364,8 @@ Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the devel
         <UnitName Value="ClpICryptoApiRandomGenerator"/>
       </Item334>
       <Item335>
-        <Filename Value="..\..\Interfaces\Pem\ClpIPemObjects.pas"/>
-        <UnitName Value="ClpIPemObjects"/>
+        <Filename Value="..\..\Interfaces\Pem\ClpIPemHeader.pas"/>
+        <UnitName Value="ClpIPemHeader"/>
       </Item335>
       <Item336>
         <Filename Value="..\..\Interfaces\Crypto\Signers\SignerCalculators\ClpIHMacDsaKCalculator.pas"/>
@@ -1780,8 +1780,8 @@ Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the devel
         <UnitName Value="ClpIPAddressUtilities"/>
       </Item438>
       <Item439>
-        <Filename Value="..\..\Pem\ClpPemObjects.pas"/>
-        <UnitName Value="ClpPemObjects"/>
+        <Filename Value="..\..\Pem\ClpPemHeader.pas"/>
+        <UnitName Value="ClpPemHeader"/>
       </Item439>
       <Item440>
         <Filename Value="..\..\Pkcs\ClpPkcs10CertificationRequest.pas"/>
@@ -1983,6 +1983,14 @@ Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the devel
         <Filename Value="..\..\Interfaces\Pkcs\ClpIPkcs10CertificationRequestBuilder.pas"/>
         <UnitName Value="ClpIPkcs10CertificationRequestBuilder"/>
       </Item489>
+      <Item490>
+        <Filename Value="..\..\Interfaces\Pem\ClpIPemObject.pas"/>
+        <UnitName Value="ClpIPemObject"/>
+      </Item490>
+      <Item491>
+        <Filename Value="..\..\Pem\ClpPemObject.pas"/>
+        <UnitName Value="ClpPemObject"/>
+      </Item491>
     </Files>
     <CompatibilityMode Value="True"/>
     <RequiredPkgs Count="3">

+ 3 - 3
CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.pas

@@ -114,7 +114,7 @@ uses
   ClpIDsaKCalculator, ClpIDsaSigner, ClpISigner, ClpIECNRSigner, ClpIRandom, 
   ClpISecureRandom, ClpIRandomNumberGenerator, ClpIRandomSourceProvider, 
   ClpIX509CertificateParser, ClpIRandomGenerator, ClpIDigestRandomGenerator, 
-  ClpICryptoApiRandomGenerator, ClpIPemObjects, ClpIHMacDsaKCalculator, 
+  ClpICryptoApiRandomGenerator, ClpIPemHeader, ClpIHMacDsaKCalculator, 
   ClpIRsaDigestSigner, ClpIRsa, ClpIPssSigner, ClpIGenericSigner, 
   ClpIEd25519Signer, ClpIEd25519PhSigner, ClpIEd25519CtxSigner, 
   ClpIDsaDigestSigner, ClpIParametersWithIV, ClpIKeyParameter, 
@@ -144,7 +144,7 @@ uses
   ClpScalarUtilities, ClpScalar25519, ClpBits, ClpCodec, ClpBinaryPrimitives, 
   ClpBitConverter, ClpBitOperations, ClpConverters, ClpCryptoLibComparers, 
   ClpCryptoLibTypes, ClpNullable, ClpPack, ClpWeakRef, ClpIPAddressUtilities, 
-  ClpPemObjects, ClpPkcs10CertificationRequest, ClpDigestRandomGenerator, 
+  ClpPemHeader, ClpPkcs10CertificationRequest, ClpDigestRandomGenerator, 
   ClpRandomNumberGenerator, ClpAppleRandomProvider, 
   ClpGenericBSDRandomProvider, ClpLinuxRandomProvider, 
   ClpWindowsRandomProvider, ClpUnixRandomProvider, ClpSolarisRandomProvider, 
@@ -161,7 +161,7 @@ uses
   ClpOpenSslPemWriter, ClpIOpenSslPemReader, ClpIOpenSslPemWriter, 
   ClpPkcsDHAsn1Objects, ClpIPkcsDHAsn1Objects, ClpIPemParser, ClpIPemReader, 
   ClpIPemWriter, ClpPemParser, ClpPemReader, ClpPemWriter, 
-  ClpIPkcs10CertificationRequestBuilder;
+  ClpIPkcs10CertificationRequestBuilder, ClpIPemObject, ClpPemObject;
 
 implementation
 

+ 109 - 0
CryptoLib/src/Pem/ClpPemHeader.pas

@@ -0,0 +1,109 @@
+{ *********************************************************************************** }
+{ *                              CryptoLib Library                                  * }
+{ *                Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe                    * }
+{ *                 Github Repository <https://github.com/Xor-el>                   * }
+
+{ *  Distributed under the MIT software license, see the accompanying file LICENSE  * }
+{ *          or visit http://www.opensource.org/licenses/mit-license.php.           * }
+
+{ *                              Acknowledgements:                                  * }
+{ *                                                                                 * }
+{ *      Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring     * }
+{ *                           development of this library                           * }
+
+{ * ******************************************************************************* * }
+
+(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
+
+unit ClpPemHeader;
+
+{$I ..\Include\CryptoLib.inc}
+
+interface
+
+uses
+  ClpIPemHeader,
+  ClpCryptoLibTypes,
+  ClpStringUtilities;
+
+type
+  /// <summary>
+  /// PEM header implementation.
+  /// </summary>
+  TPemHeader = class sealed(TInterfacedObject, IPemHeader)
+  strict private
+    FName: String;
+    FValue: String;
+
+    function GetName: String;
+    function GetValue: String;
+    function GetHashCodeInternal(const AStr: String): Int32;
+
+  public
+    constructor Create(const AName, AValue: String);
+
+    function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI} override;
+    function Equals(const AObj: IPemHeader): Boolean; reintroduce;
+    function ToString(): String; override;
+
+    property Name: String read GetName;
+    property Value: String read GetValue;
+  end;
+
+implementation
+
+{ TPemHeader }
+
+constructor TPemHeader.Create(const AName, AValue: String);
+begin
+  Inherited Create();
+  FName := AName;
+  FValue := AValue;
+end;
+
+function TPemHeader.GetName: String;
+begin
+  Result := FName;
+end;
+
+function TPemHeader.GetValue: String;
+begin
+  Result := FValue;
+end;
+
+function TPemHeader.GetHashCodeInternal(const AStr: String): Int32;
+begin
+  if AStr = '' then
+    Result := 1
+  else
+    Result := TStringUtilities.GetStringHashCode(AStr);
+end;
+
+function TPemHeader.GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI}
+begin
+  Result := GetHashCodeInternal(FName) + 31 * GetHashCodeInternal(FValue);
+end;
+
+function TPemHeader.Equals(const AObj: IPemHeader): Boolean;
+begin
+  if AObj = Self as IPemHeader then
+  begin
+    Result := True;
+    Exit;
+  end;
+
+  if AObj = nil then
+  begin
+    Result := False;
+    Exit;
+  end;
+
+  Result := (FName = AObj.Name) and (FValue = AObj.Value);
+end;
+
+function TPemHeader.ToString(): String;
+begin
+  Result := FName + ':' + FValue;
+end;
+
+end.

+ 4 - 85
CryptoLib/src/Pem/ClpPemObjects.pas → CryptoLib/src/Pem/ClpPemObject.pas

@@ -15,45 +15,18 @@
 
 (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
 
-unit ClpPemObjects;
+unit ClpPemObject;
 
 {$I ..\Include\CryptoLib.inc}
 
 interface
 
 uses
-  SysUtils,
-  Classes,
-  ClpAsn1Core,
-  ClpIPemObjects,
-  ClpCryptoLibTypes,
-  ClpStringUtilities,
-  ClpAsn1Objects;
+  ClpIPemHeader,
+  ClpIPemObject,
+  ClpCryptoLibTypes;
 
 type
-  /// <summary>
-  /// PEM header implementation.
-  /// </summary>
-  TPemHeader = class sealed(TInterfacedObject, IPemHeader)
-  strict private
-    FName: String;
-    FValue: String;
-
-    function GetName: String;
-    function GetValue: String;
-    function GetHashCodeInternal(const AStr: String): Int32;
-
-  public
-    constructor Create(const AName, AValue: String);
-
-    function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI} override;
-    function Equals(const AObj: IPemHeader): Boolean; reintroduce;
-    function ToString(): String; override;
-
-    property Name: String read GetName;
-    property Value: String read GetValue;
-  end;
-
   /// <summary>
   /// PEM object implementation.
   /// </summary>
@@ -82,60 +55,6 @@ type
 
 implementation
 
-{ TPemHeader }
-
-constructor TPemHeader.Create(const AName, AValue: String);
-begin
-  Inherited Create();
-  FName := AName;
-  FValue := AValue;
-end;
-
-function TPemHeader.GetName: String;
-begin
-  Result := FName;
-end;
-
-function TPemHeader.GetValue: String;
-begin
-  Result := FValue;
-end;
-
-function TPemHeader.GetHashCodeInternal(const AStr: String): Int32;
-begin
-  if AStr = '' then
-    Result := 1
-  else
-    Result := TStringUtilities.GetStringHashCode(AStr);
-end;
-
-function TPemHeader.GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI}
-begin
-  Result := GetHashCodeInternal(FName) + 31 * GetHashCodeInternal(FValue);
-end;
-
-function TPemHeader.Equals(const AObj: IPemHeader): Boolean;
-begin
-  if AObj = Self as IPemHeader then
-  begin
-    Result := True;
-    Exit;
-  end;
-
-  if AObj = nil then
-  begin
-    Result := False;
-    Exit;
-  end;
-
-  Result := (FName = AObj.Name) and (FValue = AObj.Value);
-end;
-
-function TPemHeader.ToString(): String;
-begin
-  Result := FName + ':' + FValue;
-end;
-
 { TPemObject }
 
 constructor TPemObject.Create(const AType: String; const AContent: TCryptoLibByteArray);

+ 4 - 2
CryptoLib/src/Pem/ClpPemReader.pas

@@ -26,8 +26,10 @@ uses
   Classes,
   Generics.Collections,
   ClpIPemReader,
-  ClpIPemObjects,
-  ClpPemObjects,
+  ClpIPemHeader,
+  ClpIPemObject,
+  ClpPemHeader,
+  ClpPemObject,
   ClpCryptoLibTypes,
   ClpEncoders,
   ClpStringUtilities,

+ 2 - 1
CryptoLib/src/Pem/ClpPemWriter.pas

@@ -25,7 +25,8 @@ uses
   SysUtils,
   Classes,
   ClpIPemWriter,
-  ClpIPemObjects,
+  ClpIPemHeader,
+  ClpIPemObject,
   ClpCryptoLibTypes,
   ClpEncoders,
   ClpConverters;