private-key

How to implement OpenSSL functionality in Python?

点点圈 提交于 2019-12-02 23:18:07
I would like to encrypt a secret text by public-key and decrypt it by private-key in Python. I can achieve that with the openssl command: echo "secrettext/2011/09/14 22:57:23" | openssl rsautl -encrypt -pubin -inkey public.pem | base64 data.cry base64 -D data.cry | openssl rsautl -decrypt -inkey private.pem How would one implement that in Python? jfs Encrypt #!/usr/bin/env python import fileinput from M2Crypto import RSA rsa = RSA.load_pub_key("public.pem") ctxt = rsa.public_encrypt(fileinput.input().read(), RSA.pkcs1_oaep_padding) print ctxt.encode('base64') Decrypt #!/usr/bin/env python

Create PrivateKey and PublicKey from a String base64 encoding with DER format

跟風遠走 提交于 2019-12-02 23:17:31
I have my Private and Public keys in a String in base64 which where encoded using ANS1 DER. I tried creating the instance of a java PrivateKey and PublicKey : byte [] llave2 = DatatypeConverter.parseBase64Binary(key); PKCS8Key pkcs8 = new PKCS8Key( llave2, password.toCharArray()); //line 2 llave2 = pkcs8.getDecryptedBytes(); //line 3 certificado = DatatypeConverter.parseBase64Binary(cer); KeyFactory kf = KeyFactory.getInstance("RSA"); PKCS8EncodedKeySpec ks = new PKCS8EncodedKeySpec(llave2); PrivateKey privateKey = kf.generatePrivate(ks); X509EncodedKeySpec x = new X509EncodedKeySpec

Java: How can I generate PrivateKey from a string?

不问归期 提交于 2019-12-02 22:18:19
I am trying to encode a message with SH1 RSA but I have no experience with security subject except some base information about RSA . I have been given a private key as String . I have managed to write following code block to do the job but I am not sure if I am doing the job securely and correctly. I am not an expert but putting my private key as String in code is not secure I guess. Can anyone guide me? String privateKeyString = "mykeyhere..."; byte[] privateKeyBytes = privateKeyString.getBytes(); String encodedPrivateKey = Base64.encodeToString(privateKeyBytes, Base64.URL_SAFE); KeyFactory

How to create a private key for iPhone Distribution Certificate?

烂漫一生 提交于 2019-12-02 18:21:34
In iPhone Developer Program Portal, there's a video to demonstrate how to create a development certificate and assign a private key Now I have finished the development process and starting to distribute I have created a "Distribution Certificate", but how do I assign a private key to this certificate? As it got the "CodeSign error: code signing identity '...' does not match any code-signing certificate in your keychain" when compiles It will be glad to let me now if I need to assign a private key to the distribution cert and how. Please be noticed that I am NOT talking about development

Newly created file becomes 0 kb (data gets overwritten to nothing) on reboot in Linux

无人久伴 提交于 2019-12-02 16:35:14
问题 I'm having a strange problem that's driving me crazy! The task in hand is to start one set of files during the first login of "root" user and another set of files during the second login of the same user. I decided to use the ".profile" and ".bashrc" files and to reload the ".bashrc" file towards the end of the task happening during the first login. During the first login, I create a private key and certificate signing request, and call an API to get the certificate. I store this certificate

ECC private key is longer than public key

僤鯓⒐⒋嵵緔 提交于 2019-12-02 16:00:41
问题 I have generated ECC public and private key using secp192r1 curve. I get 75 for public and 125 for private encoded key array length. Why private key is longer than public key? Why private key is not longer two times than public? Why private key is not 192 bits = 24 bytes because of secp192r1? Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); ECNamedCurveParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("secp192r1"); KeyPairGenerator g = KeyPairGenerator

PostgreSQL won't start: “server.key” has group or world access

a 夏天 提交于 2019-12-02 14:55:12
Whenerver I start PostgreSQL using command: $ sudo /etc/init.d/postgresql start Pg doesn't start up. The error reported is: * Starting PostgreSQL 8.4 database server * The PostgreSQL server failed to start. Please check the log output: 2010-01-21 22:10:00 PST FATAL: private key file "server.key" has group or world access 2010-01-21 22:10:00 PST DETAIL: File must be owned by the database user or root, must have no write permission for "group", and must have no permissions for "other". ... and when I try to access psql as the postgres user with: $ sudo su postgres $ psql it gives me an error:

Newly created file becomes 0 kb (data gets overwritten to nothing) on reboot in Linux

帅比萌擦擦* 提交于 2019-12-02 12:37:54
I'm having a strange problem that's driving me crazy! The task in hand is to start one set of files during the first login of "root" user and another set of files during the second login of the same user. I decided to use the ".profile" and ".bashrc" files and to reload the ".bashrc" file towards the end of the task happening during the first login. During the first login, I create a private key and certificate signing request, and call an API to get the certificate. I store this certificate and private key in a file location and then modify the ".bashrc" to invoke the second set of files,

ECC private key is longer than public key

旧城冷巷雨未停 提交于 2019-12-02 07:44:51
I have generated ECC public and private key using secp192r1 curve. I get 75 for public and 125 for private encoded key array length. Why private key is longer than public key? Why private key is not longer two times than public? Why private key is not 192 bits = 24 bytes because of secp192r1? Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); ECNamedCurveParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("secp192r1"); KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC"); g.initialize(ecSpec, new SecureRandom()); KeyPair pair = g.generateKeyPair()

Why do I have to create a certificate request (CSR) from the private key?

女生的网名这么多〃 提交于 2019-12-02 04:42:56
问题 I am trying to create a Certificate Request (CSR) from the below method where I need to give the private key, my understanding is that CSR needs/contains only the public key information with the other details about the requestor like Company Name, etc. But if extract the public key and pass while creating the CSR it throws the below error, So I am wondering why it requires a private key , although I understand private key contains the public key as well , Is it just because the public key is