rsa

How do I encrypt with an RSA private key read from a PEM file using the Go programming language?

会有一股神秘感。 提交于 2020-01-03 01:59:06
问题 How do I do the equivalent of the following C++ code in go? RSA *key = PEM_read_RSAPrivateKey(f, NULL, NULL, NULL); std::vector<CK_BYTE> out(128); RSA_private_encrypt(in.size(), &in[0], &out[0], key, RSA_PKCS1_PADDING) I've looked at the Go rsa package. It looks like EncryptPKCS1v15() may be the equivalent of RSA_private_encrypt(). But I don't see how to create a PrivateKey object other than with GenerateKey(), which (one can confirm by looking at the source) generates one using random prime

BigIntegers, gcd , modulus inverse to find public key

狂风中的少年 提交于 2020-01-02 17:20:53
问题 So, Im using java to find the public key of a RSA password. Right now Im unsure what I'm doing and also if it's correct. I have this information for the public key. C = 5449089907 n = p*q = 8271344041 q = 181123 p = n/q = 45667 d = 53 phi(n) = (p-1)(q-1) = 8271117252 What complicates things are the BigIntegers, the numbers are way to huge for int and longs, so I have to use the clumsy BigIntegers. As far as I understand I have the following equation to solve. e*5198987987 - x*8271117252 = 1 I

Java实现数字签名

半城伤御伤魂 提交于 2020-01-02 15:53:22
、数字签名算法概述 签名认证是对非对称加密技术与数字摘要技术的综合运用,指的是将通信内容的摘要信息使用发送者的私钥进行加密,然后将密文与原文一起传输给信息的接收者,接收者通过发送者的公钥信息来解密被加密的摘要作息,然后使用与发送者相同的摘要算法,对接收到的内容采用相同的方式方式产生摘要串,与解密的摘要串进行对比,如果相同,则说明接收到的内容是完整的,在传输过程中没有受到第三方的篡改,否则说明通信内容已被第三方修改。 我们知道,每个人都有其特有的私钥,且都是对外界保密的,而通过私钥加密的信息,只能通过其对应的公钥来进行解密。因此,私钥可以代表私钥持有者的身份,可以通过私钥对应的公钥来对私钥拥有者的身份进行校验。通过数字签名,能够确认消息是消息发送方签名并发送过来的,因为其他人根本假冒不了消息发送方的签名,他们没有消息发送者的私钥。而不同的内容,摘要信息千差万别,通过数字摘要算法,可以确保传输内容的完整性,如果传输内容在中途被篡改了,对应的数字签名的值也将发生改变。 数字签名:带有密钥(公钥,私钥)的消息摘要算法。私钥用于签名,公钥用于验证。 数字签名的作用: 验证数据的完整性,认证数据来源,抗否认。 数字签名实现的具体原理: 1、 将报文按双方约定的HASH算法计算得到一个固定位数的报文摘要。在数学上保证,只要改动报文中任何一位,重新计算出的报文摘要值就会与原先的值不相符

Getting 1 byte extra in the modulus RSA Key and sometimes for exponents also

岁酱吖の 提交于 2020-01-02 06:28:32
问题 Here is my code snippet: int eValue = 79, t; int bitLength = 1024; // KeySize BigInteger e = new BigInteger(Integer.toString(eValue)); KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); kpg.initialize(bitLength); KeyPair kp = kpg.generateKeyPair(); KeyFactory kfactory = KeyFactory.getInstance("RSA"); RSAPublicKeySpec kspec = (RSAPublicKeySpec) kfactory.getKeySpec(kp.getPublic(), RSAPublicKeySpec.class); System.out.println("Byte Length is : " + kspec.getModulus().toByteArray().length)

How to properly use Bouncy Castle's OAEPEncoding for RSA (Lightweight API)

与世无争的帅哥 提交于 2020-01-02 03:37:28
问题 I've been playing around with Bouncy Castle's implementation of RSA (Lightweight API) and got the basics figured out. Looking at their spec for JCE provider implementation I noticed that different padding schemes can be used with RSA. From what I understand, by default null padding is used. So I began exploring OAEP padding, particularly OAEPWithSHA512AndMGF1Padding . Searching with Google wasn't very helpful so I began digging through BC's source code and found org.bouncycastle.jce.provider

Use RSA with Eclipse Remote Systems Explorer?

穿精又带淫゛_ 提交于 2020-01-02 00:51:08
问题 I'm using the Remote Systems Explorer (RSE) plugin in Eclipse on my Windows 7 machine to edit files through SFTP on a remote Linux server. I have an RSA key pair setup between my machine and the Linux server, and I can SSH using my keys no problem when I'm at a Cygwin command prompt. I'm not able to get the keys working in Eclipse, though. I added my RSA private key to Eclipse through Preferences -> General -> Network Connections -> SSH2. I also have my public key on the remote Linux server

Sanity check SSH public key? [closed]

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-02 00:50:36
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I have asked users for their public "id_rsa.pub" ssh key, that I then place in "/home/theiraccount/.ssh/authorized_keys", so they can login to the server by SSH. I'd like to automate this process. Is there anyway to sanity check the string they give me (programmatically or otherwise)? I want to verify that sshd

How can I create a key using RSA/ECB/PKCS1Padding in python?

不羁的心 提交于 2020-01-01 14:39:35
问题 I am struggling to find any method of using RSA in ECB mode with PKCS1 padding in python. I've looked into pyCrypto, but they don't have PKCS1 padding in the master branch (but do in a patch). Nevertheless I found RSA with PKCS1 in the M2Crypto package, but I'm not sure if I can choose ECB mode... 回答1: Chaining mode such as ECB makes no sense for RSA, unless you are doing it wrong. ECB is for block ciphers: the input data is split into equal-size blocks, and each block is encrypted separately

openssl_pkey_export and “cannot get key from parameter 1”

泄露秘密 提交于 2020-01-01 12:25:07
问题 I need to use openssl within my php project, so I created a test php page using openssl. However, I keep getting these errors and I am not sure why. openssl is enabled. Warning: openssl_pkey_export() [function.openssl-pkey-export]: cannot get key from parameter 1 in C:\wamp\www\opensslsample\index.php on line 18 Warning: openssl_pkey_get_details() expects parameter 1 to be resource, boolean given in C:\wamp\www\opensslsample\index.php on line 21 <?php //echo phpinfo(); $privateKey = openssl

Can RSA be both used as encryption and signature?

那年仲夏 提交于 2020-01-01 11:36:53
问题 I am sorry but my mind suddenly goes blank for this question.... EDIT (Scenario) If I want information to bypass simple filters like f-ck , is it OK to encrypt the information with public key, and sign by private key? The public key may have already exchanged by both sides, and it is even hard to get the public key. EDIT 2 The information itself may not that much credential. The point of encryption and signature is for bypassing and integrity. 回答1: RSA is two algorithms: one for asymmetric