Your SlideShare is downloading. ×
0
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Cryptography for the mere mortals
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Cryptography for the mere mortals

1,138

Published on

Cryptography in PHP, focusing newbies to mediocre

Cryptography in PHP, focusing newbies to mediocre

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,138
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
36
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • H
  • H
  • H
  • H
  • H
  • H
  • H
  • H
  • H
  • H
  • Plaintext The initial unencrypted (unscrambled) data to be communicated. CiphertextPlaintext is encrypted (scrambled) into something unintelligible – ciphertext for communication Example: “esqbsuibqsbujnebt” Encryption The process of converting ordinary information ( plaintext ) into ciphertext . Decryption The reverse process of moving from unintelligible ciphertext to plaintext . Cipher Pair of algorithms performing encryption & decryption. Key A secret parameter for the cipher algorithm. Key Management Management of generation, exchange, storage, safeguarding, use, vetting, and replacement of keys. Provisions in Cryptosystem design, Cryptographic protocols in that design, User procedures, and so on. Crypto Analysis / Code Breaking The study of how to circumvent the confidentiality sought by using encryption.
  • To check if a given $password string is valid, for a given hash, you can use the following condition:If($hash==crypt($password,$hash)) echo ‘valid’;
  • Advanced encryption standard
  • H
  • H
  • H
  • H
  • H
  • H
  • H
  • H
  • H
  • H
  • H
  • H
  • H
  • rand() predictablea cryptographically strong random number in PHP you have to use the function openssl_random_pseudo_bytes() of the OpenSSL library, available at PHP 5.3
  • DES cipher uses 56-bit key, that means the key space is 2^56.
  • Transcript

    • 1. julius caesar : caesar cipherkey = 3
    • 2. julius caesar : caesar cipherkey = 3hasin = kdvlq
    • 3. rise of the machines
    • 4. cryptography in bangla way
    • 5. !@#$%^&* The science of writing in secret code
    • 6. daily cryptographySSLSession/Cookie EncryptionStoring Sensitive InformationSecure Message TransportationSigning Documents
    • 7. terms Plaintext Key Cipher Encryption Ciphertext Decryption
    • 8. techniques Symmetric Cryptography = shared secret key Asymmetric Cryptography = public key + private key Hash Cryptography = One way
    • 9. cryptography in PHP cracklib hash mCrypt openSSL mHash
    • 10. one way journey md5 sha1 Sha2  Sha 256  Sha 512
    • 11. problems of MD5/SHA1 Collision Attack  hash(data1) = hash(data2)
    • 12. why salt?
    • 13. password!Use a salt value in hash functions or bcrypt hash( $salt . $password ); hash_hmac( ‘sha512’, $salt . $password ); crypt($password , $salt );
    • 14. symmetric encryption One single key Shared between parties Popular
    • 15. sample encryption - AES…$ivlength = mcrypt_get_iv_size( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);$iv = mcrypt_create_iv( $ivlength, MCRYPT_RAND);
    • 16. sample encryption - AES$encryptedText = mcrypt_encrypt( MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_CBC, $iv);
    • 17. sample decryption – AES$decryptedText = mcrypt_decrypt( MCRYPT_RIJNDAEL_256, $key, $encryptedText, MCRYPT_MODE_CBC, $iv);
    • 18. asymmetric encryption public / private key semi-shared
    • 19. meet with bob and alice
    • 20. bob and alice’s storyBob Asks Alice For her public keyBob signs msg with the public key of AliceAlice gets encrypted msgAlice decrypts msg with her secret private keyAlice reads It
    • 21. public/private key encryption RSA openSSL
    • 22. RSA key-pair ssh-keygen –t RSA –b <bit>Generating public/private rsa key pair.Enter file in which to save the key (/Users/hasinhayder/.ssh/id_rsa): /tmp/pk_rsaEnter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /tmp/pk_rsaYour public key has been saved in /tmp/pk_rsa.pub
    • 23. RSA key to PEM formatopenssl rsa -in pk_rsa -outform pem > pk_rsa.pem
    • 24. generate RSA key in PEM format openssl genrsa -des3 -out pk_rsa.pem 2048
    • 25. public key out of PEM fileopenssl rsa -pubout -in pk_rsa.pem -out pk_pub.pem
    • 26. encrypt with public key$pub_key=openssl_get_publickey( file_get_contents("/tmp/pk_pub.pem"));$enc= openssl_public_encrypt( $source, $crypttext, $pub_key);
    • 27. decrypt using private key…$passphrase = “<secret passphrase>";$key = openssl_get_privatekey( file_get_contents("/tmp/pk.pem"), $passphrase);
    • 28. decrypt using private key$dec=openssl_private_decrypt( $decoded_source, $newsource, $res);
    • 29. there are always some bad guys…
    • 30. best practices PCI DSS Compliance
    • 31. best practicesAES (RIJNDAEL)BLOWFISHTWOFISHSHA-256, 384, 512RSA
    • 32. random!rand()mt_rand()openssl_random_pseudo_bytes()
    • 33. key space Secret key space >= 128 bit Public key space >= 2048 bit
    • 34. thanks M A Hossain Tonu Sr. Software Engineer, somewherein… http://mahtonu.wordpress.com Hasin Hayder Founder, Leevio http://hasin.wordpress.com

    ×