EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Public Key Material Missing

Posted: 07/09/2015 11:16:34
by Charlie Jimenez (Standard support level)
Joined: 08/14/2012
Posts: 38

Using the CertDemoWithGenerator application (vb.net) with a PFX formatted certificate file, I can see the public key info in the display after loading it to a memory storage.

I then import this certificate into the Windows(7) "MY" store using the windows Internet Options facility. I check the box "Mark Private Key as Exportable". It imports correctly, and afterwards reports that "You have a private key that corresponds to this certificate". It will also display the public key info correctly (EC - 521 bits).

Now, if I reopen the Demo application, the certificate will appear in the "MY" Windows certificate store. If I click on it I get a NullReferenceException in the LoadCertificateInfo sub:

        ElseIf cert.PublicKeyAlgorithm = SBConstants.Unit.SB_CERT_ALGORITHM_EC Then

            len1 = 4096
            Dim PubKey(len1 - 1) As Byte

            cert.KeyMaterial.SavePublic(PubKey, 0, len1)  <-- at this point
            SBUtils.Unit.SetLength(PubKey, len1)

because cert.KeyMaterial is Nothing.

What could be the problem?
Posted: 07/09/2015 12:40:53
by Ken Ivanov (Team)

Hi Charlie,

Thank you for getting in touch with us.

Support for Elliptic Curve keys has only been recently added to TElWinCertStorage component and certificates originating from it. Specifically, partial support for EC keys was added to version 12.0.267. It was further extended in version 13 branch.

So, if you are using version 12, please upgrade to its latest build (269) and check if it resolves the issue. Otherwise you would probably need to upgrade to version 13.

Posted: 07/10/2015 10:16:55
by Charlie Jimenez (Standard support level)
Joined: 08/14/2012
Posts: 38

I updated to the latest release (272) and it did not help. How do I go about upgrading to version 13?


Posted: 07/10/2015 12:15:49
by Charlie Jimenez (Standard support level)
Joined: 08/14/2012
Posts: 38

I ran into an issue with build 272 that I thought you might like to know. I get an exception "Object reference not set to an instance of an object" when I execute the following:

    stor = New SBCustomCertStorage.TElMemoryCertStorage
    Using ios As New FileStream(sFileName, FileMode.Open)
       Ret = stor.LoadFromStreamPFX(ios, pwd, CInt(ios.Length))  '<--Exception occurs here
    End Using

Executing this exact same code using build 260 is successful.

I am sorry but I had to revert back to build 260 to continue with my project, so I cannot provide any additional information. But I do remember that the exception occurred deep inside your code in a method named "LoadSecret" or something similar. Of course, the password was set correctly and is evidenced by it working correctly with build 260

Thanks for your continued support.

Posted: 07/13/2015 04:49:50
by Vsevolod Ievgiienko (Team)


I was not able to reproduce the exception in both 12th and 13th versions of SecureBlackbox. Could you please post input file with the test project to the Helpdesk if its possible? Most likelly the problem is file dependent.
Posted: 07/15/2015 14:31:06
by Charlie Jimenez (Standard support level)
Joined: 08/14/2012
Posts: 38

Just FYI - The Public Key Material missing issue is not present in SBB


Posted: 07/15/2015 14:50:07
by Charlie Jimenez (Standard support level)
Joined: 08/14/2012
Posts: 38

I just reproduced the exception in version 13.0.276. I will post the file to the help desk as requested. The exception detail is:

System.NullReferenceException was caught
Message=Object reference not set to an instance of an object.
at SBCryptoProvBuiltInPKI.TElBuiltInECCryptoKey.ImportSecret(Byte[] Buffer, Int32 StartIndex, Int32 Size, TElCPParameters Params)
at SBPublicKeyCrypto.TElECKeyMaterial.LoadSecret(Byte[] Buffer, Int32 Index, Int32 Size)
at SBPKCS12.TElPKCS12Message.KeyCorresponds(TElX509Certificate Certificate, Byte[] KeyBuffer)
at SBPKCS12.TElPKCS12Message.LoadFromBuffer(Byte[] Buffer)
at SBCustomCertStorage.TElCustomCertStorage.LoadFromBufferPFX(Byte[] Buffer, String Password)
at SBCustomCertStorage.TElCustomCertStorage.LoadFromStreamPFX(Stream Stream, String Password, Int32 Count)
at UPOSHost.modStartUp.MyApplicationContext..ctor() in C:\Users\Charlie\Documents\Visual Studio 2013\Projects\Universal POS Host Emulator\modStartUp.vb:line 282

The file is a PFX file I just created using the same version 13 components.
Posted: 07/15/2015 15:01:47
by Charlie Jimenez (Standard support level)
Joined: 08/14/2012
Posts: 38

I just posted the file to the Help Desk. One thing I failed to mention and which may be relevant, is that the PFX file I am trying to load contains more than one certificate.





Topic viewed 2308 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!