Secure Programming Flashcards

1
Q

How to avoid integer wraparound

A

BigInt
Try/Catch

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Python

A

Python dynamically changes type depending on required space

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

more secure if(==y){…}

A

tol = 0.001
if abs(x-y)<tol

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

secure symmetric encryption
(LRRS)

A

Key must be as long as plaintext
key must be random
key must never be reused
key must be kept secret

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

modulus

A

n=p*q

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

totient φ(n)

A

φ(n) = (p-1)*(q-1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

E

A

between 1 and φ(n)

e.g.1-12
7

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

D

A

Modular inverse of E

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Public-Key

A

(e,n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Private-Key

A

(d,n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

black box

A

Simulate attacks externally

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

white box

A

simulate attacks while knowing the structure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

sql

A

declare @inbox int
declare @sql nvarchar(100)

set @inbox = 3; Drop Database
set @sql = ‘select * from review where stars =’ + @stars

Output = select * from reviews; Drop database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

secure sql

A

declare @inbox nvarchar(100)
declare @sql nvarchar(100)
declare @param nvarchar(100)
declare @query nvarchar(100)

SET @inbox = ‘3; drop database’;
SET @sql= N’SELECT * FROM REVIEW WHERE stars = @stars’;
SET @paramDefinition = N’@stars NVARCHAR(MAX)’;
SET @query = @SQLstub;

EXEC sp_executesql @SQLQuery, @paramDefinition, @stars = @inbox;

output = SELECT * FROM REVIEW WHERE stars = ‘3; drop database’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

RSA encryption (key = (7,12))

A

Convert string to ASCII
e.g. H = 72
Encryption = C = M^e mod n = C = 72^7 mod 12
Decryptuon = M = C^d mod n = M = C^7 mod 12

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

XOR

A

ASCII of input XOR with a random bitstring (key)

17
Q
A