EldoS
Navigation
Web site
Support
Table Of Contents

Filter: C#  VB.NET  Pascal  ActiveX  DLL 


TElCustomCertStorage.SaveToBufferPFX

CustomCertStorage     See also    


 

Use this method in derived classes to save certificates contained in storage to buffer in PFX (PKCS12) format.

 
 

Declaration

[C#]
    int SaveToBufferPFX(ref byte[] Buffer, ref int Size, string Password, int KeyEncryptionAlgorithm, int CertEncryptionAlgorithm);
    int SaveToBufferPFX(ref byte[] Buffer, int StartIndex, int Size, string Password);

[VB.NET]
    Function SaveToBufferPFX(ByRef Buffer As Byte(), ByRef Size As Integer, ByVal Password As String, ByVal KeyEncryptionAlgorithm As Integer, ByVal CertEncryptionAlgorithm As Integer) As Integer
    Function SaveToBufferPFX(ByRef Buffer As Byte(), ByVal StartIndex As Integer, ByRef Size As Integer, ByVal Password As String) As Integer

[Pascal]
    function SaveToBufferPFX(Buffer : pointer; var Size : integer; Password : string; KeyEncryptionAlgorithm : integer; CertEncryptionAlgorithm : integer) : integer;
    function SaveToBufferPFX(Buffer : pointer; var Size : integer; Password : string) : integer;

[VB6]
    Sub IElCustomCertStorageX3.SaveToBufferPFX(Password As String, KeyEncryptionAlgorithm As TxSBPBEAlgorithm, CertEncryptionAlgorithm As TxSBPBEAlgorithm, Buffer As Byte())

[ActiveX]
    HRESULT _stdcall IElCustomCertStorageX3.SaveToBufferPFX([in] BSTR Password, [in] TxSBPBEAlgorithm KeyEncryptionAlgorithm, [in] TxSBPBEAlgorithm CertEncryptionAlgorithm, [out] VARIANT * Buffer );

[DLL]
    not applicable;
 
 

Parameters

  • Buffer - Buffer with PKCS12 data
  • StartIndex - Index of the first byte in the Buffer from which to start saving.
  • Size - Size of Buffer in bytes
  • Password - Password to encrypt certificates
  • KeyEncryptionAlgorithm - Password-based (PBE) algorithm which should be used to encrypt private keys. If this parameter is omitted, the default algorithm is SB_ALGORITHM_PBE_SHA1_3DES.
  • CertEncryptionAlgorithm - Password-based (PBE) algorithm which should be used to encrypt certificates. If this parameter is omitted, the default algorithm is SB_ALGORITHM_PBE_SHA1_RC2_40.
 

Values:

Definition Value
SB_ALGORITHM_PBE_SHA1_RC4_128 0x7201
SB_ALGORITHM_PBE_SHA1_RC4_40 0x7202
SB_ALGORITHM_PBE_SHA1_3DES 0x7203
SB_ALGORITHM_PBE_SHA1_RC2_128 0x7204
SB_ALGORITHM_PBE_SHA1_RC2_40 0x7205
Declared in
[.NET] [Pascal]
Namespace: SBConstants
Assembly: SecureBlackbox
Unit: SBConstants

Note: Windows CSPs don't understand RC4/128-bit algorithm and if the certificate is exported using these algorithm, you won't be able to import it with CryptoAPI.

 
 

Return value

    0 if certificates were successfully saved.
    PKCS12 error code otherwise.

 
 

PKCS12 Error codes

[.NET] [Pascal] [ActiveX] [DLL] Value Description
SB_PKCS12_ERROR_INVALID_ASN_DATA 793 (0x1F01) Buffer doesn't contain a valid PFX sequence
SB_PKCS12_ERROR_NO_DATA 7938 (0x1F02) The PFX message doesn't contain any certificate
SB_PKCS12_ERROR_INVALID_DATA 7939 (0x1F03) Some parameters of PFX message are invalid
SB_PKCS12_ERROR_INVALID_VERSION 7940 (0x1F04) PFX message version is invalid
SB_PKCS12_ERROR_INVALID_CONTENT 7941 (0x1F05) PFX message contains invalid content
SB_PKCS12_ERROR_INVALID_AUTHENTICATED_SAFE_DATA 7942 (0x1F06) AuthenticatedSafe part of PFX message is invalid
SB_PKCS12_ERROR_INVALID_MAC_DATA 7943 (0x1F07) MAC part of PFX message PFX message is invalid
SB_PKCS12_ERROR_INVALID_SAFE_CONTENTS 7944 (0x1F08) The entity located in PFX message has invalid content type.
SB_PKCS12_ERROR_INVALID_SAFE_BAG 7945 (0x1F09) The entity located in PFX message has invalid format
SB_PKCS12_ERROR_INVALID_SHROUDED_KEY_BAG 7946 (0x1F0A) The private key contained in PFX message has invalid format
SB_PKCS12_ERROR_UNKNOWN_PBE_ALGORITHM 7947 (0x1F0B)
  • Saving: invalid PBE algorithm specified
  • Loading: unknown PBE algorithm was used to encrypt the message.
  • SB_PKCS12_ERROR_INTERNAL_ERROR 7948 (0x1F0C) Internal error occured. Please contact EldoS support for details.
    SB_PKCS12_ERROR_INVALID_PBE_ALGORITHM_PARAMS 7949 (0x1F0D) PBE algorithm params (iteration count and salt) are invalid
    SB_PKCS12_ERROR_INVALID_CERT_BAG 7950 (0x1F0E) The certificate contained in PFX message has invalid format
    SB_PKCS12_ERROR_UNSUPPORTED_CERTIFICATE_TYPE 7951 (0x1F0F) The certificate contained in PFX message has unsupported type
    SB_PKCS12_ERROR_INVALID_PRIVATE_KEY 7952 (0x1F10) The private key contained in PFX message has invalid format
    SB_PKCS12_ERROR_INVALID_MAC 7953 (0x1F11) MAC verification failed
    SB_PKCS12_ERROR_NO_CERTIFICATES 7954 (0x1F12) Saving: nothing to save
    SB_PKCS12_ERROR_INVALID_PASSWORD 7955 (0x1F13) Invalid password was specified. Can not decrypt certificate.
    SB_PKCS12_ERROR_BUFFER_TOO_SMALL 7956 (0x1F14) Buffer doesn't have enough space to store encoded certificate
    Declared in
    [.NET] [Pascal]
    Namespace: SBPKCS12
    Assembly: SecureBlackbox
    Unit: SBPKCS12

     
     

    Description

        Use this method in derived classes to save currently stored certificates in PFX format. PFX format supports storing of private keys.

     
     

    See also:     LoadFromBufferPFX LoadFromStreamPFX SaveToStreamPFX

     
    Contact Us | Terms of Use | Trademarks | Privacy Statement
    Copyright (c) 1998-2012, EldoS Corporation