julius caesar : caesar cipherkey = 3
julius caesar : caesar cipherkey = 3hasin = kdvlq
rise of the machines
cryptography in bangla way
!@#$%^&* The science of writing in secret code
daily cryptographySSLSession/Cookie EncryptionStoring Sensitive InformationSecure Message TransportationSigning Documents
terms Plaintext Key Cipher Encryption Ciphertext Decryption
techniques Symmetric Cryptography = shared secret key Asymmetric Cryptography = public key + private key Hash Cryptogra...
cryptography in PHP cracklib hash mCrypt openSSL mHash
one way journey md5 sha1 Sha2   Sha 256   Sha 512
problems of MD5/SHA1 Collision Attack                                              hash(data1) = hash(data2)
why salt?
password!Use a salt value in hash functions or bcrypt   hash( $salt . $password );   hash_hmac( ‘sha512’, $salt . $passwor...
symmetric encryption One single key Shared between parties Popular
sample encryption - AES…$ivlength = mcrypt_get_iv_size(     MCRYPT_RIJNDAEL_256,     MCRYPT_MODE_CBC);$iv = mcrypt_create_...
sample encryption - AES$encryptedText = mcrypt_encrypt(     MCRYPT_RIJNDAEL_256,     $key,     $data,     MCRYPT_MODE_CBC,...
sample decryption – AES$decryptedText = mcrypt_decrypt(     MCRYPT_RIJNDAEL_256,     $key,     $encryptedText,     MCRYPT_...
asymmetric encryption public / private key semi-shared
meet with bob and alice
bob and alice’s storyBob Asks Alice For her public keyBob signs msg with the public key of AliceAlice gets encrypted msgAl...
public/private key encryption RSA openSSL
RSA key-pair ssh-keygen –t RSA –b <bit>Generating public/private rsa key pair.Enter file in which to save the key (/Users...
RSA key to PEM formatopenssl rsa -in pk_rsa              -outform pem   > pk_rsa.pem
generate RSA key in PEM format openssl genrsa -des3                  -out pk_rsa.pem 2048
public key out of PEM fileopenssl rsa -pubout            -in pk_rsa.pem            -out pk_pub.pem
encrypt with public key$pub_key=openssl_get_publickey(      file_get_contents("/tmp/pk_pub.pem"));$enc= openssl_public_enc...
decrypt using private key…$passphrase = “<secret passphrase>";$key = openssl_get_privatekey(      file_get_contents("/tmp/...
decrypt using private key$dec=openssl_private_decrypt(      $decoded_source,      $newsource,      $res);
there are always some      bad guys…
best practices PCI DSS Compliance
best practicesAES (RIJNDAEL)BLOWFISHTWOFISHSHA-256, 384, 512RSA
random!rand()mt_rand()openssl_random_pseudo_bytes()
key space Secret key space >= 128 bit Public key space >= 2048 bit
thanks M A Hossain Tonu     Sr. Software Engineer, somewherein…     http://mahtonu.wordpress.com Hasin Hayder     Founde...
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
×

Cryptography for the mere mortals

1,209

Published on

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,209
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
37
Comments
0
Likes
1
Embeds 0
No embeds

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 &amp; 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.
  • Cryptography for the mere mortals

    1. 1. julius caesar : caesar cipherkey = 3
    2. 2. julius caesar : caesar cipherkey = 3hasin = kdvlq
    3. 3. rise of the machines
    4. 4. cryptography in bangla way
    5. 5. !@#$%^&* The science of writing in secret code
    6. 6. daily cryptographySSLSession/Cookie EncryptionStoring Sensitive InformationSecure Message TransportationSigning Documents
    7. 7. terms Plaintext Key Cipher Encryption Ciphertext Decryption
    8. 8. techniques Symmetric Cryptography = shared secret key Asymmetric Cryptography = public key + private key Hash Cryptography = One way
    9. 9. cryptography in PHP cracklib hash mCrypt openSSL mHash
    10. 10. one way journey md5 sha1 Sha2  Sha 256  Sha 512
    11. 11. problems of MD5/SHA1 Collision Attack  hash(data1) = hash(data2)
    12. 12. why salt?
    13. 13. password!Use a salt value in hash functions or bcrypt hash( $salt . $password ); hash_hmac( ‘sha512’, $salt . $password ); crypt($password , $salt );
    14. 14. symmetric encryption One single key Shared between parties Popular
    15. 15. sample encryption - AES…$ivlength = mcrypt_get_iv_size( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);$iv = mcrypt_create_iv( $ivlength, MCRYPT_RAND);
    16. 16. sample encryption - AES$encryptedText = mcrypt_encrypt( MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_CBC, $iv);
    17. 17. sample decryption – AES$decryptedText = mcrypt_decrypt( MCRYPT_RIJNDAEL_256, $key, $encryptedText, MCRYPT_MODE_CBC, $iv);
    18. 18. asymmetric encryption public / private key semi-shared
    19. 19. meet with bob and alice
    20. 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. 21. public/private key encryption RSA openSSL
    22. 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. 23. RSA key to PEM formatopenssl rsa -in pk_rsa -outform pem > pk_rsa.pem
    24. 24. generate RSA key in PEM format openssl genrsa -des3 -out pk_rsa.pem 2048
    25. 25. public key out of PEM fileopenssl rsa -pubout -in pk_rsa.pem -out pk_pub.pem
    26. 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. 27. decrypt using private key…$passphrase = “<secret passphrase>";$key = openssl_get_privatekey( file_get_contents("/tmp/pk.pem"), $passphrase);
    28. 28. decrypt using private key$dec=openssl_private_decrypt( $decoded_source, $newsource, $res);
    29. 29. there are always some bad guys…
    30. 30. best practices PCI DSS Compliance
    31. 31. best practicesAES (RIJNDAEL)BLOWFISHTWOFISHSHA-256, 384, 512RSA
    32. 32. random!rand()mt_rand()openssl_random_pseudo_bytes()
    33. 33. key space Secret key space >= 128 bit Public key space >= 2048 bit
    34. 34. thanks M A Hossain Tonu Sr. Software Engineer, somewherein… http://mahtonu.wordpress.com Hasin Hayder Founder, Leevio http://hasin.wordpress.com
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×