내 .NET 응용 프로그램에서 RSACryptoServiceProvider.ExportCspBlob
을 사용하는 인증서에서 내 보낸 CPS BLOB가 있습니다. .NET에서 Python으로 내 보낸 CSP blob 가져 오기 pyCrypto
return Convert.ToBase64String(rsaAlg.ExportCspBlob(false /*includePrivateParameters*/));
는 지금, 나는 파이썬 응용 프로그램에서 그 덩어리를 가져와야합니다. pyCrypto를 사용해 보았지만 운이 없었습니다.
# that's the value I'm getting from .NET code above
key = 'BgIAAAAkAABSU0ExAAgAAAEAAQARMnLlzOgHkmHssf6ZSFJn8TlTiOBSoRSEnkI4U0UI6n1jFY2bTWS9O5uApMNXz1vr5OyxoXsNVF2XrNM4DOC+lRn3R/H+mZZxZY1F8oXxhe4L5AFOMhyykPreQtu9z+oKOzVB80zR+EU+nc/290POVK9/LGzP94cTk0VHSZdXDgL1eOiXLSg8h1OnJmMGxY6HyNvbF90onoHMWNrIeRue1vP/S5QLwuzkHv6tgm54bSwXWXFdDRbjtrA9HJkbf74hflAIqivO34bx+53whl2fEsC51eXqFdCr7XJJw+bwlENwDF9bUtCXQ+jXbiYtzvMbntRCKZ8LPRqlN9OWrBC2';
from Crypto.PublicKey import RSA
from Crypto.Util import asn1
from base64 import b64decode
# let's decrypt base64 first
keyDER = b64decode(key)
seq = asn1.DerSequence()
seq.decode(keyDER)
keyPub = RSA.importKey(keyDER)
나는
Traceback (most recent call last): File "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensio ns\Microsoft\Python Tools for Visual Studio\2.1\visualstudio_py_util.py", line 1 06, in exec_file exec_code(code, file, global_variables) File "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensio ns\Microsoft\Python Tools for Visual Studio\2.1\visualstudio_py_util.py", line 8 2, in exec_code exec(code_obj, global_variables) File "c:\users\marcinj\documents\visual studio 2013\Projects\PythonApplication 1\PythonApplication1\PythonApplication1.py", line 12, in seq.decode(keyDER) File "C:\Python27\lib\site-packages\Crypto\Util\asn1.py", line 237, in decode raise ValueError("Not a DER SEQUENCE.") ValueError: Not a DER SEQUENCE.