EldoS | Feel safer!

Software components for data protection, secure storage and transfer

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

Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.
#23387
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.

Code
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"
            mPgpWriter.Passphrases.Clear()
            mPgpWriter.Passphrases.Add(KeyPassPhrase)
        Else
            '*** Use public key
            Stage = "Use public key"
            mPgpWriter.EncryptionType = SBPGP.TSBPGPEncryptionType.etPublicKey
            '*** No pass phrase
            mPgpWriter.Passphrases.Clear()
        End If

        mPgpWriter.Armor = blnAsciiArmor
        mPgpWriter.ArmorHeaders.Clear()
        mPgpWriter.ArmorHeaders.Add(strArmorHeader)
        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", _
                                           System.IO.FileMode.Create)


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


Sorry code in under construction
#23388
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.
#23389
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.
#23390
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
#23391
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: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.

Reply

Statistics

Topic viewed 1596 times

none




|

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!