Archived Forum Post

Index of archived forum posts

Question:

Email encryption and signing methods

Nov 03 '17 at 09:56

Hello,

i am testing the use of the ChilkatDotNet2.dll with Powershell, to receive encrypted and signed emails.

Some emails are encrypted / signed with OAEP / RSASSA-PSS.

I download them from our emailserver, they are decrypted by the code I use etc. Everythink is working fine.

I want to get information abaout the way of encryption / signing / padding of the original emails.

I allways get "SigningAlg: PKCS1-V1_5" and "SigningHashAlg: sha1", even if the emails are not encrypted and signed.

Here some codesnippets I use:

...

$bundle = $mailman.CopyMail()

...

$email = $bundle.GetEmail($i)

...

$("SigningAlg: " + $email.SigningAlg)

$("SigningHashAlg: " + $email.SigningHashAlg)

In the dokumentation i read this:

At this point, if the email was signed and/or encrypted, it is already "unwrapped", i.e. the email is already decrypted and in a state as if it were never signed or encrypted. You may check to see if the email was received encrypted or signed, and if so, whether it was successfully unwrapped and who signed or encrypted it:

Maybe I get the result because the email is already unwrapped. Is there a way to get information of the original email before it is unwrapped when copying it?

Regards

Frank


Answer

Hi,

yes, chilcat get allways "SigningAlg: PKCS1-V1_5" and "SigningHashAlg: sha1" You can found the real information at mailman.LastErrorText (see OID)

example: algId_oid = False

algID_sign = False

chkAlg = Split(mailman.LastErrorText, vbCrLf)

For Each Eintrag In chkAlg

If algId_oid Then If AlgCrypt <> "" Then AlgCrypt = AlgCrypt & " / " AlgCrypt = AlgCrypt & Trim(Eintrag) algId_oid = False End If

If Eintrag.Contains("encryptionAlgorithmOid:") Then AlgCrypt = Trim(Mid(Eintrag, InStr(Eintrag, ":") + 1)) End If

If Eintrag.Contains("algId_oid:") Then AlgCrypt = oid(AlgCrypt) & " / " & oid(Trim(Mid(Eintrag, InStr(Eintrag, ":") + 1))) algId_oid = True End If

If Eintrag.Contains("signerDigestAlgOid:") Then AlgSign = Trim(Mid(Eintrag, InStr(Eintrag, ":") + 1)) End If

If Eintrag.Contains("AlgorithmIdentifier:") Then algID_sign = True

If algID_sign And Eintrag.Contains("oid:") Then AlgSign = oid(AlgSign) & " / " & oid(Trim(Mid(Eintrag, InStr(Eintrag, ":") + 1))) algID_sign = False End If

If Eintrag.Contains("signerDigestAlgOid:") Then AlgSign = oid(AlgSign) & " / " & oid(Trim(Mid(Eintrag, InStr(Eintrag, ":") + 1))) End If

Next

Public Function oid(ByVal OIDNr As String) As String

    oid = OIDNr

    Select Case OIDNr
        Case "0.9.2342.19200300.100.1.25"
            oid = "domainComponent"
        Case "1.2.36.68980861.1.1.10"
            oid = "Signet pilot"
        Case "1.2.36.68980861.1.1.11"
            oid = "Signet intraNet"
        Case "1.2.36.68980861.1.1.2"
            oid = "Signet personal"
        Case "1.2.36.68980861.1.1.20"
            oid = "Signet securityPolicy"
        Case "1.2.36.68980861.1.1.3"
            oid = "Signet business"
        Case "1.2.36.68980861.1.1.4"
            oid = "Signet legal"

        ........

        Case "2.5.8.1"
            oid = "X.500-Alg-Encryption"
        Case "2.5.8.1.1"
            oid = "rsa"
        Case "2.5.8.2"
            oid = "DSALG_HASH" 'Digital signature algorithm applied to hashed content.
        Case "2.5.8.3"
            oid = "DSALG_SIGN" 'Digital signature algorithm applied to a signature.
    End Select

End Function

Answer

Thank you very much, this solves my problem