cryptography

cryto.createHash sha512 with hexDigest input type

孤街浪徒 提交于 2020-01-14 14:29:06
问题 I am trying to get the same result I obtain at http://jssha.sourceforge.net/ where I have the word 'testing' in question: var word = 'testing'; var hex = toHex(word); // '740065007300740069006e006700'; on jssha when selecting input type as HEX with the value of the hex variable and SHA-512 I get the following result: 6e42b2c2a6351036b78384212774135d99d849da3066264983e495b5f74dc922e3d361b8ea9c8527169757233ed0bd4e56b2c42aab0a21bbcca67219dc53b472 although I can't achieve the same result with

What are the actual formats supported by CngKeyBlobFormat?

坚强是说给别人听的谎言 提交于 2020-01-14 08:30:36
问题 The Microsoft pages provide "minimal" information about the formats that can be used by CngKey.Import. Which actual formats are actually represented by the following CngKeyBlobFormat properties? EccPrivateBlob EccPublicBlob GenericPrivateBlob GenericPublicBlob OpaqueTransportBlob Pkcs8PrivateBlob Only the PKCS#8 private key format hints slightly about the format of the key, but it doesn't specify if the private key needs to be wrapped or if just the inner PKCS#8 structure is accepted. The

AES encryption with plain text key using bash openssl

你说的曾经没有我的故事 提交于 2020-01-14 06:00:23
问题 I am trying to encrypt a string using AES CBC. The output of the online tool (http://aes.online-domain-tools.com/) and the bash openssl command do not match. Can anyone help me with what I am doing wrong? key = 12345678912345678912345678912345 iv="e90e89a2277f4f3b6a2080d27f734266" #using the one generated by online tool openssl enc -aes-256-cbc -in input.txt -out output.txt -K $key -iv $iv EDIT - more info on the settings chosen on the site - Input type - plain text Function - AES Mode - CBC

Load stored RSA public/private key from disk?

狂风中的少年 提交于 2020-01-14 05:37:28
问题 independent from the fact that the private key should be encrypted (which happens independently from this question): I'm generating RSA key pairs using this code: KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); kpg.initialize(2048); KeyPair keyPair = kpg.generateKeyPair(); privKey = (RSAPrivateKey)keyPair.getPrivate(); pubKey = (RSAPublicKey)keyPair.getPublic(); byte[] data=privKey.getEncoded(); ... byte[] data=pupKey.getEncoded(); The contents of data are binary and not Base 64

How can I import an RSA public key from either XML or modulus/exponent in native code for use with Windows CAPI's CryptVerifySignature?

北慕城南 提交于 2020-01-14 05:29:06
问题 In C#, I am able to validate a hash against a public key in either of the following ways: // Import from raw modulus and exponent using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) { RSAParameters rsaKeyInfo = new RSAParameters {Modulus = modulus, Exponent = exponent}; rsa.ImportParameters(rsaKeyInfo); return rsa.VerifyHash(hash, CryptoConfig.MapNameToOID("SHA512"), signature); } // Import from XML using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) { rsa

How can I import an RSA public key from either XML or modulus/exponent in native code for use with Windows CAPI's CryptVerifySignature?

让人想犯罪 __ 提交于 2020-01-14 05:29:06
问题 In C#, I am able to validate a hash against a public key in either of the following ways: // Import from raw modulus and exponent using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) { RSAParameters rsaKeyInfo = new RSAParameters {Modulus = modulus, Exponent = exponent}; rsa.ImportParameters(rsaKeyInfo); return rsa.VerifyHash(hash, CryptoConfig.MapNameToOID("SHA512"), signature); } // Import from XML using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) { rsa

How to use salsa20 counter nonce?

核能气质少年 提交于 2020-01-14 03:31:19
问题 I am not sure if I got it right: a counter of messages can be used as/instead of the nonce? I mean a message like this: Header(2bytes) | counter(8bytes) | Body(n bytes encrypted) | HMAC-SHA1 with counter = 1 (63 of the bits=0) is ok? I understand that I should never use the same key with the same nonce twice. What do I do when a new connection is started and counter starts from 1 again? 回答1: I understand that I should never use the same key with the same nonce twice. What do I do when a new

Keystore operation failed with RSA sign and verify

筅森魡賤 提交于 2020-01-14 03:10:00
问题 I have difficulties to use RSA for signing and verifying. Below is part of my RSA class that I use. The methods init() , privateKey() and publicKey() work fine with encrypt() and decrypt() methods (last two not listed here), so I assume I made some mistake inside of my sign() method. Method verify() wasn't tested yet, because signing was unsuccessful, so I wasn't able to move further. Please take a look... My RSA class is: class RSA { private final static String ANDROID_KEY_STORE =

Keystore operation failed with RSA sign and verify

≡放荡痞女 提交于 2020-01-14 03:09:58
问题 I have difficulties to use RSA for signing and verifying. Below is part of my RSA class that I use. The methods init() , privateKey() and publicKey() work fine with encrypt() and decrypt() methods (last two not listed here), so I assume I made some mistake inside of my sign() method. Method verify() wasn't tested yet, because signing was unsuccessful, so I wasn't able to move further. Please take a look... My RSA class is: class RSA { private final static String ANDROID_KEY_STORE =

How do I use RSACryptoServiceProvider to decrypt, given that I only have p, q, d and u?

南笙酒味 提交于 2020-01-14 03:07:36
问题 I am creating a simple client app to experiment with Mega and I am having trouble wrapping my head around the way RSA is used. Let's take, for example, the decryption of the session ID - this is one of the first things that must be done in order to log in. The API provides me the following RSA data: p (1024 bits) q (1024 bits) d (2044 bits) u (1024 bits) To start with, I do not know what "u" stands for. I see from code that it is calculated by modinverse(p, q) - is this what is commonly