cryptography

Openssl and Node's Crypto have different outputs

廉价感情. 提交于 2019-12-24 02:07:46
问题 in short, I want to sign a string( "a" ) just like openssl using crypto library in node. but I get wrong output over and over again. Long Description signing with openssl I have two generated rsa keys : public-key.pem and private-key.pem that I have made them with openssl : $ openssl genrsa 2048 > private-key.pem $ openssl rsa -in private-key.pem -pubout >public-key.pem when I type these in shell: $ echo "a" | openssl dgst -sha256 -sign private-key.pem >signature_openssl.bin It generates a

Export a certificate in asn.1 notation from X509Certificate2

点点圈 提交于 2019-12-24 01:54:34
问题 I'm currently learning working with certificates and now I'm curious, if it is possible to get the ASN.1 notation of a loaded certificate from a X509Certificate2 -instance. I have found the Export -Method and it works fine, however I have not seen a possibilty to change the encoding of the output format - it's only in the DER-format. Is there a possibility to export/convert a loaded certificate as an ASCII ASN.1 certificate, something like in the example below: Certificate: Data: Version: 3

Asymmetric stream cipher with short plaintext => short ciphertext

孤街浪徒 提交于 2019-12-24 01:43:23
问题 I am looking for an asymmetric cipher which has the property that very short inputs result in very short outputs. .NET's standard RSACryptoService seems to output a minimum of 128 bytes for any short plaintext, including the empty plaintext. Minimum supported BlockSize is 128 and the only supported Mode is CBC. The perfect algorithm would not expand the plaintext at all, while providing the asymmetric property. Expected input size is 50-100 bytes, certainly never more than 150. 回答1: It is

EVP_BytesToKey implementation in PHP

淺唱寂寞╮ 提交于 2019-12-24 01:33:29
问题 I've been trying to implement the exact same function in PHP as the one in C. However, I have not seen the exact same outcome. I think the problem is with the "count" or iteration that I still do not totally understand. Function definition: int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, const unsigned char *salt, const unsigned char *data, int datal, int count, unsigned char *key, unsigned char *iv) Here is the link to the C function implementation: evp_key.c. Here is what I

EVP_BytesToKey implementation in PHP

倖福魔咒の 提交于 2019-12-24 01:31:29
问题 I've been trying to implement the exact same function in PHP as the one in C. However, I have not seen the exact same outcome. I think the problem is with the "count" or iteration that I still do not totally understand. Function definition: int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, const unsigned char *salt, const unsigned char *data, int datal, int count, unsigned char *key, unsigned char *iv) Here is the link to the C function implementation: evp_key.c. Here is what I

SSRS Decrypting database column throws error “Value cannot be null. Parameter name: inputBuffer”

北城余情 提交于 2019-12-24 01:17:05
问题 We have a database field that is encrypted in a C# MVC app using Entity Framework. That part works fine for encrypting and decrypting. We need to show this data decrypted in an SSRS report. I've taken the Decrypt method and converted it to VB.Net and placed in the code behind of the report. The error occurs when calling the StreamReader 's ReadToEnd method. We've found some references online about there being an issue trying to close a stream that's already closed. This stream is only being

Unable to compute a CMAC using Cygwin and OpenSSL

a 夏天 提交于 2019-12-24 00:55:50
问题 I want to compute a CMAC using OpenSSL. I found this question which helped me. But I am encountering a problem with the following code: #include <openssl/cmac.h> void dispHex(const unsigned char *buffer, unsigned int size) { int i=0; for (i=0; i<size-1; i++) { printf("%02X ", buffer[i]); } printf("%02x\n", buffer[i]); } int main() { size_t out_len; unsigned char res[16]; unsigned char mac_key[16] = { 0x00, 0x01 ,0x02 ,0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01 ,0x02 ,0x03, 0x04, 0x05, 0x06,

HMAC SHA256 in Swift 4

别等时光非礼了梦想. 提交于 2019-12-24 00:48:36
问题 I have a string and a key, which i want to generate an HMAC SHA256 from it. Although i'm using 2 libs IDZSwiftCommonCrypto and CryptoSwift and this answer Nothing really worked for me. My source of truth are those 2 websites https://myeasywww.appspot.com/utility/free/online/Crypt_Decrypt-MD5-AES-HMAC-SHA-DES-RABBIT/en?command=UTILITY&ID=2 and https://www.freeformatter.com/hmac-generator.html#ad-output Which they always generate the correct hash key for my case. Any idea in what can work here?

RandomNumberGenerator in ASP.NET5

旧城冷巷雨未停 提交于 2019-12-24 00:37:52
问题 I have created a new Web API project using the ASP.NET 5 Templates. I am wanting to generate random numbers using System.Security.Cryptography.RandomNumberGenerator but it is not available in the .NET Platform 5.4 (see screenshot). Compiling it also generates the following errors: Error CS0234 The type or namespace name 'Cryptography' does not exist in the namespace 'System.Security' (are you missing an assembly reference?) Error CS0246 The type or namespace name 'RandomNumberGenerator' could

Random number generator security: BCryptGenRandom vs RNGCryptoServiceProvider

泄露秘密 提交于 2019-12-24 00:36:22
问题 For those in a hurry, this is NOT related to the controversial Dual_EC_DRBG planted inside NIST's SP800-90A. About the two RNGs: The Microsoft BCRYPT layer based one is over their C API. BCryptGenRandom is following NIST SP800-90A's CTR_DRBG (i.e. uses an approved block cipher, AES, to create random bits). However it is unclear if it uses a hardware random source as seed (or part of the seed)... The Microsoft .NET RNGCryptoServiceProvider is C# based. Looking at the .NET source code (or here)