cryptography

Memory Leak while verifying Authenticode Signature of Executables?

人盡茶涼 提交于 2019-12-22 07:51:30
问题 I am using WinVerifyTrust to verify the validity of some Windows executables with the following function, called in a loop from _tmain : int signature_is_valid(const wchar_t *filepath) { GUID guid = WINTRUST_ACTION_GENERIC_VERIFY_V2; WINTRUST_FILE_INFO file_info = { 0 }; WINTRUST_DATA wd; file_info.cbStruct = sizeof(file_info); file_info.pcwszFilePath = filepath; file_info.hFile = NULL; file_info.pgKnownSubject = NULL; ZeroMemory(&wd, sizeof(wd)); wd.cbStruct = sizeof(wd); wd.dwUIChoice = WTD

Are the first 32 bits of a 160-bit SHA1 hash an acceptable substitute for a CRC32 hash?

十年热恋 提交于 2019-12-22 06:27:20
问题 I'm working on a .NET 3.5 project and I need a 32-bit hash value. There doesn't seem to be any methods in the .NET Cryptography classes that return a 32-bit hash (MD5 is 128 bits, SHA1 is 160 bits, etc.). I implemented a CRC32 class, but I find that the SHA1 and MD5 hashing functions that already exist are much faster. Would there be any problem (i.e., increased chance of collisions) with me using the SHA1 hashing function and just breaking off the first 32 bits to store as my hash value? 回答1

Hashing and encryption technique for a huge data set containing phone numbers

安稳与你 提交于 2019-12-22 05:36:08
问题 Description of problem: I'm in the process of working with a highly sensitive data-set that contains the people's phone number information as one of the columns. I need to apply (encryption/hash function on them) to convert them as some encoded values and do my analysis. It can be an one-way hash - i.e, after processing with the encrypted data we wont be converting them back to original phone numbers. Essentially, am looking for an anonymizer that takes phone numbers and converts them to some

Perfectly random one-time pad for encryption

不羁的心 提交于 2019-12-22 05:25:15
问题 I need to create a one-time pad to encrypt some data (a few KBs in size). How should I go about generating this one-time pad to avoid all of the pseudo-random problems associated with basic random number generation such as rand() ? Is there an existing, trusted tool or library I can use for this? 回答1: Try Random.ORG. They have various free (and paid) services that generate truly random numbers based on atmospheric noise (or at least that is what they claim to do). 回答2: Most modern operating

PKCS#11 Generate AES key

自作多情 提交于 2019-12-22 05:20:11
问题 Hei, The question is not really about Ncryptoki but i didnt know anywhere else to ask.. so if anybody can help please help me. Im tryng to generate AES key and heres the code what i have right now: CK_MECHANISM keyGenMech = new CK_MECHANISM(CKM.AES_KEY_GEN); CK_ATTRIBUTE[] template = { new CK_ATTRIBUTE(CKA.CLASS, CKO.SECRET_KEY), new CK_ATTRIBUTE(CKA.TOKEN, CK_BBOOL.TRUE), new CK_ATTRIBUTE(CKA.SENSITIVE, CK_BBOOL.TRUE), new CK_ATTRIBUTE(CKA.VALUE_LEN, 32), new CK_ATTRIBUTE(CKA.KEY_TYPE, CKK

How can I do an ISO 9797-1 MAC with triple DES in C#?

萝らか妹 提交于 2019-12-22 05:18:04
问题 I've got a project which stipulates the following encryption rules for a 24 byte block of data. 1) Cryptography should be done using full triple DES MAC algorithm as defined in 9797-1 as MAC algorithm 3 with output transformation 3 without truncation and with DES in CBC mode as block cipher with ICV set to zeros. Last 8 bytes of encrypted data constitute the value we need. The program is saying the encryption done is wrong. Are there any other things I need to do to match the above spec? The

Are there advantages for using SpongyCastle over BouncyCastle, if targeting Android 3.0 and later?

泄露秘密 提交于 2019-12-22 04:42:55
问题 If I understand the situation correctly, SpongyCastle is a renaming of BouncyCastle and it was created to give people the ability to include a new version of BouncyCastle on Android, since just including the latest BouncyCastle jar would cause conflicts with the old and stripped down version of BouncyCastle that came with Android. However, apparently since version 3.0 (in 2011 - 6 years ago!) the Android BouncyCastle package was renamed to com.android.org.bouncycastle , so that now if you

Manipulating 80 bits datatype in C

Deadly 提交于 2019-12-22 04:38:11
问题 I'm implementing some cryptographic algorithm in C which involves an 80 bits key. A particular operation involves a rotate shifting the key x number of bits. I've tried the long double type which if I'm not wrong is 80bits, but that doesn't work with the bitshift operator. The only alternative I can come up with is to use a 10 element char array with some complicated looping and if-else. My question is whether there's some simple and efficient way of carrying this out. Thanks. 回答1: There is

How to add seek and position capabilities to CryptoStream

蓝咒 提交于 2019-12-22 04:37:23
问题 I was trying to use CryptoStream with AWS .NET SDk it failed as seek is not supported on CryptoStream. I read somewhere with content length known we should be able to add these capabilities to CryptoStream. I would like to know how to do this; any sample code will be useful too. I have a method like this which is passed with a FieStream and returns a cryptoStream. I assign the returned Stream object to InputStream of AWS SDk PutObjectRequest object. public static Stream GetEncryptStream

What algorithm does Microsoft Office 2010 use for encryption?

冷暖自知 提交于 2019-12-22 04:36:17
问题 Does it use the standard AES 128bit key for encryption? I've searched a lot on Google, but I still haven't found the algorithm is uses for encrypting. I'm encrypting a PowerPoint file. 回答1: This technet article confirms that the defaults are AES 128-bit key, SHA1, CBC. Although there are Office 2010 settings to change how encryption is performed, when you encrypt Open XML Format files (.docx, .xslx, .pptx, and so on) the default values — AES (Advanced Encryption Standard), 128-bit key length,