I was recently examining a file containing cleartext, then under the cleartext:
This is cleartext. A message presumably signed with the below certificate.
-----BEGIN CERTIFICATE-----
Proc-Type: 4,ENCRYPTED
Modulus: 31353732
DEK-Info: DES-CBC,656e733333
MIIBwcHBwcHBwcHAAgAAAcIAAAIAAAAAAAyZjAwMDAwMDAwZjAwMDBmMDAwMDAwM
DBmMDAwMDBmMGgwMDAwMDAwMGYwMGYwMGYwMDAwMGZmMDAwMDAwMDBmegAICGUHm
QBxb3mYbXBveW2ZcZYHaW9hAKoulAeZU29sU2+jAKougQCUcZZnmXGYB4JxlnmVU
G0HZ6pngi6XB3OCcZVxZ6oulXGUZ4J5lXGUB3lvaYFxlgeVZZd5l1BtM5Z5lWeUe
ZdQbXGZLoEAlHGWZ5lxmAeCZ4IubW9ncAB4cZZnmXGYB4JxmGeYKaopqnGYZ4Epq
gCWcZhngQCYeWmqa6pQbXmXLmeqeZdQbXGZLoEAlHFlb3CZZ5lxmAeCbIEAlHGWZ
5lxmAeCZZh5l2WUB5lngnmVB5dllnGVcWc4mHmVB4FllmWYZ5lxgnmXUG1xmS6BA
JRxlmeZcZgHgneBAJRxlmeZcZgHgnGVB5cHAKoAmC6Z5W9xLplnAKptd2uqcZYul
weWAJhQbQdnqmVnqnmXUG1xmS6BAJRxlmd5B5hxmHmXUG1xmS6BAJRxlmeZcZgHg
nGWB5Vll3mVcXJQbQdnqgeWB2eqZ4Iuly6WKapQbQdnqmVnqnmXUG1xNACUcZl5l
1BtcZkugQCUcZZnmXGYB4JxlgeVcZl5lXFmcZh5lWWXeQCqZ4Iul2WZB5YHZ6png
i6XZWeqeZdQbW9xlnmVLmeqeZdQbXGZLoEAlHGWZ5lxmAeCcZYHlS6Wb5gHglBtB
2eqB5YpqlBtB5UHlmuqcZYul2VnqnmXUG1ignGYB5UuZ6p5l1BtcZkugQCUcZZnm
XGYB4JxlgeVcTCZcZgHgnGYLpcHlmuqcZYulweWa6pxli6XZZd5l1BtOXGYB2eqZ
Zh5l1BtcZkugQC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through bruteforce, could the original secret key be found and the encrypted data be decrypted to cleartext? How about re-encrypted to yield the same encrypted text?
Related
i'm trying to connect esp32 to firestore but an error appear on the serial monitor
Token info: type = OAuth2.0 access token, status = error
Token error: code: -116, message: mbedTLS, mbedtls_pk_parse_key: PK - Invalid key tag or value
i'm using source code from https://github.com/mobizt/Firebase-ESP-Client/blob/main/examples/Firestore/ImportDocuments/ImportDocuments.ino
Most likely you've not provided the private key string correctly (TLS libraries are rather picky about that), or the private key is not in correct format.
E.g. this is how you generate a 2048 bit RSA keypair in PKCS8 format (which is what the sample code appears to use):
$ ssh-keygen -t rsa -b 2048 -m PKCS8 -f testkey
This is how you add the resulting private key as a multiline raw string literal in C++:
const char PRIVATE_KEY[] = R"(-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDhhA52G0UQGFk5
+WDGpWXgVHR6Bjpyq81HZ0SI9PQYTZa87b4qOysL8QkpeXiUR5Ltza1A5ceLERfy
2fpwhLIdHDmFN9dYQIN7ODf8dPRFVPT9ABegHDGzNWQJBuDe9ffVfF8DYeSlo7iq
vKUSeL2IpbTFn7Ccard68Wee3GueIm0GVi6V/HKhJYT4Cq6Fp8g/xVMdwAD6AFR8
8vBH1FERJn+6U89xdgewnjrw69jhlctziIdDxANedqTX/aEkchKcFhhmXehwsFfn
3gdToJBu0fClaTUvm0tYMRLaoUfAQ9t6J9TtPkA3ZZFzge7FZGl3lpFd6NOiiiQD
Fi9NLXx7AgMBAAECggEANNV1deIpqf2qWdS9AY0acxYWO8hdxSPO8h2Vhuisj00O
NbEVTluSWDfeR6M3xrWGDMSVBJFQ0JnunGzJKbdM61kDeNx+TSTAKQwgwbq8x8mB
pAxzfIVed3fYueysnk/OAmwi7m3u3Yef6hBMNCmpbew0j+A7xkmSNvF7r1JAvEkv
wnRy4GY9+39HHotF0T2BofdmxA0i5hS7NQc5AxJ+O9xVB4qoUCoPDXsOXfQoGURe
ugR7ANSONwIbnfSkcTanoMeqaQeSpLe+cNlBKTG+ofQyOsM2vSbPndUNx+CerLPe
Jya+/owBgYCTeOG+E+Bs05God/y/HuX5hUJVHSQHIQKBgQD7Z9XFf6Ecs8oGHx6g
D4qWNxLolB9Ls6W9MkXrrTcPMWQJIbYM2RxNLVjdArVLDT7yUHUH/KWx/Qrd9x5P
g8H8htO2vSHJRBpFbxL5wYudsh6G38GOs65OEcjKMWryzet44bRPe9zkULbfqiwy
5KOyi4VoUc63HeiKTJbHaTwWaQKBgQDloxmU22G7Vno7BhmReH4veZ+yV2jnX8Uc
cp4ciq7XqPZNUMKTskmrLl6Lw9I2xY8ahdP0kYWB6CKJr9DF8TN09n4NN2yLz89o
mHowHCdsyjE51l7lmkdHSxCOVt+Wt4vsoegZAydm8mtAfA0W63tgMDgKpCyqtn/H
vl6v08jHQwKBgQDwtO48doKvlIRtcAZGghrS0FBOVuPP+2VIzIWdrO72oPeCtsAz
dPxf+HcIxLsH7NrD7rzetMuAqyJoe16OCz0Ep6K1aEidB5OPv1WPw/wFNLF9uWb9
VpQhM23oCYC4kOhPiOq234UTJSSy6Z//6mHBZUyKISmmsgAfykzjCKL7YQKBgDNQ
qCXIhGVtpLDN4ybLyz7mqdYbjFiv4QdDYau1He8ZVbjfRCvnGmlDWmNXJgGRUjI2
F7A+WJw3+IfWHwwsozgO4QopCXuQu6N+90cK85Bu+mMXUWtzd1wqHRABv8MZTw5Y
+9mjB8oMgAUP84jcpFxRSiSunUCkuZc0JkqaQ/KrAoGAYxtl+555GpXK9eLfrVOG
02czqaXssGXIi31aGTICy7Esk8OgaG+pd4brcICeYE/CQ6gDjt6m/dHcw+DFmeFX
nVDHCIIDB9SeHM0Z3wZi/JruCtoB6vTxhA5lA9QeI4TpZvYXQkuerRUzRvhxyzkV
PrYun0MrVLxiiwezSTxlyGw=
-----END PRIVATE KEY-----
)";
I have a private key that is in the following format, unfortunately I can't share the actual key, so the base64 code is masked:
-----BEGIN PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-ECB,4C425124E54FEA716FEE437A01473736
****************************************************************
****************************************************************
****************************************************************
****************************************************************
****************************************************************
****************************************************************
****************************************************************
****************************************************************
****************************************************************
****************************************************************
****************************************************************
****************************************************************
****************************************************************
**********************==
-----END PRIVATE KEY-----
So I have little application that comes from 2010, written by Huawei called CardManufactureFileDecrypt that uses the private key, a certificate and the password / passphrase to successfully decrypt files that contain vouchers, so from that I can deduce that the file is intact, also that the password or passphrase I have is correct.
So my question is does anyone know how to read an encrypted private key in the form of BEGIN PRIVATE KEY? Or perhaps what libraries from about 10 years ago would have produced / consumed keys in this style?
When I try to read the private key with openssl I get the following error(s):
$ openssl rsa -in PrivateKey_E8.p8 -out PrivateKey_E8_unencrypted.p8
unable to load Private Key
139978370384320:error:0906B082:PEM routines:PEM_get_EVP_CIPHER_INFO:unexpected dek iv:../crypto/pem/pem_lib.c:551:
Or:
$ openssl pkcs8 -in PrivateKey_E8.p8 -out PrivateKey_E8_unencrypted.p8
Error reading key
140719466078656:error:0909006C:PEM routines:get_name:no start line:../crypto/pem/pem_lib.c:745:Expecting: ENCRYPTED PRIVATE KEY
I have a public/private GPG keypair. When I try to gpg --import either the public or the private key, only the public keyring is updated:
[root#ip-10-24-5-35 ~]# gpg --list-keys
/root/.gnupg/pubring.gpg
------------------------
pub 4096R/A6E928B1 2018-07-02
uid saids_ftp (some description) <said#example.com>
sub 4096R/5010A53E 2018-07-02
[root#ip-10-24-5-35 ~]# gpg --list-secret-keys
[root#ip-10-24-5-35 ~]#
Later, when I try to decrypt a file, I get the following output:
[root#ip-10-24-5-35 raw]# gpg --decrypt file.txt.gpg
gpg: encrypted with RSA key, ID FFAB8C83
gpg: encrypted with RSA key, ID D66EFA2A
gpg: encrypted with RSA key, ID 2FA063D3
gpg: encrypted with RSA key, ID 038D4A79
gpg: encrypted with ELG key, ID D5D81FBC
gpg: encrypted with RSA key, ID 45ED8372
gpg: encrypted with RSA key, ID CC1446EE
gpg: encrypted with 4096-bit RSA key, ID 5010A53E, created 2018-07-02
"saids_ftp (some description) <said#example.com>"
gpg: encrypted with RSA key, ID 75BB9DFE
gpg: encrypted with RSA key, ID B2ECF5E4
gpg: encrypted with ELG key, ID 2AD775F8
gpg: encrypted with RSA key, ID B5F82E2E
gpg: encrypted with RSA key, ID D8098B00
`enter code here`gpg: decryption failed: No secret key
Is there something wrong with my private key? I'm not sure how I exported it in the past, as the server that the key was created on is no longer available.
I try to deploy a datapower inside IPC with the following parameter
{
"ibm-datapower-dev": {
"name": "ibm-datapower-dev",
"crypto.frontsideCert": "-----BEGIN CERTIFICATE REQUEST----- MIICijCCAXICAQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUx ITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDCCASIwDQYJKoZIhvcN AQEBBQADggEPADCCAQoCggEBAK2cJ7rtqGPsFoFNLjOQ08knGO429u+EdIEPiXvc nvumhIoSmOquUOzyIOqPCY35Wso2EjS97dH3Qa+X8Qo8L6FfmWDBn4C6RWVPxxh1 a2P0TM1eSzPP/bVU0yghgdgPkU6jYfA0OmnBN3KOHl39gc86cI8tXUxstnlACzv+ me1RKmvMfy+IE3C0qBvvPjhNjIU4vx9OJ/DaxMh2shJxHlt718mZTCy/fAqE5bc5 19Atxy7aPD9LFWQ6/mGbnLzH8l4MqrZYFkVkZx8h3uYt3eyN0co4FicBuGtgs97s VcpZz9tC2yFEi25Iql+AdGuaK+hMNU2pF5GdNaARlyLjemECAwEAAaAAMA0GCSqG SIb3DQEBCwUAA4IBAQBvGtz0xYQOX1SqTdutLLKSJdlUt3jin3NoEvvDKAHhmpnc DDMfamqM4wjXb1JlTQKSHAdgLB/KHMgJPlb4pn9pHVCsZ9cEwz0Qz0oGPyr/rmYC IZRfmImqKdDLDhVWyK8GLv6cYwQEkuRMzytXX8DMcJcWRXuJj3cuyVGQ7BKxSnl7 0U9pbUb8mNwcvJnZfsfL4AIQR2//No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KiSGaX1V3qvmASoz1Vj4wMcCgYEAxzK+ 1YngK9Jc4JgJMYqkfRHKwjBq99CzKJHKtXzaHVqcFmH2OqmwGWb4t0DyQsi5PKVM u4OFS3/vgSKpEwem94dB6OwuAioeX6pSkYW4qGLhOm9V9iPrjg/Q4v5+ym6iNMB+ 0CZdeR1TGI1qLFkv8ziSdN1K2Ycv2fYGSRpNE5cCgYEAgTG2M4C39e1DlDOYgTCt xWHTFslQJzk4RNVtQyHaoLrzSj21E7oAIgvJ6y8YnoXyeqiedTDwY9QfAhmqGRzZ P2kaKszBxz/EnkifNZCpi560Ibag63I57EZ69EPBprg6bI4bgZzStjtJoI8rXRHC aKq/vkPaPlcxl0kVvJuJZy8CgYEApqw7KQl4XLJjrDkKWD2dbFjawqkol7o0bhmu 9zREfJM4TzIgiO06v8Z9DTh2fJLfC3N0ROHDQm0FxZNuzNF2T18JMw+LX5xGVd15 wPGWlK5HrlFCJ/XePrvVGFnBVThE2MbIVPoE9DYpNT3+PKVTjbskMEyJOIH48/L7 R2eOXnkCgYBRCjh9ns9PSneKWGfz+ymlB0b4kCZBU69Q3ladgN50oxG6QmiccObT EXEeUl+XqhlhyR7MeNSz7IUugHSVKqpa2fGFTQ3Uk7k6QslSXHcJFl3HBjK/Ejcc H8zB9FPVe1gOqeK2HBnThC7zWOseGrBMWhyeH2cNdGXnw+dexWUTig== -----END RSA PRIVATE KEY-----",
"datapowerEnv.workerThreads": "4",
"image.pullPolicy": "IfNotPresent",
"image.repository": "ibmcom/datapower",
"image.tag": "7.6.0",
"patternName": "webApplicationProxy",
"replicaCount": "1",
"resources.limits.cpu": "4",
"resources.limits.memory": "8Gi",
"resources.requests.cpu": "2",
"resources.requests.memory": "4Gi",
"service.name": "datapower",
"service.type": "NodePort",
"webApplicationProxy.backendURL": "https://www.ibm.com",
"webApplicationProxy.containerPort": "8443"
}
}
and it failed (and no log info is available)
Just to complete info I generate the cert/key inside linux with the following command
generate key
openssl genrsa -out /tmp/hostname.key 2048
genrate cert
openssl req -new -key /tmp/hostname.key -out /tmp/hostname-2017.req
what is wrong ? where info/log is available to understand the error ?
The only way I can get the ICP GUI to accept my keys and certs is to strip out the header, footer, and line feeds. Only one continuous, encrypted string remains.
You should base64 encode the key and cert. They'll be used as a k8s secret, and those are required to be base64 encoded.
First, let's understand what these values are doing.
Each of the keys crypto.frontsideCert and crypto.frontsideKey map to values used in a Kubernetes secret. You can actually see how these values are substituted in the chart:
https://github.com/IBM/charts/blob/master/stable/ibm-datapower-dev/templates/secrets.yaml#L7-L8
And to provide a secret to Kubernetes, the value must be base-64 encoded. While the secret isn't really encrypted, it will be obscured from casual observation.
You can base64 encode these strings using base64 on your favorite linux distro:
cat /tmp/hostname.key | base64
# Outputs a large block of text, which typically ends in "==" cat
cat /tmp/hostname-2017.req | base64
# Outputs a large block of text, which typically ends in "=="
If you're ever concerned that the value in a secret isn't what you expect, you can always verify it:
echo "This is an obscured secret." | base64
VGhpcyBpcyBhbiBvYnNjdXJlZCBzZWNyZXQuCg==
echo VGhpcyBpcyBhbiBvYnNjdXJlZCBzZWNyZXQuCg== | base64 --decode
This is an obscured secret.
I need to use the PEM formatted public key for some purpose, but not finding the command which can convert DER formatted public key to PEM formatted public key.
The command I have used -
openssl rsa -in user_id_rsa.pub -inform DER -outform PEM -out pubkey.pem
But i got the below error -
unable to load Private Key
139901900170912:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1337:
139901900170912:error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 error:tasn_dec.c:677:
139901900170912:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1337:
139901900170912:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:388:Type=RSA
My expected output should be in this format-
-----BEGIN RSA PUBLIC KEY-----
KEY CONTENT
-----END RSA PUBLIC KEY-----
Is anyone has try the same?