João Paulo Nunes
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Logbook for Lab 05 ## Purpose This labs purpose is to improve your understanding of the RSA algorithm by going through all the essential steps of the RSA algorithm in real numbers, applying the learned theories. ## Task 1: Deriving the Private Key To calculate the private key, this program was created in C: ```c= #include <stdio.h> #include <openssl/bn.h> #define NBITS 128 void printBN2(char *msg, BIGNUM *a, BIGNUM *b) { char *number_str_a = BN_bn2hex(a); char *number_str_b = BN_bn2hex(b); printf("%s (%s,%s)\n", msg, number_str_a, number_str_b); OPENSSL_free(number_str_a); OPENSSL_free(number_str_b); } void printBN(char *msg, BIGNUM *a) { char *number_str_a = BN_bn2hex(a); printf("%s %s\n", msg, number_str_a); OPENSSL_free(number_str_a); } int main(){ // init BN_CTX *ctx = BN_CTX_new(); BIGNUM *p = BN_new(); BIGNUM *q = BN_new(); BIGNUM *n = BN_new(); BIGNUM *e = BN_new(); BIGNUM *p_1 = BN_new(); BIGNUM *q_1 = BN_new(); BIGNUM *phi = BN_new(); BIGNUM *prime = BN_new(); BIGNUM *d = BN_new(); // assign value BN_hex2bn(&p, "F7E75FDC469067FFDC4E847C51F452DF"); BN_hex2bn(&q, "E85CED54AF57E53E092113E62F436F4F"); BN_hex2bn(&e, "0D88C3"); // Public key n = pq BN_mul(n, p, q, ctx); printBN2("Public Key is ", e, n); // phi(n) = (p-1)(q-1) BN_sub(p_1, p, BN_value_one()); BN_sub(q_1, q, BN_value_one()); BN_mul(phi, p_1, q_1, ctx); // check if "e" and phi is relatively prime BN_gcd(prime, phi, e, ctx); if (!BN_is_one(prime)) { printf("Error: e and phi(n) is not relatively prime! \n "); exit(0); } // Calculate Private key BN_mod_inverse(d, e, phi, ctx); printBN("Private Key is ", d); } ``` After running the created program, we managed to get the private key. ![](https://i.imgur.com/XODlEcl.png) ## Task 2: Encrypting a Message We need to convert this ASCII string ("A top secret!") to a hex string, and then convert the hex string to a BIGNUM using the hex-to-bn API BN_hex2bn(). Converting the string to hexadecimal: ``` python -c 'print("A top secret!".encode("hex"))' 4120746f702073656372657421 ``` To encrypt the message we created the following code: ```c= #include <stdio.h> #include <openssl/bn.h> void printBN(char *msg, BIGNUM *a) { char *number_str_a = BN_bn2hex(a); printf("%s %s\n", msg, number_str_a); OPENSSL_free(number_str_a); } int main() { BN_CTX *ctx = BN_CTX_new(); BIGNUM *n = BN_new(); BIGNUM *e = BN_new(); BIGNUM *M = BN_new(); //encrypt variable BIGNUM *C = BN_new(); // provided values BN_hex2bn(&n, "DCBFFE3E51F62E09CE7032E2677A78946A849DC4CDDE3A4D0CB81629242FB1A5"); BN_dec2bn(&e, "65537"); //decimal // message "A top secret!" BN_hex2bn(&M, "4120746f702073656372657421"); // encrypt message M: M^e mod n BN_mod_exp(C, M, e, n, ctx); printBN("Encryption message:", C); return 0; } ``` By running the program we get the encrypted message: ![](https://i.imgur.com/CzFTniG.png) ## Task 3: Decrypting a Message Using the same public and private keys as in task 2, let's now decrypt the ciphertext C, and convert it back to a plain ASCII string. `C = 8C0F971DF2F3672B28811407E2DABBE1DA0FEBBBDFC7DCB67396567EA1E2493F` To decrypt the ciphertext C and get the hexadecimal string, we create the following program: ```c= #include <stdio.h> #include <openssl/bn.h> void printBN(char *msg, BIGNUM *a) { char *number_str_a = BN_bn2hex(a); printf("%s %s\n", msg, number_str_a); OPENSSL_free(number_str_a); } int main() { BN_CTX *ctx = BN_CTX_new(); BIGNUM *n = BN_new(); BIGNUM *M = BN_new(); BIGNUM *d = BN_new(); BIGNUM *C = BN_new(); // provided values BN_hex2bn(&n, "DCBFFE3E51F62E09CE7032E2677A78946A849DC4CDDE3A4D0CB81629242FB1A5"); BN_hex2bn(&d, "74D806F9F3A62BAE331FFE3F0A68AFE35B3D2E4794148AACBC26AA381CD7D30D"); // message crypt BN_hex2bn(&C, "8C0F971DF2F3672B28811407E2DABBE1DA0FEBBBDFC7DCB67396567EA1E2493F"); // decrypt C: C^d mod n BN_mod_exp(M, C, d, n, ctx); printBN("Decryption message:", M); return 0; } ``` Thus obtaining the hexadecimal string: ![](https://i.imgur.com/iAuDRxy.png) Now converting the hexadecimal string back to a simple ASCII string. ![](https://i.imgur.com/zAYBLpr.png) ## Task 4: Signing a Message In order to sign a message we first need to calculate the cipher with the algorithm used in the previous task. We calculate the hexadecimal values for the messages using: ``` python -c 'print("I owe you $2000".encode('utf-8').hex())' 49206f776520796f75202432303030 ``` The hexadecimal value for the message "I owe you $2000" is `49206f776520796f75202432303030` And, ``` python -c 'print("I owe you $3000".encode('utf-8').hex())' 49206f776520796f75202433303030 ``` The hexadecimal value for the message "I owe you $3000" is `49206f776520796f75202433303030` With this values we calculate the signature for each message using this code ```c= BN_CTX *ctx = BN_CTX_new(); BIGNUM *n = BN_new(); BIGNUM *e = BN_new(); BIGNUM *M = BN_new(); BIGNUM *d = BN_new(); BIGNUM *c = BN_new(); BN_hex2bn(&n, "DCBFFE3E51F62E09CE7032E2677A78946A849DC4CDDE3A4D0CB81629242FB1A5"); BN_hex2bn(&e, "010001"); BN_hex2bn(&M, "4120746f702073656372657421"); BN_hex2bn(&d, "74D806F9F3A62BAE331FFE3F0A68AFE35B3D2E4794148AACBC26AA381CD7D30D"); BIGNUM *signature = BN_new(); // I owe you $2000 BN_hex2bn(&M, "49206f776520796f75202432303030"); BN_mod_exp(signature, M ,d , n, ctx); printBN("Signature for $2000 = ", signature); printf("\n"); //I owe you $3000 BN_hex2bn(&M, "49206f776520796f75202433303030"); BN_mod_exp(signature, M ,d , n, ctx); printBN("Signature for $3000 = ", signature); printf("\n"); ``` Signatures: ![](https://i.imgur.com/N5q3XPd.png) ## Task 5: Verifying a Signature To verify the signature of the message we use inverse operation of the method used in the previous task: ```c= BIGNUM *S = BN_new(); /* M = Launch a missile. Hex = 4c61756e63682061206d697373696c652e S = 643D6F34902D9C7EC90CB0B2BCA36C47FA37165C0005CAB026C0542CBDB6802F e = 010001 (this hex value equals to decimal 65537) n = AE1CD4DC432798D933779FBD46C6E1247F0CF1233595113AA51B450F18116115 */ BN_hex2bn(&n, "AE1CD4DC432798D933779FBD46C6E1247F0CF1233595113AA51B450F18116115"); BN_hex2bn(&e, "010001"); BN_hex2bn(&M, "4c61756e63682061206d697373696c652e"); BN_hex2bn(&S, "643D6F34902D9C7EC90CB0B2BCA36C47FA37165C0005CAB026C0542CBDB6802F"); BN_mod_exp(c, S, e, n, ctx); printBN("M given = ", M); printBN("M obtained =", c); ``` Using the code above we obtain a M equal to the one provided: ``` M given = 4C61756E63682061206D697373696C652E M obtained = 4C61756E63682061206D697373696C652E ``` Simulating an error in the Signature by changing the last 2 bytes from `2F` to `3F`. ```c= BN_hex2bn(&S, "643D6F34902D9C7EC90CB0B2BCA36C47FA37165C0005CAB026C0542CBDB6803F"); BN_mod_exp(c, S, e, n, ctx); printBN("M given = ", M); printBN("M obtained =", c); ``` ``` M given = 4C61756E63682061206D697373696C652E M obtained = 91471927C80DF1E42C154FB4638CE8BC726D3D66C83A4EB6B7BE0203B41AC294 ``` Has we can see the M obtained is cleary different than the one provided. We can conclude that even a single byte change in a signature produces massive difference in the decrypted message obtained. ## Task 6: Manually Verifying an X.509 Certificate ### Step 1: Download a certificate from a real web server For this step we downloaded a certificate from `www.santander.pt:443` using the following command: ```bash openssl s_client -connect www.santander.pt:443 -showcerts > santander.txt ``` This gave us the following text: ``` CONNECTED(00000003) --- Certificate chain 0 s:C = ES, ST = Cantabria, L = Santander, jurisdictionC = ES, O = "Grupo Santander (Banco Santander, S.A.)", businessCategory = Private Organization, OU = TOTTA, serialNumber = A39000013, CN = www.santander.pt i:C = US, O = "Entrust, Inc.", OU = See www.entrust.net/legal-terms, OU = "(c) 2014 Entrust, Inc. - for authorized use only", CN = Entrust Certification Authority - L1M -----BEGIN CERTIFICATE----- MIIHZjCCBk6gAwIBAgIQUPHwvnH98PnjkgjHvl+XRjANBgkqhkiG9w0BAQsFADCB ujELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsT H1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMxOTA3BgNVBAsTMChjKSAy MDE0IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25seTEuMCwG A1UEAxMlRW50cnVzdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEwxTTAeFw0y MTA2MjQxMDM0MTlaFw0yMjA3MDExMDM0MTlaMIHaMQswCQYDVQQGEwJFUzESMBAG A1UECBMJQ2FudGFicmlhMRIwEAYDVQQHEwlTYW50YW5kZXIxEzARBgsrBgEEAYI3 PAIBAxMCRVMxMDAuBgNVBAoTJ0dydXBvIFNhbnRhbmRlciAoQmFuY28gU2FudGFu ZGVyLCBTLkEuKTEdMBsGA1UEDxMUUHJpdmF0ZSBPcmdhbml6YXRpb24xDjAMBgNV BAsTBVRPVFRBMRIwEAYDVQQFEwlBMzkwMDAwMTMxGTAXBgNVBAMTEHd3dy5zYW50 YW5kZXIucHQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDqsm+Hgm/q lMVkunZWZf8Jq5S23EgeOCt4kBZQj4IfebwD5Z+YdGuqNApKjpz6EYdReMX2HdxW mXz6XlVhvNUYavnd+Juj1MdCw6kUqzxrsmRovtfU3CAJ1m1nnXFBF8dvnQgCCM4a TwSsaMDak2Gl9AjZJNaJIxHZPO4mpVnozQnCkhEVCzx2FICUUGuLy5s1ysLp9rsR 55fiU7dnMekiokfS1ELEmZsJTJepHprJaN00a2AT9ihp14a42MQwH28inbobP3Rv UmgIeWb7bU42l1NN3XH6Tq87yKhFZkNXBKi6upaj9AfPxNbbZgmhwFKo06AkxBNz 3sINLSDKztGpAgMBAAGjggNEMIIDQDAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBSY HwAKRMi1q5cmbYKogOKKgkv66TAfBgNVHSMEGDAWgBTD99C1KjCtrw2RIXA5VN28 iXDHOjBoBggrBgEFBQcBAQRcMFowIwYIKwYBBQUHMAGGF2h0dHA6Ly9vY3NwLmVu dHJ1c3QubmV0MDMGCCsGAQUFBzAChidodHRwOi8vYWlhLmVudHJ1c3QubmV0L2wx bS1jaGFpbjI1Ni5jZXIwMwYDVR0fBCwwKjAooCagJIYiaHR0cDovL2NybC5lbnRy dXN0Lm5ldC9sZXZlbDFtLmNybDBTBgNVHREETDBKghB3d3cuc2FudGFuZGVyLnB0 ggxzYW50YW5kZXIucHSCEXNhbnRhbmRlcnRvdHRhLnB0ghV3d3cuc2FudGFuZGVy dG90dGEucHQwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggr BgEFBQcDAjBLBgNVHSAERDBCMDcGCmCGSAGG+mwKAQIwKTAnBggrBgEFBQcCARYb aHR0cHM6Ly93d3cuZW50cnVzdC5uZXQvcnBhMAcGBWeBDAEBMIIBfgYKKwYBBAHW eQIEAgSCAW4EggFqAWgAdgBWFAaaL9fC7NP14b1Esj7HRna5vJkRXMDvlJhV1onQ 3QAAAXo9lbo1AAAEAwBHMEUCIQDHp3pOWdBeV1+H1nO/RtQo1bLG6gChT2rwBHsG DJZsDwIgZNQ48AAe7YH1LKaJZ/IT8c5UyYpNw0uZMs+KcelrikwAdgBVgdTCFpA2 AUrqC5tXPFPwwOQ4eHAlCBcvo6odBxPTDAAAAXo9lbo+AAAEAwBHMEUCIDUv2rrT +4XxC4CflMn0pC47uTgC/78J4JnBUeYyZq6dAiEArbDqpQF2BCFDT/BTXy2FMqiR 2gHDa9WSLyGMCNc39LYAdgBGpVXrdfqRIDC1oolp9PN9ESxBdL79SbiFq/L8cP5t RwAAAXo9lbpZAAAEAwBHMEUCIA3/knL8uiA/m2463bQReLD1S4gGQ1BGX5y1euYF LeIvAiEAm+mhkp3yWgDapT3O/nXFYfaPCcvXh+WXjjchWAnUR6IwDQYJKoZIhvcN AQELBQADggEBAGa0Hvo19kSGLCocd/sbItQq5nCbOWR0NsoS+6Xgtfq3uf1ac6ak mO3tTXEkIuy626KbagsnpVTO6krhhlQWNKVFdRnCWIl7B02oNffhZR8qmpRaojc9 PN3L5UWxvtGUZ+jPpgQdRTgFzl1xl5LJBjVUjj+hlR8NpNqkvwTWyNn3hJeoStUo H5/KtyZImUKwsyrm4Di/bMiOruffTKPg9V7hQTHbv2L6ckEshpJJlb8t0CPq77NT VmLJnbm5hiT3Y5eokhCDZriBSrjsrDfWxtCBcRdGJ3804zn1PTzx6giHLA7yp6UI SBjHfj6DcUOTscfduYPRzMCnL3ibBREIIEU= -----END CERTIFICATE----- 1 s:C = US, O = "Entrust, Inc.", OU = See www.entrust.net/legal-terms, OU = "(c) 2014 Entrust, Inc. - for authorized use only", CN = Entrust Certification Authority - L1M i:C = US, O = "Entrust, Inc.", OU = See www.entrust.net/legal-terms, OU = "(c) 2009 Entrust, Inc. - for authorized use only", CN = Entrust Root Certification Authority - G2 -----BEGIN CERTIFICATE----- MIIFLTCCBBWgAwIBAgIMYaHn0gAAAABR02amMA0GCSqGSIb3DQEBCwUAMIG+MQsw CQYDVQQGEwJVUzEWMBQGA1UEChMNRW50cnVzdCwgSW5jLjEoMCYGA1UECxMfU2Vl IHd3dy5lbnRydXN0Lm5ldC9sZWdhbC10ZXJtczE5MDcGA1UECxMwKGMpIDIwMDkg RW50cnVzdCwgSW5jLiAtIGZvciBhdXRob3JpemVkIHVzZSBvbmx5MTIwMAYDVQQD EylFbnRydXN0IFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMjAeFw0x NDEyMTUxNTI1MDNaFw0zMDEwMTUxNTU1MDNaMIG6MQswCQYDVQQGEwJVUzEWMBQG A1UEChMNRW50cnVzdCwgSW5jLjEoMCYGA1UECxMfU2VlIHd3dy5lbnRydXN0Lm5l dC9sZWdhbC10ZXJtczE5MDcGA1UECxMwKGMpIDIwMTQgRW50cnVzdCwgSW5jLiAt IGZvciBhdXRob3JpemVkIHVzZSBvbmx5MS4wLAYDVQQDEyVFbnRydXN0IENlcnRp ZmljYXRpb24gQXV0aG9yaXR5IC0gTDFNMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A MIIBCgKCAQEA0IHBOSPCsdHs91fdVSQ2kSAiSPf8ylIKsKs/M7WwhAf23056sPuY Ij0BrFb7cW2y7rmgD1J3q5iTvjOK64dex6qwymmPQwhqPyK/MzlG1ZTy4kwFItln gJHxBEoOm3yiydJs/TwJhL39axSagR3nioPvYRZ1R5gTOw2QFpi/iuInMlOZmcP7 lhw192LtjL1JcdJDQ6Gh4yEqI3CodT2ybEYGYW8YZ+QpfrI8wcVfCR5uRE7sIZlY FUj0VUgqtzS0BeN8SYwAWN46lsw53GEzVc4qLj/RmWLoquY0djGqr3kplnjLgRSv adr7BLlZg0SqCU+01CwBnZuUMWstoc/B5QIDAQABo4IBKzCCAScwDgYDVR0PAQH/ BAQDAgEGMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDATASBgNVHRMBAf8E CDAGAQH/AgEAMDMGCCsGAQUFBwEBBCcwJTAjBggrBgEFBQcwAYYXaHR0cDovL29j c3AuZW50cnVzdC5uZXQwMAYDVR0fBCkwJzAloCOgIYYfaHR0cDovL2NybC5lbnRy dXN0Lm5ldC9nMmNhLmNybDA7BgNVHSAENDAyMDAGBFUdIAAwKDAmBggrBgEFBQcC ARYaaHR0cDovL3d3dy5lbnRydXN0Lm5ldC9ycGEwHQYDVR0OBBYEFMP30LUqMK2v DZEhcDlU3byJcMc6MB8GA1UdIwQYMBaAFGpyJnrQHu995ztpUdRsjZ+QEmarMA0G CSqGSIb3DQEBCwUAA4IBAQC0h8eEIhopwKR47PVPG7SEl2937tTPWa+oQ5YvHVje pvMVWy7ZQ5xMQrkXFxGttLFBx2YMIoYFp7Qi+8VoaIqIMthx1hGOjlJ+Qgld2dnA DizvRGsf2yS89byxqsGK5Wbb0CTz34mmi/5e0FC6m3UAyQhKS3Q/WFOv9rihbISY Jnz8/DVRZZgeO2x28JkPxLkJ1YXYJKd/KsLak0tkuHB8VCnTglTVz6WUwzOeTTRn 4Dh2ZgCN0C/GqwmqcvrOLzWJ/MDtBgO334wlV/H77yiI2YIowAQPlIFpI+CRKMVe 1QzX1CA778n4wI+nQc1XRG5sZ2L+hN/nYNjvv9QiHg3n -----END CERTIFICATE----- --- Server certificate subject=C = ES, ST = Cantabria, L = Santander, jurisdictionC = ES, O = "Grupo Santander (Banco Santander, S.A.)", businessCategory = Private Organization, OU = TOTTA, serialNumber = A39000013, CN = www.santander.pt issuer=C = US, O = "Entrust, Inc.", OU = See www.entrust.net/legal-terms, OU = "(c) 2014 Entrust, Inc. - for authorized use only", CN = Entrust Certification Authority - L1M --- No client certificate CA names sent Peer signing digest: SHA256 Peer signature type: RSA-PSS Server Temp Key: X25519, 253 bits --- SSL handshake has read 3802 bytes and written 388 bytes Verification: OK --- New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384 Server public key is 2048 bit Secure Renegotiation IS NOT supported Compression: NONE Expansion: NONE No ALPN negotiated Early data was not sent Verify return code: 0 (ok) --- --- Post-Handshake New Session Ticket arrived: SSL-Session: Protocol : TLSv1.3 Cipher : TLS_AES_256_GCM_SHA384 Session-ID: 092E17B110E96A42C53877393631A6507B3E39253D6539F7D0A55C9F8DD1AF82 Session-ID-ctx: Resumption PSK: 8877BAFA943CE3FD7B28B7CA1A8046D360F87100EDB08D899F58037DE44597507B48EB26213A26A2DCE05611DB100B41 PSK identity: None PSK identity hint: None SRP username: None TLS session ticket lifetime hint: 83100 (seconds) TLS session ticket: 0000 - 00 00 68 4f 95 e5 49 b2-11 15 8b df a1 2a 11 ab ..hO..I......*.. 0010 - 56 01 bc b2 6f 4d 45 b9-28 d8 20 a4 8a f5 b5 af V...oME.(. ..... 0020 - fd 5d 9b cd ea 62 5d bc-aa af f6 3b b1 87 85 dd .]...b]....;.... 0030 - 8b 8c a4 62 dc 53 07 41-16 54 9b 38 b6 58 ca 03 ...b.S.A.T.8.X.. 0040 - 00 d9 80 63 cb c8 32 c1-89 41 93 95 6a ec af 5b ...c..2..A..j..[ 0050 - 3a b6 c1 f5 91 43 08 43-26 ca 58 33 5f bb b1 1b :....C.C&.X3_... 0060 - af bb 38 65 d4 11 c3 3d-b4 08 56 a4 8b de e7 3b ..8e...=..V....; 0070 - 06 de 96 c2 f1 92 47 98-9e 59 49 f9 b7 17 2b b3 ......G..YI...+. 0080 - ed 21 a1 d0 77 9c 4d 70-7c 97 ca e1 fd f2 57 b7 .!..w.Mp|.....W. 0090 - 77 15 a6 43 77 96 eb 67-8b ec 69 a7 7a 06 72 c8 w..Cw..g..i.z.r. 00a0 - 61 8d ef 07 ba e1 23 5f-c7 b9 c2 64 b5 68 ea c1 a.....#_...d.h.. 00b0 - 53 6b 6f 96 cc 07 8d e5-d3 d2 9a 08 fc f4 35 3f Sko...........5? 00c0 - 35 ff 40 b1 3c 69 6d 90-ff db ec 40 54 65 43 19 5.@.<im....@TeC. 00d0 - 79 22 44 9e f3 96 be 0b-a3 bc 2d 22 7f 11 05 16 y"D.......-".... Start Time: 1639075331 Timeout : 7200 (sec) Verify return code: 0 (ok) Extended master secret: no Max Early Data: 0 --- read R BLOCK --- Post-Handshake New Session Ticket arrived: SSL-Session: Protocol : TLSv1.3 Cipher : TLS_AES_256_GCM_SHA384 Session-ID: 511907D531AF795530321434CFDC7DF2D8FBA18377DAA5E676953A34C3D0348E Session-ID-ctx: Resumption PSK: D0008EF7720172350C64F9C398E5D2A331557AB86A50144AE10D5B62E1DD866EBCC0D2F0C88D6EEF192B655B7CCBFBDB PSK identity: None PSK identity hint: None SRP username: None TLS session ticket lifetime hint: 83100 (seconds) TLS session ticket: 0000 - 00 00 68 4f 95 e5 49 b2-11 15 8b df a1 2a 11 ab ..hO..I......*.. 0010 - ec ae 89 76 9a 0a f8 36-51 41 5c 81 c1 7a 60 b1 ...v...6QA\..z`. 0020 - e6 29 f5 82 8b ee a6 d0-6e fc 64 9d c3 86 4b 5c .)......n.d...K\ 0030 - 8d 00 15 6e b2 a7 29 af-27 fd 3e ac e7 51 f1 aa ...n..).'.>..Q.. 0040 - af ed 5a 58 15 08 07 de-3d b7 da d5 ce 93 6b 3c ..ZX....=.....k< 0050 - 35 10 7c 79 79 57 21 28-8f c2 f9 61 91 e4 f0 1c 5.|yyW!(...a.... 0060 - 33 16 e5 ea e9 b3 66 19-15 05 1a 99 12 5d 8b 5b 3.....f......].[ 0070 - 78 21 d4 b6 4e 3a 11 2b-b1 2a 7a ee 39 57 d0 f7 x!..N:.+.*z.9W.. 0080 - 5a ad f4 e6 09 1a 52 71-7d 77 a0 03 e8 aa 3a 49 Z.....Rq}w....:I 0090 - 73 4d 8c ed 69 32 87 fa-58 2f eb 4c f5 35 de 50 sM..i2..X/.L.5.P 00a0 - 22 2c bc 1d a6 85 5b 4e-fd a4 e1 57 93 a3 66 67 ",....[N...W..fg 00b0 - 97 2e 47 17 07 c1 de dc-e0 f2 45 4e 77 4d 47 6a ..G.......ENwMGj 00c0 - 2b 16 e8 c7 f1 be b3 b2-16 a2 56 03 68 22 93 bd +.........V.h".. 00d0 - 27 79 1b c2 48 fa 48 7a-3f 21 94 73 62 c6 85 6e 'y..H.Hz?!.sb..n Start Time: 1639075331 Timeout : 7200 (sec) Verify return code: 0 (ok) Extended master secret: no Max Early Data: 0 --- read R BLOCK closed ``` With this we created 2 files with the certificate keys given: `c0.pem` and `c1.pem` ### Step 2: Extract the public key (e, n) from the issuer's certificate We then find the `n` value of the public key using the following command: ``` openssl x509 -in c1.pem -noout -modulus Modulus=D081C13923C2B1D1ECF757DD55243691202248F7FCCA520AB0AB3F33B5B08407F6DF4E7AB0FB98223D01AC56FB716DB2EEB9A00F5277AB9893BE338AEB875EC7AAB0CA698F43086A3F22BF333946D594F2E24C0522D9678091F1044A0E9B7CA2C9D26CFD3C0984BDFD6B149A811DE78A83EF6116754798133B0D901698BF8AE22732539999C3FB961C35F762ED8CBD4971D24343A1A1E3212A2370A8753DB26C4606616F1867E4297EB23CC1C55F091E6E444EEC2199581548F455482AB734B405E37C498C0058DE3A96CC39DC613355CE2A2E3FD19962E8AAE6347631AAAF79299678CB8114AF69DAFB04B9598344AA094FB4D42C019D9B94316B2DA1CFC1E5 ``` To find the `e` value of the public key, we use the command: ``` openssl x509 -in c1.pem -text -noout > e.txt ``` This give us the following text file: ``` Certificate: Data: Version: 3 (0x2) Serial Number: 61:a1:e7:d2:00:00:00:00:51:d3:66:a6 Signature Algorithm: sha256WithRSAEncryption Issuer: C = US, O = "Entrust, Inc.", OU = See www.entrust.net/legal-terms, OU = "(c) 2009 Entrust, Inc. - for authorized use only", CN = Entrust Root Certification Authority - G2 Validity Not Before: Dec 15 15:25:03 2014 GMT Not After : Oct 15 15:55:03 2030 GMT Subject: C = US, O = "Entrust, Inc.", OU = See www.entrust.net/legal-terms, OU = "(c) 2014 Entrust, Inc. - for authorized use only", CN = Entrust Certification Authority - L1M Subject Public Key Info: Public Key Algorithm: rsaEncryption RSA Public-Key: (2048 bit) Modulus: 00:d0:81:c1:39:23:c2:b1:d1:ec:f7:57:dd:55:24: 36:91:20:22:48:f7:fc:ca:52:0a:b0:ab:3f:33:b5: b0:84:07:f6:df:4e:7a:b0:fb:98:22:3d:01:ac:56: fb:71:6d:b2:ee:b9:a0:0f:52:77:ab:98:93:be:33: 8a:eb:87:5e:c7:aa:b0:ca:69:8f:43:08:6a:3f:22: bf:33:39:46:d5:94:f2:e2:4c:05:22:d9:67:80:91: f1:04:4a:0e:9b:7c:a2:c9:d2:6c:fd:3c:09:84:bd: fd:6b:14:9a:81:1d:e7:8a:83:ef:61:16:75:47:98: 13:3b:0d:90:16:98:bf:8a:e2:27:32:53:99:99:c3: fb:96:1c:35:f7:62:ed:8c:bd:49:71:d2:43:43:a1: a1:e3:21:2a:23:70:a8:75:3d:b2:6c:46:06:61:6f: 18:67:e4:29:7e:b2:3c:c1:c5:5f:09:1e:6e:44:4e: ec:21:99:58:15:48:f4:55:48:2a:b7:34:b4:05:e3: 7c:49:8c:00:58:de:3a:96:cc:39:dc:61:33:55:ce: 2a:2e:3f:d1:99:62:e8:aa:e6:34:76:31:aa:af:79: 29:96:78:cb:81:14:af:69:da:fb:04:b9:59:83:44: aa:09:4f:b4:d4:2c:01:9d:9b:94:31:6b:2d:a1:cf: c1:e5 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Key Usage: critical Certificate Sign, CRL Sign X509v3 Extended Key Usage: TLS Web Client Authentication, TLS Web Server Authentication X509v3 Basic Constraints: critical CA:TRUE, pathlen:0 Authority Information Access: OCSP - URI:http://ocsp.entrust.net X509v3 CRL Distribution Points: Full Name: URI:http://crl.entrust.net/g2ca.crl X509v3 Certificate Policies: Policy: X509v3 Any Policy CPS: http://www.entrust.net/rpa X509v3 Subject Key Identifier: C3:F7:D0:B5:2A:30:AD:AF:0D:91:21:70:39:54:DD:BC:89:70:C7:3A X509v3 Authority Key Identifier: keyid:6A:72:26:7A:D0:1E:EF:7D:E7:3B:69:51:D4:6C:8D:9F:90:12:66:AB Signature Algorithm: sha256WithRSAEncryption b4:87:c7:84:22:1a:29:c0:a4:78:ec:f5:4f:1b:b4:84:97:6f: 77:ee:d4:cf:59:af:a8:43:96:2f:1d:58:de:a6:f3:15:5b:2e: d9:43:9c:4c:42:b9:17:17:11:ad:b4:b1:41:c7:66:0c:22:86: 05:a7:b4:22:fb:c5:68:68:8a:88:32:d8:71:d6:11:8e:8e:52: 7e:42:09:5d:d9:d9:c0:0e:2c:ef:44:6b:1f:db:24:bc:f5:bc: b1:aa:c1:8a:e5:66:db:d0:24:f3:df:89:a6:8b:fe:5e:d0:50: ba:9b:75:00:c9:08:4a:4b:74:3f:58:53:af:f6:b8:a1:6c:84: 98:26:7c:fc:fc:35:51:65:98:1e:3b:6c:76:f0:99:0f:c4:b9: 09:d5:85:d8:24:a7:7f:2a:c2:da:93:4b:64:b8:70:7c:54:29: d3:82:54:d5:cf:a5:94:c3:33:9e:4d:34:67:e0:38:76:66:00: 8d:d0:2f:c6:ab:09:aa:72:fa:ce:2f:35:89:fc:c0:ed:06:03: b7:df:8c:25:57:f1:fb:ef:28:88:d9:82:28:c0:04:0f:94:81: 69:23:e0:91:28:c5:5e:d5:0c:d7:d4:20:3b:ef:c9:f8:c0:8f: a7:41:cd:57:44:6e:6c:67:62:fe:84:df:e7:60:d8:ef:bf:d4: 22:1e:0d:e7 ``` In this file we can find the `Exponent` used in the certificate: ``` Exponent: 65537 (0x10001) ``` ### Step 3: Extract the signature from the server's certificate For this we use the following command: ```bash openssl x509 -in c0.pem -text -noout ``` Obtaining the following signature: ``` Signature Algorithm: sha256WithRSAEncryption 66:b4:1e:fa:35:f6:44:86:2c:2a:1c:77:fb:1b:22:d4:2a:e6: 70:9b:39:64:74:36:ca:12:fb:a5:e0:b5:fa:b7:b9:fd:5a:73: a6:a4:98:ed:ed:4d:71:24:22:ec:ba:db:a2:9b:6a:0b:27:a5: 54:ce:ea:4a:e1:86:54:16:34:a5:45:75:19:c2:58:89:7b:07: 4d:a8:35:f7:e1:65:1f:2a:9a:94:5a:a2:37:3d:3c:dd:cb:e5: 45:b1:be:d1:94:67:e8:cf:a6:04:1d:45:38:05:ce:5d:71:97: 92:c9:06:35:54:8e:3f:a1:95:1f:0d:a4:da:a4:bf:04:d6:c8: d9:f7:84:97:a8:4a:d5:28:1f:9f:ca:b7:26:48:99:42:b0:b3: 2a:e6:e0:38:bf:6c:c8:8e:ae:e7:df:4c:a3:e0:f5:5e:e1:41: 31:db:bf:62:fa:72:41:2c:86:92:49:95:bf:2d:d0:23:ea:ef: b3:53:56:62:c9:9d:b9:b9:86:24:f7:63:97:a8:92:10:83:66: b8:81:4a:b8:ec:ac:37:d6:c6:d0:81:71:17:46:27:7f:34:e3: 39:f5:3d:3c:f1:ea:08:87:2c:0e:f2:a7:a5:08:48:18:c7:7e: 3e:83:71:43:93:b1:c7:dd:b9:83:d1:cc:c0:a7:2f:78:9b:05: 11:08:20:45 ``` Using the command `cat signature | tr -d '[:space:]:'` on the signature value we obtain the following key: ``` 66b41efa35f644862c2a1c77fb1b22d42ae6 709b39647436ca12fba5e0b5fab7b9fd5a73 a6a498eded4d712422ecbadba29b6a0b27a5 54ceea4ae186541634a5457519c258897b07 4da835f7e1651f2a9a945aa2373d3cddcbe5 45b1bed19467e8cfa6041d453805ce5d7197 92c90635548e3fa1951f0da4daa4bf04d6c8 d9f78497a84ad5281f9fcab726489942b0b3 2ae6e038bf6cc88eaee7df4ca3e0f55ee141 31dbbf62fa72412c86924995bf2dd023eaef b3535662c99db9b98624f76397a892108366 b8814ab8ecac37d6c6d081711746277f34e3 39f53d3cf1ea08872c0ef2a7a5084818c77e 3e83714393b1c7ddb983d1ccc0a72f789b05 11082045 ``` ### Step 4: Extract the body of the server's certificate In order to view the information in the server's certificate we use the following command: ```bash openssl asn1parse -i -in c0.pem ``` Executing the command we obtain this text: ``` 0:d=0 hl=4 l=1894 cons: SEQUENCE 4:d=1 hl=4 l=1614 cons: SEQUENCE 8:d=2 hl=2 l= 3 cons: cont [ 0 ] 10:d=3 hl=2 l= 1 prim: INTEGER :02 13:d=2 hl=2 l= 16 prim: INTEGER :50F1F0BE71FDF0F9E39208C7BE5F9746 31:d=2 hl=2 l= 13 cons: SEQUENCE 33:d=3 hl=2 l= 9 prim: OBJECT :sha256WithRSAEncryption 44:d=3 hl=2 l= 0 prim: NULL 46:d=2 hl=3 l= 186 cons: SEQUENCE 49:d=3 hl=2 l= 11 cons: SET 51:d=4 hl=2 l= 9 cons: SEQUENCE 53:d=5 hl=2 l= 3 prim: OBJECT :countryName 58:d=5 hl=2 l= 2 prim: PRINTABLESTRING :US 62:d=3 hl=2 l= 22 cons: SET 64:d=4 hl=2 l= 20 cons: SEQUENCE 66:d=5 hl=2 l= 3 prim: OBJECT :organizationName 71:d=5 hl=2 l= 13 prim: PRINTABLESTRING :Entrust, Inc. 86:d=3 hl=2 l= 40 cons: SET 88:d=4 hl=2 l= 38 cons: SEQUENCE 90:d=5 hl=2 l= 3 prim: OBJECT :organizationalUnitName 95:d=5 hl=2 l= 31 prim: PRINTABLESTRING :See www.entrust.net/legal-terms 128:d=3 hl=2 l= 57 cons: SET 130:d=4 hl=2 l= 55 cons: SEQUENCE 132:d=5 hl=2 l= 3 prim: OBJECT :organizationalUnitName 137:d=5 hl=2 l= 48 prim: PRINTABLESTRING :(c) 2014 Entrust, Inc. - for authorized use only 187:d=3 hl=2 l= 46 cons: SET 189:d=4 hl=2 l= 44 cons: SEQUENCE 191:d=5 hl=2 l= 3 prim: OBJECT :commonName 196:d=5 hl=2 l= 37 prim: PRINTABLESTRING :Entrust Certification Authority - L1M 235:d=2 hl=2 l= 30 cons: SEQUENCE 237:d=3 hl=2 l= 13 prim: UTCTIME :210624103419Z 252:d=3 hl=2 l= 13 prim: UTCTIME :220701103419Z 267:d=2 hl=3 l= 218 cons: SEQUENCE 270:d=3 hl=2 l= 11 cons: SET 272:d=4 hl=2 l= 9 cons: SEQUENCE 274:d=5 hl=2 l= 3 prim: OBJECT :countryName 279:d=5 hl=2 l= 2 prim: PRINTABLESTRING :ES 283:d=3 hl=2 l= 18 cons: SET 285:d=4 hl=2 l= 16 cons: SEQUENCE 287:d=5 hl=2 l= 3 prim: OBJECT :stateOrProvinceName 292:d=5 hl=2 l= 9 prim: PRINTABLESTRING :Cantabria 303:d=3 hl=2 l= 18 cons: SET 305:d=4 hl=2 l= 16 cons: SEQUENCE 307:d=5 hl=2 l= 3 prim: OBJECT :localityName 312:d=5 hl=2 l= 9 prim: PRINTABLESTRING :Santander 323:d=3 hl=2 l= 19 cons: SET 325:d=4 hl=2 l= 17 cons: SEQUENCE 327:d=5 hl=2 l= 11 prim: OBJECT :jurisdictionCountryName 340:d=5 hl=2 l= 2 prim: PRINTABLESTRING :ES 344:d=3 hl=2 l= 48 cons: SET 346:d=4 hl=2 l= 46 cons: SEQUENCE 348:d=5 hl=2 l= 3 prim: OBJECT :organizationName 353:d=5 hl=2 l= 39 prim: PRINTABLESTRING :Grupo Santander (Banco Santander, S.A.) 394:d=3 hl=2 l= 29 cons: SET 396:d=4 hl=2 l= 27 cons: SEQUENCE 398:d=5 hl=2 l= 3 prim: OBJECT :businessCategory 403:d=5 hl=2 l= 20 prim: PRINTABLESTRING :Private Organization 425:d=3 hl=2 l= 14 cons: SET 427:d=4 hl=2 l= 12 cons: SEQUENCE 429:d=5 hl=2 l= 3 prim: OBJECT :organizationalUnitName 434:d=5 hl=2 l= 5 prim: PRINTABLESTRING :TOTTA 441:d=3 hl=2 l= 18 cons: SET 443:d=4 hl=2 l= 16 cons: SEQUENCE 445:d=5 hl=2 l= 3 prim: OBJECT :serialNumber 450:d=5 hl=2 l= 9 prim: PRINTABLESTRING :A39000013 461:d=3 hl=2 l= 25 cons: SET 463:d=4 hl=2 l= 23 cons: SEQUENCE 465:d=5 hl=2 l= 3 prim: OBJECT :commonName 470:d=5 hl=2 l= 16 prim: PRINTABLESTRING :www.santander.pt 488:d=2 hl=4 l= 290 cons: SEQUENCE 492:d=3 hl=2 l= 13 cons: SEQUENCE 494:d=4 hl=2 l= 9 prim: OBJECT :rsaEncryption 505:d=4 hl=2 l= 0 prim: NULL 507:d=3 hl=4 l= 271 prim: BIT STRING 782:d=2 hl=4 l= 836 cons: cont [ 3 ] 786:d=3 hl=4 l= 832 cons: SEQUENCE 790:d=4 hl=2 l= 12 cons: SEQUENCE 792:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Basic Constraints 797:d=5 hl=2 l= 1 prim: BOOLEAN :255 800:d=5 hl=2 l= 2 prim: OCTET STRING [HEX DUMP]:3000 804:d=4 hl=2 l= 29 cons: SEQUENCE 806:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Subject Key Identifier 811:d=5 hl=2 l= 22 prim: OCTET STRING [HEX DUMP]:0414981F000A44C8B5AB97266D82A880E28A824BFAE9 835:d=4 hl=2 l= 31 cons: SEQUENCE 837:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Authority Key Identifier 842:d=5 hl=2 l= 24 prim: OCTET STRING [HEX DUMP]:30168014C3F7D0B52A30ADAF0D9121703954DDBC8970C73A 868:d=4 hl=2 l= 104 cons: SEQUENCE 870:d=5 hl=2 l= 8 prim: OBJECT :Authority Information Access 880:d=5 hl=2 l= 92 prim: OCTET STRING [HEX DUMP]:305A302306082B060105050730018617687474703A2F2F6F6373702E656E74727573742E6E6574303306082B060105050730028627687474703A2F2F6169612E656E74727573742E6E65742F6C316D2D636861696E3235362E636572 974:d=4 hl=2 l= 51 cons: SEQUENCE 976:d=5 hl=2 l= 3 prim: OBJECT :X509v3 CRL Distribution Points 981:d=5 hl=2 l= 44 prim: OCTET STRING [HEX DUMP]:302A3028A026A0248622687474703A2F2F63726C2E656E74727573742E6E65742F6C6576656C316D2E63726C 1027:d=4 hl=2 l= 83 cons: SEQUENCE 1029:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Subject Alternative Name 1034:d=5 hl=2 l= 76 prim: OCTET STRING [HEX DUMP]:304A82107777772E73616E74616E6465722E7074820C73616E74616E6465722E7074821173616E74616E646572746F7474612E707482157777772E73616E74616E646572746F7474612E7074 1112:d=4 hl=2 l= 14 cons: SEQUENCE 1114:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Key Usage 1119:d=5 hl=2 l= 1 prim: BOOLEAN :255 1122:d=5 hl=2 l= 4 prim: OCTET STRING [HEX DUMP]:030205A0 1128:d=4 hl=2 l= 29 cons: SEQUENCE 1130:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Extended Key Usage 1135:d=5 hl=2 l= 22 prim: OCTET STRING [HEX DUMP]:301406082B0601050507030106082B06010505070302 1159:d=4 hl=2 l= 75 cons: SEQUENCE 1161:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Certificate Policies 1166:d=5 hl=2 l= 68 prim: OCTET STRING [HEX DUMP]:30423037060A6086480186FA6C0A01023029302706082B06010505070201161B68747470733A2F2F7777772E656E74727573742E6E65742F7270613007060567810C0101 1236:d=4 hl=4 l= 382 cons: SEQUENCE 1240:d=5 hl=2 l= 10 prim: OBJECT :CT Precertificate SCTs 1252:d=5 hl=4 l= 366 prim: OCTET STRING [HEX DUMP]:0482016A01680076005614069A2FD7C2ECD3F5E1BD44B23EC74676B9BC99115CC0EF949855D689D0DD0000017A3D95BA350000040300473045022100C7A77A4E59D05E575F87D673BF46D428D5B2C6EA00A14F6AF0047B060C966C0F022064D438F0001EED81F52CA68967F213F1CE54C98A4DC34B9932CF8A71E96B8A4C0076005581D4C2169036014AEA0B9B573C53F0C0E43878702508172FA3AA1D0713D30C0000017A3D95BA3E00000403004730450220352FDABAD3FB85F10B809F94C9F4A42E3BB93802FFBF09E099C151E63266AE9D022100ADB0EAA501760421434FF0535F2D8532A891DA01C36BD5922F218C08D737F4B600760046A555EB75FA912030B5A28969F4F37D112C4174BEFD49B885ABF2FC70FE6D470000017A3D95BA59000004030047304502200DFF9272FCBA203F9B6E3ADDB41178B0F54B88064350465F9CB57AE6052DE22F0221009BE9A1929DF25A00DAA53DCEFE75C561F68F09CBD787E5978E37215809D447A2 1622:d=1 hl=2 l= 13 cons: SEQUENCE 1624:d=2 hl=2 l= 9 prim: OBJECT :sha256WithRSAEncryption 1635:d=2 hl=2 l= 0 prim: NULL 1637:d=1 hl=4 l= 257 prim: BIT STRING ``` From this text we can extract the body of the certificate using the command: ```bash openssl anslparse -i -in c0.pem -strparse 4 -out c0_body.bin -nout ``` Running the command we obtain a bin file `c0_body.bin` with the body of the certificate. After this we calculate the hash value of the body using the `sha256sum` algorithm: ```bash sha256sum c0_body.bin ``` Output: ``` 793ec98a8800cb7b6ab2354a15b1b911972ac036d2607936e00aae2ffe1a5e68 c0_body.bin ``` ### Step 5: Verify the signature To calculate the body of the server using the signature and the values of e and n, we just need to change the initial valeus of these variables in the code presented in task 5: ```c= BN_hex2bn(&n, "D081C13923C2B1D1ECF757DD55243691202248F7FCCA520AB0AB3F33B5B08407F6DF4E7AB0FB98223D01AC56FB716DB2EEB9A00F5277AB9893BE338AEB875EC7AAB0CA698F43086A3F22BF333946D594F2E24C0522D9678091F1044A0E9B7CA2C9D26CFD3C0984BDFD6B149A811DE78A83EF6116754798133B0D901698BF8AE22732539999C3FB961C35F762ED8CBD4971D24343A1A1E3212A2370A8753DB26C4606616F1867E4297EB23CC1C55F091E6E444EEC2199581548F455482AB734B405E37C498C0058DE3A96CC39DC613355CE2A2E3FD19962E8AAE6347631AAAF79299678CB8114AF69DAFB04B9598344AA094FB4D42C019D9B94316B2DA1CFC1E5"); BN_hex2bn(&e, "010001"); BN_hex2bn(&M, "793ec98a8800cb7b6ab2354a15b1b911972ac036d2607936e00aae2ffe1a5e68 "); BN_hex2bn(&S, "66b41efa35f644862c2a1c77fb1b22d42ae6709b39647436ca12fba5e0b5fab7b9fd5a73a6a498eded4d712422ecbadba29b6a0b27a554ceea4ae186541634a5457519c258897b074da835f7e1651f2a9a945aa2373d3cddcbe545b1bed19467e8cfa6041d453805ce5d719792c90635548e3fa1951f0da4daa4bf04d6c8d9f78497a84ad5281f9fcab726489942b0b32ae6e038bf6cc88eaee7df4ca3e0f55ee14131dbbf62fa72412c86924995bf2dd023eaefb3535662c99db9b98624f76397a892108366b8814ab8ecac37d6c6d081711746277f34e339f53d3cf1ea08872c0ef2a7a5084818c77e3e83714393b1c7ddb983d1ccc0a72f789b0511082045"); BN_mod_exp(c, S, e, n, ctx); printBN("M given = ", M); printBN("M obtained =", c); ``` This gave us the following result: ``` M given = 793EC98A8800CB7B6AB2354A15B1B911972AC036D2607936E00AAE2FFE1A5E68 M obtained = 01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF003031300D060960864801650304020105000420793EC98A8800CB7B6AB2354A15B1B911972AC036D2607936E00AAE2FFE1A5E68 ``` At first it might seem that the value found is different than the body of the server's certificate, but with further inspection we can see that its same value only padded to meet the same number of bytes as the signature and n. ![](https://i.imgur.com/dscwxfj.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully