cryptography

PBKDF2WithHmacSHA256 impact of key length to the output length

懵懂的女人 提交于 2021-01-28 21:05:54
问题 Consider the following java code: KeySpec spec = new PBEKeySpec("pass".toCharArray(), "salt".getBytes(), 10000, 512); SecretKeyFactory f = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256"); System.out.println(f.generateSecret(spec).getEncoded().length); This code outputs " 64 ". So 64 bytes, while SHA-256 is a 32 byte hash. I know I specified 512 bits (64 byte) as the key length. However I would expect that the generated key (PBKDF2) will be hashed by SHA-256 so that the output should

TLS 1.2 - The token supplied to the function is invalid

≡放荡痞女 提交于 2021-01-28 19:26:44
问题 I have this strange problem, SslStream.AuthenticateAsClient() throws following exception: System.Security.Authentication.AuthenticationException : A call to SSPI failed, see inner exception. ----> System.ComponentModel.Win32Exception : The token supplied to the function is invalid It happens only when Tls12 is required by the client: SslStream.AuthenticateAsClient(..., ..., SslProtocols.Tls12); Code works properly for Ssl3, Tls11 and Tls. Server certificate is self-signed and 'old'. It uses

python + how to remove the message “cryptography is not installed, use of crypto disabled”

試著忘記壹切 提交于 2021-01-28 19:09:57
问题 First time programming in python and I guess you will notice it after reading my question: + How can I remove the message "cryptography is not installed, use of crypto disabled" when running the application? I have created a basic console application using the pyinstaller tool and the code is written in python. When I run the executable, I am getting the message "cryptography is not installed, use of crypto disabled". The program still runs, but I would prefer to get rid off the message. Can

Bouncy Castle convert ASN.1 to r and s byte arrays

徘徊边缘 提交于 2021-01-28 13:31:52
问题 I have the following code that generates a digital signature: byte[] GetSignature(byte[] message, byte[] privateKey) { var ecParams = NistNamedCurves.GetByName("P-256"); var domainParameters = new ECDomainParameters(ecParams.Curve, ecParams.G, ecParams.N, ecParams.H, ecParams.GetSeed()); var d = new BigInteger(1, privateKey); var privateKeyParameters = new ECPrivateKeyParameters(d, domainParameters); var signer = SignerUtilities.GetSigner("SHA-256withECDSA"); signer.Init(true,

Bouncy Castle convert ASN.1 to r and s byte arrays

岁酱吖の 提交于 2021-01-28 13:31:30
问题 I have the following code that generates a digital signature: byte[] GetSignature(byte[] message, byte[] privateKey) { var ecParams = NistNamedCurves.GetByName("P-256"); var domainParameters = new ECDomainParameters(ecParams.Curve, ecParams.G, ecParams.N, ecParams.H, ecParams.GetSeed()); var d = new BigInteger(1, privateKey); var privateKeyParameters = new ECPrivateKeyParameters(d, domainParameters); var signer = SignerUtilities.GetSigner("SHA-256withECDSA"); signer.Init(true,

Why are classes like SHA1Managed, SHA256Managed hidden from my Intellisense?

人走茶凉 提交于 2021-01-28 11:21:10
问题 When I go to the System.Security.Cryptography namespace, I can only see SHA1 , SHA256 , HMACSHA1 etc classes there. But actually, there is a SHA1Managed class, as well as SHA256Managed , which I don't see? When I write it out manually - everything works as expected. Is this hidden intentionally? And what's the difference between simply instancing a managed version of those, versus for example calling their factory methods ( SHA1.Create() or SHA256.Create() )? Are they the same thing? 回答1: Can

Error validating CMS signature

不问归期 提交于 2021-01-28 09:21:03
问题 For the past 2 weeks I've been banging my head against a wall trying to create and validate CMS signatures in Swift 4 using OpenSSL. My code is ultimately destined to be run on Linux, so I can't use the macOS Security framework. I believe I have finally gotten CMS signature creation working properly. My code for that looks like this: let testBundle = Bundle(for: type(of: self)) guard let textUrl = testBundle.url(forResource: "test_message", withExtension: "txt"), let signingKeyUrl =

How do I use bouncy castle in .net to encrypt using RSA/ECB/OAEPWithSHA256AndMGF1Padding?

僤鯓⒐⒋嵵緔 提交于 2021-01-28 07:13:06
问题 There are examples on the web on how to use bouncy castle library in Java to encrypt with RSA/ECB/OAEPWithSHA256AndMGF1Padding (Example is shown at breaking down RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING). However the bouncy castle library in C# seem to have deviated from Java library in that it is more explicit (hence requires more steps) and I am not able to figure out how to make it work for the above algorithm. Would appreciate if some body can put a code sample together to encrypt a sample

Digitally sign a hex string in command line using elliptic curve secp256k1

房东的猫 提交于 2021-01-28 06:51:40
问题 I'm trying to figure out the most simple way to digitally sign a string of hex values using a private key also represented by a string of hex values. I'm open to command line, or a script, but preferably using openssl cli. Example: string to sign: 1333183ddf384da83ed49296136c70d206ad2b19331bf25d390e69b222165e37 private key: a675c86089e0622c112379906f5cf19ee336575af1bfa1de558051312db9afdc Hoping there is a command like: $ openssl sign -msg

Electronjs and Nodejs(Crypto) crypto.scryptSync is not a function

穿精又带淫゛_ 提交于 2021-01-28 02:34:23
问题 Hi So I have a server running Crypto it working perfectly. Im using electronjs as a client side and crypto is suppose to be build into node. when I try use the module it returns "crypto.scryptSync is not a function" I have let crypto = require('crypto'); at the top of the page im just doing a simple call like this Encrypt_AES function Encrypt_AES(data, pubkey) { const algorithm = 'aes-192-cbc'; const key = crypto.scryptSync(pubkey, 'salt', 24); const iv = Buffer.alloc(16, 0); //