<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Mobile_App_Development_2022W_Lecture_19</id>
	<title>Mobile App Development 2022W Lecture 19 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Mobile_App_Development_2022W_Lecture_19"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Mobile_App_Development_2022W_Lecture_19&amp;action=history"/>
	<updated>2026-04-06T03:23:08Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Mobile_App_Development_2022W_Lecture_19&amp;diff=23963&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Video==  Video from the lecture given on March 25, 2022 is now available: * [https://homeostasis.scs.carleton.ca/~soma/mad-2022w/lectures/comp1601-2022w-lec19-20220325.m4v video] * [https://homeostasis.scs.carleton.ca/~soma/mad-2022w/lectures/comp1601-2022w-lec19-20220325.cc.vtt auto-generated captions] Video is also available through Brightspace (Resources-&gt;Zoom Meetings (Recordings, etc.)-&gt;Cloud Recordings tab).  Note that here you&#039;ll also see chat messages.  ==Notes...&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Mobile_App_Development_2022W_Lecture_19&amp;diff=23963&amp;oldid=prev"/>
		<updated>2022-03-25T20:02:55Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Video==  Video from the lecture given on March 25, 2022 is now available: * [https://homeostasis.scs.carleton.ca/~soma/mad-2022w/lectures/comp1601-2022w-lec19-20220325.m4v video] * [https://homeostasis.scs.carleton.ca/~soma/mad-2022w/lectures/comp1601-2022w-lec19-20220325.cc.vtt auto-generated captions] Video is also available through Brightspace (Resources-&amp;gt;Zoom Meetings (Recordings, etc.)-&amp;gt;Cloud Recordings tab).  Note that here you&amp;#039;ll also see chat messages.  ==Notes...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
Video from the lecture given on March 25, 2022 is now available:&lt;br /&gt;
* [https://homeostasis.scs.carleton.ca/~soma/mad-2022w/lectures/comp1601-2022w-lec19-20220325.m4v video]&lt;br /&gt;
* [https://homeostasis.scs.carleton.ca/~soma/mad-2022w/lectures/comp1601-2022w-lec19-20220325.cc.vtt auto-generated captions]&lt;br /&gt;
Video is also available through Brightspace (Resources-&amp;gt;Zoom Meetings (Recordings, etc.)-&amp;gt;Cloud Recordings tab).  Note that here you&amp;#039;ll also see chat messages.&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Lecture 19&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
March 25:   cryptography  &lt;br /&gt;
March 30:   A3 solutions, language runtimes&lt;br /&gt;
April 1:    Midterm solutions, operating systems&lt;br /&gt;
April 6:    networking, *last regular tutorial checkoffs*&lt;br /&gt;
April 8:    A4 solutions, closing thoughts&lt;br /&gt;
April 14:   Final Exam (2-4 PM)&lt;br /&gt;
April 18-22: Final exam interviews&lt;br /&gt;
&lt;br /&gt;
Midterm interviews will be the week of April 4th&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Cryptography and mobile applications (and other things)&lt;br /&gt;
 - highly encourage you all to take cryptography&lt;br /&gt;
     - it is moving to 2nd year, so you should be able to take it in the fall/winter&lt;br /&gt;
&lt;br /&gt;
Key problem in mobile OSs&lt;br /&gt;
  - how do I know what code is &amp;quot;okay&amp;quot; to run?&lt;br /&gt;
     - what code is authorized?&lt;br /&gt;
&lt;br /&gt;
Key technology: digital signatures&lt;br /&gt;
 - so only run code signed by approved authorities&lt;br /&gt;
&lt;br /&gt;
Note this applies everywhere&lt;br /&gt;
 - firmware (code that runs on devices)&lt;br /&gt;
 - boot loaders (code to start an operating system)&lt;br /&gt;
 - operating systems&lt;br /&gt;
 - applications&lt;br /&gt;
&lt;br /&gt;
Four building blocks of modern cryptography&lt;br /&gt;
 - secure hashes&lt;br /&gt;
 - message authentication codes (MACs)&lt;br /&gt;
 - symmetric encryption&lt;br /&gt;
 - public key encryption&lt;br /&gt;
    - which includes digital signatures&lt;br /&gt;
&lt;br /&gt;
What is a digital signature?&lt;br /&gt;
&lt;br /&gt;
When you install software on Windows, it will say who has published the software&lt;br /&gt;
 - under the hood, Windows is checking the digital signature of the software&lt;br /&gt;
 - if &amp;quot;unknown publisher&amp;quot;, there wasn&amp;#039;t a valid signature, or was signed&lt;br /&gt;
   by someone Windows didn&amp;#039;t know about&lt;br /&gt;
&lt;br /&gt;
Digital signature provides two basic guarantees&lt;br /&gt;
 - authenticity  &amp;lt;--- who signed this&lt;br /&gt;
 - integrity     &amp;lt;--- is it what was signed, with no changes&lt;br /&gt;
&lt;br /&gt;
Integrity comes from secure hashes (cryptographic hashes)&lt;br /&gt;
 - MD5, SHA1 were older ones, don&amp;#039;t use them&lt;br /&gt;
 - SHA256, SHA512, others are better&lt;br /&gt;
&lt;br /&gt;
On many OSs, can generate a SHA256 hash with the sha256 command or similar&lt;br /&gt;
 - produces a 256-bit value (normally displayed in hexadecimal)&lt;br /&gt;
    - because in base-16 each digit represents 4 bits&lt;br /&gt;
&lt;br /&gt;
A hash of any kind converts an arbitrary-sized input into a fixed-sized output.&lt;br /&gt;
&lt;br /&gt;
A secure hash should have the following properties&lt;br /&gt;
 - given a document, it should be easy to compute the hash&lt;br /&gt;
 - given a hash, it should be *difficult* to construct a document&lt;br /&gt;
   that has that hash&lt;br /&gt;
 - it should be *difficult* to find two documents that have the same hash&lt;br /&gt;
 - if you change one bit in the document, it should on average change&lt;br /&gt;
   half the bits in the hash.&lt;br /&gt;
&lt;br /&gt;
Note that hash functions have *no key*&lt;br /&gt;
&lt;br /&gt;
So if someone presents you with a secure hash to identify a document and you get the document from another source, the secure hash can tell you that a) you found the right document, and b) it hasn&amp;#039;t been changed&lt;br /&gt;
 - in effect, a secure hash is a strong identifier of any digital data&lt;br /&gt;
&lt;br /&gt;
Classic use: downloading large files (disk images, etc)&lt;br /&gt;
 - main website shows secure hash&lt;br /&gt;
 - download file from a mirror&lt;br /&gt;
 - check the downloaded file has the same hash&lt;br /&gt;
&lt;br /&gt;
Technologies like bittorrent and git are built on secure hashes&lt;br /&gt;
&lt;br /&gt;
Now, how do you know you have the right hash for a file?&lt;br /&gt;
 - if you downloaded it from a website, the website could have been compromised&lt;br /&gt;
 - can we have a stronger guarantee?&lt;br /&gt;
&lt;br /&gt;
This is what digital signatures are for.&lt;br /&gt;
&lt;br /&gt;
Symmetric encryption&lt;br /&gt;
 - k: the key&lt;br /&gt;
 - P: plaintext&lt;br /&gt;
 - C: ciphertext (encrypted plaintext)&lt;br /&gt;
 - E: encryption algorithm&lt;br /&gt;
 - E&amp;#039;: decryption algorithm&lt;br /&gt;
&lt;br /&gt;
 - normally E and E&amp;#039; are the same or almost the same&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 E(P,k) =&amp;gt; C&lt;br /&gt;
 E&amp;#039;(C,k) =&amp;gt; P&lt;br /&gt;
&lt;br /&gt;
This is how secret decoder rings work&lt;br /&gt;
This is also how AES works.&lt;br /&gt;
  - AES is a symmetric block cipher&lt;br /&gt;
     - works on 128 bits at a time&lt;br /&gt;
     - key can be 128, 192, or 256 bits&lt;br /&gt;
(How do you encrypt something longer that 128 bits?  That&amp;#039;s block cipher modes, beyond the scope of this lecture.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With symmetric key encryption, the key for encryption and the key for decryption are the same.&lt;br /&gt;
&lt;br /&gt;
Symmetric key encryption is *very* secure, but has a fundamental problem&lt;br /&gt;
 - how do both parties get the same key?&lt;br /&gt;
&lt;br /&gt;
Public key cryptography is the solution to this problem&lt;br /&gt;
 - keys come in pairs, a public and matching private key&lt;br /&gt;
 - k: private key is private (don&amp;#039;t share with anyone!)&lt;br /&gt;
 - k&amp;#039;: public key is public (tell everyone!)&lt;br /&gt;
&lt;br /&gt;
So with public key cryptography we get:&lt;br /&gt;
&lt;br /&gt;
  E(P, k) =&amp;gt; C&lt;br /&gt;
  E&amp;#039;(C, k&amp;#039;) =&amp;gt; P&lt;br /&gt;
&lt;br /&gt;
If you wanted to send me a private document, you would get my public&lt;br /&gt;
key (which is widely available), use it to encrypt the document, and&lt;br /&gt;
then send it to me (or even publish it).  Only I can read it since&lt;br /&gt;
only I have the corresponding private key.&lt;br /&gt;
&lt;br /&gt;
A digital signature is the same idea, except we reverse the public and private key roles&lt;br /&gt;
 - private key is used to sign a document&lt;br /&gt;
 - public key is used to verify a signature&lt;br /&gt;
&lt;br /&gt;
(While some algorithms, like RSA, can be used for encryption and signatures,&lt;br /&gt;
 nowadays we actually use separate ones mostly)&lt;br /&gt;
&lt;br /&gt;
By the way, public key algorithms only work on small amounts of plaintext/ciphertext&lt;br /&gt;
 - so we combine with hash functions (for digital signatures) or symmetric key algorithms (for encryption)&lt;br /&gt;
 &lt;br /&gt;
PGP/GnuPG  (GNU Privacy Guard) are tools for encrypting and signing documents using hash functions, symmetric key algorithms, and public key algorithms&lt;br /&gt;
&lt;br /&gt;
How do I know I have the right public key for someone?&lt;br /&gt;
 - just because I have a public key that says it is from Justin Trudeau,&lt;br /&gt;
   do I really think that&amp;#039;s the case?&lt;br /&gt;
&lt;br /&gt;
Why not use digital signatures to authenticate public keys?&lt;br /&gt;
&lt;br /&gt;
A public key + metadata =&amp;gt; certificate&lt;br /&gt;
&lt;br /&gt;
Note that all the lock icon means in a web browser is that&lt;br /&gt;
 - the connection used TLS&lt;br /&gt;
 - TLS connection was secured using a certificate signed by a known authority&lt;br /&gt;
&lt;br /&gt;
It says nothing about the security of the website itself&lt;br /&gt;
&lt;br /&gt;
There are almost no proofs in cryptography&lt;br /&gt;
 - just puzzles nobody has solved yet&lt;br /&gt;
 - so algorithms &amp;amp; protocols regularly are found to be &amp;quot;broken&amp;quot; and&lt;br /&gt;
   then we switch to new ones&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
certificates are used to secure websites, and secure code&lt;br /&gt;
 - same tech!&lt;br /&gt;
&lt;br /&gt;
mobile devices only run code signed with approved certificates&lt;br /&gt;
  - many many fewer ones than in web browsers!&lt;br /&gt;
&lt;br /&gt;
In Xcode, you have to configure a key that Apple signs&lt;br /&gt;
 - otherwise, you wouldn&amp;#039;t be able to get an iPhone to run your code&lt;br /&gt;
 - that signature is specific to your device, won&amp;#039;t work on any iPhone&lt;br /&gt;
    - if you want that, you have to go through the App Store&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>