rsa

Android Encryption RSA InvalidKeyException

天涯浪子 提交于 2020-01-31 06:18:53
问题 Dears, I need help to understand why decryptString doesn't work and throw "java.security.InvalidKeyException: Need RSA private or public key". When call encrypt method, i use public key by the private key/certificate. Thanks for any help! public class KeysHandler { /*** * Generate and store in AndroidKeyStore a security KeyPair keys. * @param alias - Alias to create the key. * @return KeyPair object with: private and public key. */ public static KeyPair generateKeyPair(String alias) { KeyPair

Android Encryption RSA InvalidKeyException

扶醉桌前 提交于 2020-01-31 06:15:29
问题 Dears, I need help to understand why decryptString doesn't work and throw "java.security.InvalidKeyException: Need RSA private or public key". When call encrypt method, i use public key by the private key/certificate. Thanks for any help! public class KeysHandler { /*** * Generate and store in AndroidKeyStore a security KeyPair keys. * @param alias - Alias to create the key. * @return KeyPair object with: private and public key. */ public static KeyPair generateKeyPair(String alias) { KeyPair

SSH免密登陆(本机)

孤人 提交于 2020-01-31 03:39:20
本次测试仅用本机;具体根据实际设置调整 修改/etc/hosts 添加本机IP及主机名,如下: 执行ssh-keygen -t rsa,会生成本机的密钥及公钥;保存在以下两个文件中:id_rsa及id_rsa.pub 之后把id_rsa.pub里的内容追加复制到目标主机authorized_keys文件中; 即完成免密登陆,注:免密登陆对用户有要求,登陆哪个用户就修改哪个用户下的公钥文件; 修改后测试:此处因为登陆本机,无需修改iptables等限制; 来源: https://www.cnblogs.com/arvin-arvin/p/11468393.html

ISCC2018 Reverse & Pwn writeup

一个人想着一个人 提交于 2020-01-31 01:05:43
Reference: L1B0 Re RSA256 春秋欢乐赛原题。。flag都不变的 给了三个加密文件和公钥证书public.key,可以使用openssl进行处理 $openssl rsa -pubin -text -modulus -in ./public.key Public-Key: (256 bit) Modulus: 00:d9:9e:95:22:96:a6:d9:60:df:c2:50:4a:ba:54: 5b:94:42:d6:0a:7b:9e:93:0a:ff:45:1c:78:ec:55: d5:55:eb Exponent: 65537 (0x10001) Modulus=D99E952296A6D960DFC2504ABA545B9442D60A7B9E930AFF451C78EC55D555EB writing RSA key -----BEGIN PUBLIC KEY----- MDwwDQYJKoZIhvcNAQEBBQADKwAwKAIhANmelSKWptlg38JQSrpUW5RC1gp7npMK /0UceOxV1VXrAgMBAAE= -----END PUBLIC KEY----- rsa参数中, Exponent=65537 即为 e 值 ,Modulus即为n 使用python解密即可 #!/usr/bin/env python

Why does this encrypted string have funny characters in it? It isn't readable?

和自甴很熟 提交于 2020-01-30 09:50:13
问题 I'm converting the encrypted text using UTF8, yet the resulting string has funny characters that I can't read and not sure if I can send this text to the browser. string message = "hello world"; var rsa = new RSACryptoServiceProvider(2048); var c = new UTF8Encoding(); byte[] dataToEncrypt = c.GetBytes(message); byte[] encryptedData = rsa.Encrypt(dataToEncrypt, false); string output = c.GetString(encryptedData); Console.WriteLine(output); Console.ReadLine(); When I run the above, I get the

RSA: Encrypt password in javascript but failed to decrypt that in C#

雨燕双飞 提交于 2020-01-29 05:35:08
问题 I want apply the RSA encryption to my project, but encountered some troubles: First, I have download the JavaScripts library from http://www.ohdave.com/rsa/ ,and add reference to my project; Second, I have define the RSA object and code to initialize that: internal RSACryptoServiceProvider Rsa { get { if (HttpContext.Cache["Rsa"] != null) { RSACryptoServiceProvider encryptKeys = (RSACryptoServiceProvider)HttpContext.Cache["Rsa"]; return encryptKeys; } else { return new

使用 openssl 生成证书

时光怂恿深爱的人放手 提交于 2020-01-29 05:06:34
一、openssl 简介 openssl 是目前最流行的 SSL 密码库工具,其提供了一个通用、健壮、功能完备的工具套件,用以支持SSL/TLS 协议的实现。 官网: https://www.openssl.org/source/ 构成部分 密码算法库 密钥和证书封装管理功能 SSL通信API接口 用途 建立 RSA、DH、DSA key 参数 建立 X.509 证书、证书签名请求(CSR)和CRLs(证书回收列表) 计算消息摘要 使用各种 Cipher加密/解密 SSL/TLS 客户端以及服务器的测试 处理S/MIME 或者加密邮件 二、RSA密钥操作 默认情况下,openssl 输出格式为 PKCS#1-PEM 生成RSA私钥(无加密) openssl genrsa -out rsa_private.key 2048 生成RSA公钥 openssl rsa -in rsa_private.key -pubout -out rsa_public.key 生成RSA私钥(使用aes256加密) openssl genrsa -aes256 -passout pass:111111 -out rsa_aes_private.key 2048 其中 passout 代替shell 进行密码输入,否则会提示输入密码; 生成加密后的内容如: -----BEGIN RSA PRIVATE

How to parse(Convert to RSAParameters) X.509 private key in C#?

独自空忆成欢 提交于 2020-01-28 02:52:06
问题 I'm working on an encryption channel to encrypt the communication between two devices. So I'm creating a helper class to do the encryption and decryption. I've googled a lot and found a piece of code that can parse RSA Public Key Into RSACryptoServiceProvider . This is the code: public static RSACryptoServiceProvider DecodeX509PublicKey(byte[] x509key) { byte[] SeqOID = { 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00 }; byte[] seq = new byte[15];

密码学习题总结

核能气质少年 提交于 2020-01-27 06:54:11
密码学习题总结 第一题 在公钥算法还没有诞生的年代,数字签名遥不可及。为了对n位的消息签名,研究者设计了这个方案:事先随机产生2n个56位的秘钥。k1,K1, k2,K2....,kn,Kn,这些参数是保密的。发送者再相应地事先准备好两套64位的签证参数:u,U1,u2,U2: ...,Un,U和v,V1,v2,V2.... vn,Vn,这两套参数公开,其中vi=E(ki,ui), Vi= E(Ki,Ui)。 消息M按如下方式签名。对于消息的第i位,依赖该消息位的值为0或1,将ki或Ki附在消息上。例如,如果消息 的前三位为110,则签名时附上的前三个秘钥为K1,K2,k3。请问该方法如何验证签名?一套 保密秘钥可以安全 地为不同的消息签名多少次? 如何验证签名:直接代入验证签名,例如,明文为M=110,那么M加密之后为K1,K2,k3,那么代入E(K1,U1)得到V1,验证V1是否正确(因为E(Ki,Ui)和Vi都是已知的),同理可以验证V2,v3,可以验证K1,K2,k3是正确的序列,即可验证签名。 一套保密钥可以安全的为不同的消息签名1次。 第二题 请借助RSA的相关方法,设计一个方案,使得:(1)第一签名者形成文件,对文件签名,并发给第二签名者;(2)第二签名者首先验证该文件确实是第一签名者签过名。然后,他将其签名也加入文件中

RSA 加密

你离开我真会死。 提交于 2020-01-26 10:18:57
1、RSA算法介绍 RSA是目前最有影响力的公钥加密算法,该算法基于一个十分简单的数论事实:将两个大素数相乘十分容易,但那时想要对其乘积进行因式分解却极其困难,因此可以将乘积公开作为加密密钥,即公钥,而两个大素数组合成私钥。公钥是可发布的供任何人使用,私钥则为自己所有,供解密之用。 解密者拥有私钥,并且将由私钥计算生成的公钥发布给加密者。加密都使用公钥进行加密,并将密文发送到解密者,解密者用私钥解密将密文解码为明文。 以甲要把信息发给乙为例,首先确定角色:甲为加密者,乙为解密者。首先由乙随机确定一个KEY,称之为密匙,将这个KEY始终保存在机器B中而不发出来;然后,由这个 KEY计算出另一个KEY,称之为公匙。这个公钥的特性是几乎不可能通过它自身计算出生成它的私钥。接下来通过网络把这个公钥传给甲,甲收到公钥后,利用公钥对信息加密,并把密文通过网络发送到乙,最后乙利用已知的私钥,就对密文进行解码了。以上就是RSA算法的工作流程。 2、RSA算法实现 1. 随意选择两个大的质数p和q,p不等于q,计算N=pq。 2. 根据欧拉函数,不大于N且与N互质的整数個数為(p-1)(q-1)。 3. 选择一个整数e与(p-1)(q-1)互质,并且e小于(p-1)(q-1)。 4. 用以下这个公式计算d:d× e ≡ 1 (mod (p-1)(q-1))。 5. 将p和q的记录销毁。 以上内容中,