Ruby Rzeszów Ruby User Group #4 Wojciech Rząsa [email protected] @wrzasa Katedra Informatyki i Automatyki, Politechnika Rzeszowska http://www.kia.prz.edu.pl/ 19.01.2017 Wojciech Rząsa, @wrzasa, KIiA PRz RRUG#4, Asymmetric Cryptography in Ruby 1/35
(data privacy) Authenticity (who wrote it?) Integrity (was it changed along the way?) Non-repudiation . . . Wojciech Rząsa, @wrzasa, KIiA PRz RRUG#4, Asymmetric Cryptography in Ruby 4/35
Asymmetric vs. symmetric Key distribution problem Extensive applications More CPU intensive → slow (complex math. operations) Longer keys symmetric 128, 129, 256 bit (AES) asymmetric 1024, 2048, 4096 bit (RSA) Wojciech Rząsa, @wrzasa, KIiA PRz RRUG#4, Asymmetric Cryptography in Ruby 8/35
Public key encryption § 1 require ’openssl ’ 2 3 message = "W Tyńcu , w gospodzie ,,Pod Lutym Turem ’’, 4 należącej do opactwa , siedziało kilku ludzi , słuchając 5 opowiadania wojaka bywalca , który z dalekich stron 6 przybywszy , prawił im o przygodach , jakich na wojnie 7 i w czasie podróży doznał." 8 9 key = OpenSSL :: PKey :: RSA.new File.read(’keys/public2.pem ’) 10 11 encrypted = key. public_encrypt message ¦ ¥ Public key encryption Wojciech Rząsa, @wrzasa, KIiA PRz RRUG#4, Asymmetric Cryptography in Ruby 16/35
Asymmetric encryption/decryption Easy (?) key distribution Slow encryption/decryption Vulnerable when used for bulk data Private-key cipher-text is a large ”signature” Wojciech Rząsa, @wrzasa, KIiA PRz RRUG#4, Asymmetric Cryptography in Ruby 18/35
public keys 2 Generate arbitrary secure symmetric key 3 Encrypt message with the symmetric key 4 Encrypt symmetric key with public key of recipient 5 Send/save ciphertext and encrypted key Wojciech Rząsa, @wrzasa, KIiA PRz RRUG#4, Asymmetric Cryptography in Ruby 22/35
public keys 2 Generate arbitrary secure symmetric key 3 Encrypt message with the symmetric key 4 Encrypt symmetric key with public key of recipient 5 Send/save ciphertext and encrypted key Advantages of both cryptography types Key distribution with asymmetric cryptography Efficient data exchange with symmetric cryptography Wojciech Rząsa, @wrzasa, KIiA PRz RRUG#4, Asymmetric Cryptography in Ruby 22/35
public keys 2 Generate arbitrary secure symmetric key 3 Encrypt message with the symmetric key 4 Encrypt symmetric key with public key of recipient 5 Send/save ciphertext and encrypted key Advantages of both cryptography types Key distribution with asymmetric cryptography Efficient data exchange with symmetric cryptography How to use it? Get one of existing solutions TLS or SSH protocol for communication GPG/PGP for file encryption Wojciech Rząsa, @wrzasa, KIiA PRz RRUG#4, Asymmetric Cryptography in Ruby 22/35
owner Key owner problem I have a public key. How do I know who owns corresponding private key? Wojciech Rząsa, @wrzasa, KIiA PRz RRUG#4, Asymmetric Cryptography in Ruby 23/35
owner Key owner problem I have a public key. How do I know who owns corresponding private key? Key with identity Public key Identity data . . . Digital signature(s) Wojciech Rząsa, @wrzasa, KIiA PRz RRUG#4, Asymmetric Cryptography in Ruby 23/35
Identity data Validity period Certificate issuer Extensions . . . Digital signature Wojciech Rząsa, @wrzasa, KIiA PRz RRUG#4, Asymmetric Cryptography in Ruby 24/35
RFC5280 Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile RFC4514 Lightweight Directory Access Protocol (LDAP): String Representation of Distinguished Names Samolej, Rząsa, Rzońca, Sadolewski: Wprowadzenie do informatyki II – bezpieczeństwo systemów informatycznych, sieci komputerowe, systemy operacyjne i bazy danych, Oficyna Wyd. PRz., 2014. Wojciech Rząsa, @wrzasa, KIiA PRz RRUG#4, Asymmetric Cryptography in Ruby 34/35