rsa

Verify JWT with RS256 (asymmetric) in C#

99封情书 提交于 2020-08-26 07:20:42
问题 I have some code like this which I believe is failing because it's using an Asymmetric RS256 but has "SymmetricSecurityKey()". The tokens were hand generated from https://jwt.io/ How do I convert this to use my Asymmetric public key? Also, I'm new to C# and I'd like to target dotnet standard, so I'm also wondering if I'm using the wrong libs? (I'm depending on the preview release) λ cat Program.cs using System; using System.IdentityModel.Tokens.Jwt; using System.Text; using System.Linq;

How to encrypt large file with RSA?

半世苍凉 提交于 2020-08-25 07:34:12
问题 Code https://play.golang.org/p/CUEqjsJq5c Error: panic: crypto/rsa: message too long for RSA public key size goroutine 1 [running]: panic(0x4a6d80, 0xc420010420) /usr/local/go/src/runtime/panic.go:500 +0x1a1 main.main() /tmp/sample.go:28 +0xfa File size 811 byte (for test encrypt self source file). I want encrypt some bigger files, 1..500 mb. Can I do it with RSA or need use some other methods? 回答1: RSA can only encrypt data smaller than (or equal to) the key length. The answer is to encrypt

How to encrypt large file with RSA?

让人想犯罪 __ 提交于 2020-08-25 07:34:09
问题 Code https://play.golang.org/p/CUEqjsJq5c Error: panic: crypto/rsa: message too long for RSA public key size goroutine 1 [running]: panic(0x4a6d80, 0xc420010420) /usr/local/go/src/runtime/panic.go:500 +0x1a1 main.main() /tmp/sample.go:28 +0xfa File size 811 byte (for test encrypt self source file). I want encrypt some bigger files, 1..500 mb. Can I do it with RSA or need use some other methods? 回答1: RSA can only encrypt data smaller than (or equal to) the key length. The answer is to encrypt

Which section of TLS packet to decrypt?

百般思念 提交于 2020-08-20 15:26:53
问题 I writing a C# sniffer to decrypt a TLS packet which I already have the private key for. Here is a screenshot of the TLS packet. I have tried decrypting the bytes in "Encrypted Application Data", but I am getting the error, "The parameter is incorrect" which usually means the data isn't correct for the provided key, so the question is, am I decrypting the wrong bytes? The private key I have is from a .pem file in the section -----BEGIN PRIVATE KEY-----. I think this .pem file is generated

Simplify modular exponentiation C++

穿精又带淫゛_ 提交于 2020-08-20 12:24:54
问题 I am attempting to write the decryption function for an RSA encryption system, everything seemed to be working fine for very small numbers, however sometimes the output just isn't correct (I think that the cause may be a floating point error or some kind of stack overflow). The process which is causing me problems can be simplified to (11^23) mod 187 but I will include the full code in case anybody wants to see it. I know that the answer should be 88 as it is the example used in Appendix J of

Export RSA key pair with WebCrypto in Chromium

此生再无相见时 提交于 2020-08-09 13:35:11
问题 The following code works in Firefox 76.0.1: "use strict" let RSAKeys (async () => { RSAKeys = await crypto.subtle.generateKey({ name: "RSA-OAEP", modulusLength: 3072, publicExponent: new Uint8Array([1, 0, 1]), hash: "SHA-256"}, true, ["wrapKey", "unwrapKey"]) alert(JSON.stringify(Object.fromEntries( await Promise.all(Object.entries(RSAKeys).map(async ([k, v], i) => [k, await cryptoBase64("exportKey", ["pkcs8", "spki"][i], v)]))))) })() async function cryptoBase64(primitive, ...args) { return

Different label and MGF1 hash functions using RsaCng with OAEP

╄→尐↘猪︶ㄣ 提交于 2020-07-22 21:33:19
问题 We've to decrypt a ciphertext encrypted using RSA OAEP and we're trying to use RsaCng. The ciphertext was produced using Java, and the Java API allows you to specify a different hash function for the label and for the mask generation function (MGF1). In this specific case, SHA-256 was used in the first case and SHA-1 in the second (yes, not a good idea but we have no control over this). Now, from what I understand using RsaCng I can only specify one hash function (using RSAEncryptionPadding