Comments (4)
For example, my public key (also found at https://api.github.com/users/hadley/keys) is:
pubkey <- "-----BEGIN PUBLIC KEY-----
MIIBIDANBgkqhkiG9w0BAQEFAAOCAQ0AMIIBCAKCAQEAy/i7l7DZon6YFnZfXg/H
+BnYDOG9CkHWtSxKXLiAlygl7kqF5tTeUHapMFCnkE1OLFOCGJCFT2PCi/Yipc2Y
AMghko/jcPT8Qa1hQaY+z4ErTqt6DllI7OZkakhphV96q9gUxcln2WXWU/6MD7H3
yetn60b5xH53SSVDfu1mSwosiaxio8aeIv84cIrjg4yUeKsUYOjkr3bNmkx478LV
q2y3aj//OpemfEVyp0BHpx8govAitKVU+p4z/4t/o4T0W8mAsqs9M1O6MYFthC+W
6FuvR61cYo40qO4YZ3jcRgzGCWgXuZWG4RvwNM+BEY9BGvEWLcjtplntnfeSyOCA
uQIBIw==
-----END PUBLIC KEY-----"
parsed <- PKI::PKI.load.key(textConnection(pubkey))
der <- PKI::PKI.save.key(parsed, "DER")
PKI::PKI.digest(key, "MD5")
# [1] 82 3b 28 6f 24 1a c5 0b 77 c6 4d ed 26 4b a8 c4
but github tells me my finger print is ff:1d:8e:1c:af:f9:02:f7:6e:55:ca:cd:22:c4:5b:e6
from pki.
It is the MD5 hash of the SSH-encoded key (in binary form) - so for your key
> q = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvPJWA/qBXtSCwvYopyXdD28C4pC2PBm3GZOoZ4XxGm4UIKZWp+bJRfGEpfY+1peX8xFNy6V4bEoGkr2wNWFqP1aBdfEwlSKBdNskIsV2CCx1TRWZKvnauDtehfOJ5a7bTiHwzHYJVrnjNJbqi6VX8XqSF29uz5eDw7F1J+nZp5mHokvqQabJkNoacSDaLISKa/ig6EHSVKOrww+qf1hOlM8UmW0Cro/+v6VhNdguCdx+ByDICAoJzWGM2JuXLMOTZjADwkUpPJ5aNLQlgknUBK/WPXtpTbp/LAsHRhsmeJjr8FP3R3z4XhvDokeap7eFRQmLo6n4I8uBO3Vy9LqmVQ=="
> PKI.digest(base64decode(strsplit(q, " ", TRUE)[[1]][2]),"MD5")
[1] ff 1d 8e 1c af f9 02 f7 6e 55 ca cd 22 c4 5b e6
Since we don't provide PKI.save.key
in OpenSSH format it's a bit legwork to get it from raw keys, but possible:
> k <- PKI.load.OpenSSH.pubkey(q, format="key")
> der <- PKI.save.key(k, "DER")
> PKI.digest(unlist(lapply(c(list(charToRaw("ssh-rsa")), ASN1.decode(ASN1.decode(der)[[2]])[2:1]), function(o) c(writeBin(length(o), raw(), endian="big"), o))), "MD5")
[1] ff 1d 8e 1c af f9 02 f7 6e 55 ca cd 22 c4 5b e6
Note: your key in pubkey
above is not your github key.
BTW:the above would be much simpler if we had a way to get exp/mod from keys - sounds like a good idea ...
from pki.
Thanks Simon, that's super helpful.
I generated pubkey
key from my the github public key using PKI.load.key and PKI.save.key - should I not expect to get the same key back? (albeit represented in a different way). Or have I made a silly mistake somewhere?
key <- "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvPJWA/qBXtSCwvYopyXdD28C4pC2PBm3GZOoZ4XxGm4UIKZWp+bJRfGEpfY+1peX8xFNy6V4bEoGkr2wNWFqP1aBdfEwlSKBdNskIsV2CCx1TRWZKvnauDtehfOJ5a7bTiHwzHYJVrnjNJbqi6VX8XqSF29uz5eDw7F1J+nZp5mHokvqQabJkNoacSDaLISKa/ig6EHSVKOrww+qf1hOlM8UmW0Cro/+v6VhNdguCdx+ByDICAoJzWGM2JuXLMOTZjADwkUpPJ5aNLQlgknUBK/WPXtpTbp/LAsHRhsmeJjr8FP3R3z4XhvDokeap7eFRQmLo6n4I8uBO3Vy9LqmVQ=="
parsed <- PKI::PKI.load.OpenSSH.pubkey(key, format = "key")
PKI::PKI.save.key(parsed)
from pki.
Probably some copy/paste issue - the key generated with the above is indeed your GitHub key and it shows the correct fingerprint -- but it is not identical to the pubkey
in your original post on top.
from pki.
Related Issues (20)
- Default print method HOT 1
- Encrypted connections HOT 1
- PKI crashes HOT 6
- PKI.encrypt gives different results each time I call it HOT 2
- Read private key protected by passphrase HOT 2
- package doesn't load google apps credentials (rsa private key) HOT 6
- Add IV API in CBC mode so IV can be set HOT 7
- Install: 'openssl/err.h' file not found HOT 18
- PKI fails to install using OpenSSL 1.1.0 or higher HOT 5
- OpenSSL 1.1 problem HOT 7
- Encrypt RSA private key
- Compilation failure on Arch HOT 1
- PKI "configure: error: Cannot find usable crypto library" HOT 5
- checking for library containing RSA_generate_key_ex... no HOT 1
- openssl 3.x removed Blowfish
- Debian failure in C.UTF-8
- compression detection can fail for XZ in tar signing HOT 1
- Generate random keys? HOT 3
- PKI.encrypt(): missing padding block when last block is full HOT 2
- More informative error messages HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pki.