EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Signing failed (secret key mismatch/passphrase not provided?)

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
Posted: 02/11/2013 02:09:21
by Andy Kim (Basic support level)
Joined: 02/07/2013
Posts: 11

Hi keep getting this error? I dont know why? I am adding a passphrase.

MyBase.Stage = "Set up PGP Writer Object"
        Dim pubKeyring As New SBPGPKeys.TElPGPKeyring
        Dim secKeyring As New SBPGPKeys.TElPGPKeyring
        Dim inF, outF As System.IO.FileStream
        Dim blnAsciiArmor As Boolean = True
        Dim strArmorHeader As String = "Version: GnuPG v2.0.17 (MingW32)"
        Dim strArmorBoundary As String = "PGP MESSAGE BLOCK"
        Dim blnCompress As Boolean = False
        Dim intSymmetricKeyAlorithm As Integer = 2
        Dim intProtectionLevel As Integer = 1
        Dim blnSign As Boolean = 0

        Stage = "Assign the keyrings to the pgp writer"
        mPgpWriter.EncryptingKeys = pubKeyring

        If blnSign Then
            mPgpWriter.SigningKeys = secKeyring
        End If

        Stage = "Set the Encryption type"
        If Trim(passphrase) <> "" Then
            mPgpWriter.EncryptionType = SBPGP.TSBPGPEncryptionType.etBoth
            '*** Add passphrase
            Stage = "Add passphrase"
            '*** Use public key
            Stage = "Use public key"
            mPgpWriter.EncryptionType = SBPGP.TSBPGPEncryptionType.etPublicKey
            '*** No pass phrase
        End If

        mPgpWriter.Armor = blnAsciiArmor
        mPgpWriter.ArmorBoundary = strArmorBoundary
        mPgpWriter.Compress = blnCompress
        mPgpWriter.Timestamp = RunDateTime
        mPgpWriter.InputIsText = True
        mPgpWriter.UseNewFeatures = True
        mPgpWriter.UseOldPackets = False
        mPgpWriter.TextCompatibilityMode = True

        Select Case (intProtectionLevel)
            Case 0
                mPgpWriter.Protection = SBPGPConstants.TSBPGPProtectionType.ptLow
            Case 1
                mPgpWriter.Protection = SBPGPConstants.TSBPGPProtectionType.ptNormal
            Case Else
                mPgpWriter.Protection = SBPGPConstants.TSBPGPProtectionType.ptHigh
        End Select

        mPgpWriter.SignBufferingMethod = SBPGP.TSBPGPSignBufferingMethod.sbmRewind

        Select Case (intSymmetricKeyAlorithm)
            Case 0
                mPgpWriter.SymmetricKeyAlgorithm = SBPGPConstants.Unit.SB_PGP_ALGORITHM_SK_CAST5
            Case 1
                mPgpWriter.SymmetricKeyAlgorithm = SBPGPConstants.Unit.SB_PGP_ALGORITHM_SK_3DES
            Case 2
                mPgpWriter.SymmetricKeyAlgorithm = SBPGPConstants.Unit.SB_PGP_ALGORITHM_SK_AES128
            Case Else
                mPgpWriter.SymmetricKeyAlgorithm = SBPGPConstants.Unit.SB_PGP_ALGORITHM_SK_AES256
        End Select

        '*** Sign each file
        Stage = "Sign each file"
        For intF As Int16 = 0 To strFileList.Length - 1
            Dim strProcessFileName As String = strFileList(intF)
            Dim blnEncrypt As Boolean = True
            Dim blnInputIsText As Boolean = True
            Dim strOutputFileName As String = FileName(strFileList(intF) & strPgpFileExtension)

            inF = New System.IO.FileStream(strProcessFileName, IO.FileMode.Open)
            outF = New System.IO.FileStream("C:\OUTPUT.txt.asc", _

                mPgpWriter.Filename = "C:\OUTPUT.txt.asc"
                mPgpWriter.EncryptAndSign(inF, outF, 0)
            End Try

Sorry code in under construction
Posted: 02/11/2013 02:11:36
by Andy Kim (Basic support level)
Joined: 02/07/2013
Posts: 11

I get the error when I call the encryptandSign part.
Posted: 02/11/2013 02:14:12
by Vsevolod Ievgiienko (EldoS Corp.)

Thank you for contacting us.

You should provide a password for a secret key using TElPGPWriter.OnKeyPassphrase event handler.
Posted: 02/11/2013 02:16:03
by Eugene Mayevski (EldoS Corp.)

Alternatively each private key object (TElPGPSecretKey) has Passphrase property.

On a side note, please mark your code with the corresponding tag or button. I'll do this manually for your post now.

Sincerely yours
Eugene Mayevski
Posted: 02/11/2013 02:35:17
by Andy Kim (Basic support level)
Joined: 02/07/2013
Posts: 11

Thanks! I got it to work.
Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.



Topic viewed 1677 times

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


Back to top

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

Got it!