CS252: Systems Programming Ninghui Li Topic 3: Programming in a FIZ: Simple Functional Programming Language.

Slides:



Advertisements
Similar presentations
CS555Spring 2012/Topic 171 Cryptography CS 555 Topic 17: Textbook RSA encryption.
Advertisements

1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
CSE331: Introduction to Networks and Security Lecture 19 Fall 2002.
Public Key Cryptosystems - RSA Receiver Sender Eavesdroppe r p q p q p q p and q prime.
Dr. Lo’ai Tawalbeh Summer 2007 Chapter 9 – Public Key Cryptography and RSA Dr. Lo’ai Tawalbeh New York Institute of Technology (NYIT) Jordan’s Campus INCS.
RSA ( Rivest, Shamir, Adleman) Public Key Cryptosystem
1 Lecture #10 Public Key Algorithms HAIT Summer 2005 Shimrit Tzur-David.
Public Encryption: RSA
WS Algorithmentheorie 03 – Randomized Algorithms (Public Key Cryptosystems) Prof. Dr. Th. Ottmann.
Cryptography and Network Security Chapter 9. Chapter 9 – Public Key Cryptography and RSA Every Egyptian received two names, which were known respectively.
Public Key Cryptography and the RSA Algorithm
Cryptography1 CPSC 3730 Cryptography Chapter 9 Public Key Cryptography and RSA.
Private-Key Cryptography traditional private/secret/single key cryptography uses one key shared by both sender and receiver if this key is disclosed communications.
WS Algorithmentheorie 03 – Randomized Algorithms (Public Key Cryptosystems) Prof. Dr. Th. Ottmann.
RSA Encryption William Lu. RSA Background  Basic technique first discovered in 1973 by Clifford Cocks of CESG (part of British GCHQ)  Invented in 1977.
Fall 2010/Lecture 311 CS 426 (Fall 2010) Public Key Encryption and Digital Signatures.
Dr.Saleem Al_Zoubi1 Cryptography and Network Security Third Edition by William Stallings Public Key Cryptography and RSA.
Public Key Algorithms 4/17/2017 M. Chatterjee.
1 Pertemuan 08 Public Key Cryptography Matakuliah: H0242 / Keamanan Jaringan Tahun: 2006 Versi: 1.
Public Key Cryptography RSA Diffie Hellman Key Management Based on slides by Dr. Lawrie Brown of the Australian Defence Force Academy, University College,
“RSA”. RSA  by Rivest, Shamir & Adleman of MIT in 1977  best known & widely used public-key scheme  RSA is a block cipher, plain & cipher text are.
Introduction to Public Key Cryptography
Public Key Model 8. Cryptography part 2.
Public Key Encryption and the RSA Public Key Algorithm CSCI 5857: Encoding and Encryption.
 Introduction  Requirements for RSA  Ingredients for RSA  RSA Algorithm  RSA Example  Problems on RSA.
CS5204 – Fall Cryptographic Security Presenter: Hamid Al-Hamadi October 13, 2009.
The RSA Algorithm Rocky K. C. Chang, March
Prime Numbers Prime numbers only have divisors of 1 and self
RSA Public Key Algorithm. RSA Algorithm history  Invented in 1977 at MIT  Named for Ron Rivest, Adi Shamir, and Len Adleman  Based on 2 keys, 1 public.
RSA and its Mathematics Behind
RSA Ramki Thurimella.
Cryptography: RSA & DES Marcia Noel Ken Roe Jaime Buccheri.
Public-Key Cryptography CS110 Fall Conventional Encryption.
Introduction to Algorithms Second Edition by Cormen, Leiserson, Rivest & Stein Chapter 31.
Section 4.4: The RSA Cryptosystem Practice HW Handwritten and Maple Exercises p at end of class notes.
Darci Miyashiro Math 480 April 29, 2013
Public Key Cryptography. symmetric key crypto requires sender, receiver know shared secret key Q: how to agree on key in first place (particularly if.
RSA Public Key Crypto System. About RSA Announced in 1977 by Ronald Rivest, Adi Shamir, and Leonard Adleman Relies on the relative ease of finding large.
1 Public-Key Cryptography and Message Authentication.
Public Key (RSA) Day 27. Objective Students will be able to… …understand how RSA is used for encryption and decryption. …understand some of the challenges.
Computer and Network Security Rabie A. Ramadan Lecture 6.
Cryptography and Network Security Chapter 9 - Public-Key Cryptography
Algebra of RSA codes Yinduo Ma Tong Li. Ron Rivest, Adi Shamir and Leonard Adleman.
PUBLIC-KEY CRYPTOGRAPH IT 352 : Lecture 2- part3 Najwa AlGhamdi, MSc – 2012 /1433.
RSA and its Mathematics Behind July Topics  Modular Arithmetic  Greatest Common Divisor  Euler’s Identity  RSA algorithm  Security in RSA.
Lecture 8 Overview. Analysis of Algorithms Algorithms – Time Complexity – Space Complexity An algorithm whose time complexity is bounded by a polynomial.
Cryptography and Network Security Public Key Cryptography and RSA.
Information Security CS 526
Chapter 3 – Public Key Cryptography and RSA (A). Private-Key Cryptography traditional private/secret/single-key cryptography uses one key shared by both.
RSA The algorithm was publicly described in 1977 by Ron Rivest, Adi Shamir, and Leonard Adleman at MIT Partly used for PGP (Pretty Good Privacy) to encrypt.
Chapter 9 Public Key Cryptography and RSA. Private-Key Cryptography traditional private/secret/single key cryptography uses one key shared by both sender.
Fall 2002CS 395: Computer Security1 Chapter 9: Public Key Cryptography.
POON TENG HIN.  RSA  Shamir’s Three-Pass Protocol  Other issues.
CS 4803 Fall 04 Public Key Algorithms. Modular Arithmetic n Public key algorithms are based on modular arithmetic. n Modular addition. n Modular multiplication.
Cryptography and Network Security Third Edition by William Stallings Lecture slides by Lawrie Brown.
Computer Security Lecture 5 Ch.9 Public-Key Cryptography And RSA Prepared by Dr. Lamiaa Elshenawy.
Lecture 3 (Chapter 9) Public-Key Cryptography and RSA Prepared by Dr. Lamiaa M. Elshenawy 1.
RSA Pubic Key Encryption CSCI 5857: Encoding and Encryption.
Chapter 9 – Public Key Cryptography and RSA Every Egyptian received two names, which were known respectively as the true name and the good name, or the.
CSCE 715: Network Systems Security Chin-Tser Huang University of South Carolina.
CSEN 1001 Computer and Network Security Amr El Mougy Mouaz ElAbsawi.
1 The RSA Algorithm Rocky K. C. Chang February 23, 2007.
RSA Algorithm Date: 96/10/17 Wun-Long Yang. Outline Introduction to RSA algorithm RSA efficient implementation & profiling.
Cryptography By: Nick Belhumeur. Overview What is Cryptography? What is Cryptography? 2 types of cryptosystems 2 types of cryptosystems Example of Encryption.
Public Key Cryptography
Public Key Encryption and Digital Signatures
Public Key Encryption and the RSA Algorithm
Public Key Cryptosystems - RSA
Real-world Security of Public Key Crypto
The RSA Public-Key Encryption Algorithm
Presentation transcript:

CS252: Systems Programming Ninghui Li Topic 3: Programming in a FIZ: Simple Functional Programming Language

slide 2 What is FIZ FIZ F is for functional programming I is for integer(we only use integer data type) Z is for zero, denoting the simplicity of the language In Functional Programming, one defines functions writes expressions Syntax: instead of writing f(a, b, c); we write (f a b c)

slide 3 Basic Features of FIZ non-negative integerevaluates to its value (inc exp)evaluates to value of exp + 1 (dec exp)evaluates to halt if value of exp is 0 otherwise evaluates to value of exp - 0 (ifz cexp texp fexp) evaluates to value of texp when cexp evaluates to 0 and to value of fexp when cexp evaluates to none 0

slide 4 Examples (inc 3)4 (inc (dec (inc 1)))2 (ifz (dec 1) 2 3)2

slide 5 Defining New Functions (define (name arguments) function-body ) Examples: (define (add x y) (ifz y x (add (inc x) (dec y)))) (define (sub x y) (ifz y x (ifz x halt (sub (dec x) (dec y))))) (name arguments) E.g., (add 2 3); (add (inc 2) (dec 3))

slide 6 Dealing with Errors (halt)stops the program Whenever the evaluation could lead to non- integer or negative number, call (halt) Note: FIZ has no assignment, except in function invocation. FIZ has no loop, except in recursion

More Examples: Add (define (add x y) (ifz y x (add (inc x) (dec y)))) ; if y==0, x+y=x ; otherwise x+y = (x+1) + (y-1) We assume lazy evaluation, i.e., in (ifz cond t_exp e_exp) We evaluate t_exp only when cond is 0, and evaluate e_exp only when cond is not 0

Lazy versus Eager Evaluation In Eager evaluation (add 3 0) becomes (ifz 0 3 (add (inc 3) (dec 0))) We need to evaluate the last argument in the above function call, i.e., (add (inc 3) (dec 0)), Which becomes (add 4 -1) This then becomes infinite loop In Lazy evaluation (add 3 0) becomes (ifz 0 3 (add (inc 3) (dec 0))) We do not evaluate the last argument yet, and figures out that we do not need it A similar issue in C: In “If (cond_1 && func(a,b))”, if cond_1 is false, would func(a,b) be called?

More Examples (define (mul x y) (ifz y 0 (add x (mul x (dec y)))) (define (div x y) (ifz y (halt) (ifz (lt x y) 0 (inc (div (sub x y) y)))))

Concept of Public Key Encryption In Traditional Cryptography, encryption key = decryption key, and must be kept secret, and key distribution/agreement is a difficult problem to solve In public key encryption, each party has a pair (K, K -1 ) of keys: K is the public key, and used for encryption K -1 is the private key, and used for decryption Satisfies D K -1 [E K [M]] = M Knowing K, it is computationally expensive to find K -1 The public key K may be made publicly available, e.g., in a publicly available directory Many can encrypt, only one can decrypt Public-key systems aka asymmetric crypto systems

RSA Algorithm Invented in 1978 by Ron Rivest, Adi Shamir and Leonard Adleman Published as R L Rivest, A Shamir, L Adleman, "On Digital Signatures and Public Key Cryptosystems", Communications of the ACM, vol 21 no 2, pp , Feb 1978 Security relies on the difficulty of factoring large composite numbers Essentially the same algorithm was discovered in 1973 by Clifford Cocks, who works for the British intelligence

RSA Public Key Crypto System Key generation: 1. Select 2 large prime numbers of about the same size, p and q Typically each p, q has between 512 and 2048 bits 2. Compute n = pq, and  (n) = (q-1)(p-1) 3. Select e, 1<e<  (n), s.t. gcd(e,  (n)) = 1 Typically e=3 or e= Compute d, 1< d<  (n) s.t. ed  1 mod  (n) Knowing  (n), d easy to compute. Public key: (e, n) Private key: d

RSA Description (cont.) Encryption Given a message M, 0 < M < nM  Z n  {0} use public key (e, n) compute C = M e mod n C  Z n  {0} Decryption Given a ciphertext C, use private key (d) Compute C d mod n = (M e mod n) d mod n = M ed mod n = M

Topic 6: Public Key Encrypption and Digital Signatures 14 RSA Example p = 11, q = 7, n = 77,  (n) = 60 d = 13, e = 37 (ed = 481; ed mod 60 = 1) Let M = 15. Then C  M e mod n C  (mod 77) = 71 M  C d mod n M  (mod 77) = 15

Topic 6: Public Key Encrypption and Digital Signatures 15 We show how to do modular exponentiation in FIZ. (define (mexp x e y) (ifz e 1 (ifz (rem e 2) (rem (square (mexp x (div e 2) y)) y) (rem (mul x (mexp x (dec e) y)) y)))) If e==0, then result is 1 Else if e%2=0, result is (x^(e/2) mod y) ^ 2 mod y Else result is (x * (x^(e-1) mod y)) mod y

16 FIZ is based on Scheme Scheme is a functional programming language Uses the list data structure extensively Program/Data equivalence Heavy use of recursion Garbage-collected, heap-allocated Usually interpreted, but good compilers exist

17 History of Function Programming Lisp was created in 1958 by John McCarthy at MIT Stands for LISt Processing Scheme developed in 1975 A dialect of Lisp Racket ML OCaml Haskell

18 Application Areas Artificial Intelligence expert systems planning Simulation, modeling Rapid prototyping

19 Functional Languages Imperative Languages Ex. Fortran, Algol, Pascal, Ada based on von Neumann computer model Functional Languages Ex. Scheme, Lisp, ML, Haskell Based on mathematical model of computation and lambda calculus

20 Review Be able to write simple programs in FIZ. Know the concept of lazy evaluation versus eager evaluation. How RSA work is not required.

21 Upcoming Attraction How to write an interpreter/compiler frontend? Topic 4: Regular expressions & Lexical Analyzer Topic 5: Context-free grammar & Parser