Information Security Notes 4 - Authentication and Standards

Information Security Notes 4 - Authentication and Standards

Adversatry Model in Networks

  • Read only
  • Write only
  • Drop message
  • Replace message

Encryption is to ensure confidentiality
Digital signature/MAC is to ensure message integrity

Man-in-the-middle attacks

The attacker establishes separate contacts with each end of the communication and exchanges the data it receives so that the two ends of the communication think they are talking directly to each other through a private connection, when in fact the entire conversation is under the full control of the attacker.
Public Key Stolen.

A<=KEY=>M<=Key=>B

Protection of Man-in-the-middle attacks - SSL

Verify that the certificate used by one or both parties involved in the communication is issued by an authoritative and trusted digital certificate authority and is capable of performing two-way identity authentication.

Secure Public Key Distribution

  • Manual
  • Certificate
  • Public Key infrastructure
  • PGP
  • ID-base

Manual

Download a public key from a webpage/an email

  • Anyone can forge such a webpage or email

  • Hash the public key and release the hash instead

  • Hash is much more easier to compare by haman than public key

Visual Hash - RandomArt

Use image hash instead of using hex, most non-IT ppls are allergic to hex
Directly use Vitual hash is insecure because attackers can “easily” generate the same public key with the same visual hash

What should we do:

  1. Broadcast the hash of their public keys
  2. announce their public key.
  3. Compute the visual hashes

Certificate

  • Certificate Authority(CA): It is an authoritative body responsible for issuing and managing digital certificates and acts as a trusted third party, assuming the responsibility of checking the legitimacy of public keys.

It is impossible to do the Man-in-the-middle attacks unless:

  • CA also issues a certificate for attackers
  • attackers applies a certificate with user’s identity from another trusted CA
  • Attackers steals CA’s private key
  • Steals Users’ private key

Information included in a digital certificate:

  • Basic info of the subject: name, email, web address
  • Public key of the subject
  • Basic info of the issuer
  • Issuer’s digital signature on the certificate
  • Validity of the certificate: the period of time that the certificate is valid

X.509

Defines a framework for the provision of authentication services by the X.500 directory to its users
Extensions:

  • .pem
  • .cer
  • .crt
  • .der
  • .p7b

Used in many areas such as S/MIME, IPSec, SSL/TLS

Digital Certificate Creation

  1. Subject generates public key pair
  2. Subject keeps the private key to himself
  3. Subject sends his identity and public key to issuer
  4. Issuer verifies subject’s identity
  5. Issuer signs the certificate and returns it to subject

Digital Certificate Verification

  1. Subject presents the certificate to others
  2. Other checks the issuer’s digital signature on the certificate
  3. Check if the certificate has been revoked

Certificate Revocation List CRL

A list that contains revoked certificates.

Reasons for revocation:

  • CA improperly issued a certificate
  • The private key has been hacked
  • Owner no longer own the domains

Pretty Good Privacy - PGP

Self-signed certificate
User trusts this certifcate because there is a link between issuer and users

ID Based

  • Require a trusted authority
    • Called a Public Key Generator(PKG)
  • PKG generates a private key to the user
  • Anyone can use the users’s ID to send an encrypted message
  • The ID is the public key

Pros

  • Do not need a real public KEY, just use ID
  • Encryption cipher is usually short

Cons

  • Authority has the ability to deduce everyone’s private key
  • ID is not legally bind with a person identity

Symmetric key Distribution

  1. Key agreement: Both parties contribute some information in key establishment.
  2. Perfect forward secrecy: When you lose this long term key, the security of your future actions cannot be guaranteed, but your previous actions are guaranteed to be secure.
  3. Session Key: uses a session key per each communication session
  4. Authenticated: is able to confirm the identity of the partner
  5. Absent of Secure Channel: does not require both party to pre-share a secure channel

Encrypted Key Exchange

  • A and B share a password
  • Diffie-Hellman
  1. Secure against replay attack
  2. Secure against offline dictionary attack
  3. Perfect forward secracy
  4. Secure against Denning-Sacco attacks

More of password-base authentication

  1. Do not choose weak passwords
  2. Do not write down password
  3. Change password regularly
  4. Avoid using personal information as password

Information Security Notes 3 - Hash function

Information Security Notes 3 - Hash function

Hash function, known as message digest, used for verification in general.

Famous hash: MD5, SHA1, SHA-256

Hash is discuss in Data Structure


MD construction || Length extension attacks

Two conditions for Length extension attacks:

  • When thee encrypted data is less than 64 bytes, it will be filled automatically.(padding)
  • Encrypt the plaintext in blocks according to this fixed length and use the encryption result of the previous block as the next encrypted block (Initial Vector).

MD5, SHA-1 SHA-2 are all with MD construction
SHA-3 is not.
The most effective way to prevent hash collisions is to expand the bits where the hash values are taken.

Attacks on (Ideal) Hash functions

  • Brute-force: To break the n-bits hash, we need to perform 2^(n-1) operations.
  • Second Pre-image: given a fixed message, output another message such that their hash values are the same, requires 2^(n-1) operations.
  • Birthday attack: To obtain any two message that has the same hash values, requires only 2^(n/2) operations! Birthday Attacker is Maths

Hash Chain

Can be used in applications that requires only one-way authentication e.g. security token
How it works: Hash another Hash

Hash list

Verifying the top hash can assery the correctness of data
When data is transferred, we cut the file into small pieces. Each data packet have a hash value. We put all hash value together as a top hash. Hash check the top hash.

Hash Tree(Merkle Tree)

Hashing like a tree. By verifying the root hash.
Usage: git, p2p system, Bitcoin

Message Authentication Code (MAC)

MAC is a small bit of information that can be used to check the authenticity and the integrity of a message.

  • Authenticity: from the designated person
  • Integrity: unmodified

Requirment of MAC

  • Computable: very fast
  • Unforgeable: cannot be forged by attacker
  • One-wayness: Message cannot be recovered from MAC

Limitation of MAC

MAC requires a key to verify (symmetric).

Digital Signature

  • Asymmetric key version of MAC
  • SSL?
  • Anyone has the public key can verify the document is signed by a signer

Example of Digial Signatures

  • RSA-PSS
  • DSA
  • ECDSA => shortest, fastest and more secure

Comparing MAC and Digital Signature

  • MAC is not publicly verifiable
  • MAC is faster, because requires a hash operation only

Information Security Notes 2 - Symmetric and Asymmetric Encryption

Information Security Notes 2 - Symmetric and Asymmetric Encryption

Symmetric and Asymmetric key

Symmetric

  • Share Same Key
  • Most classoc crypto are Symmetric
  • Encrypts and Decrypts using the same key
  • Also called “Secret Key Encryption”

Symmetric Overview

  • More secure if the algorithm is opened and publicly review
  • Two type of Symmetric
    1. Stream Cipher: the smallest unit to encrypt is one bit
    2. Block Cipher: the smallest unit to encrypt is a block
  • Block Ciphers are more secure than most stream ciphers
  • Most encryptions scramble the message by substitution and rearrangement for multiple-times
  • Security is bounded by the key size.
    • 64bits key => broken with at most 2^64 operations

History - Data Encryption Standard

DES and 3DES should not be adopted today.

  • Known more by reading “Meeting in the middle attack”

Asymmetric

  • Public Key
  • Private Key
  • Encrypt with public key; Decrypt with private key
  • Also called “Public Key Encryption”
  • Everyone can lock but only the one with private key can unlock
  • Trapdoor Function: As a function, its function value is very easy to calculate, but the calculation of the inverse solution is very difficult unless some special information is known.

Note that there are many Maths about ECC, AES etc. I will note them if I have time later.

Data Mining Notes 1

Attribute of data

  • Nominal (ID numbers)
  • Ordinal (grades)
  • Interval (dates)
  • Ratio

How to measure the similarity of two objects

Similarity = 1 - Dissimilarity

  • Similarity
    • Numerical measure of how alike two data objects are
    • Is higher when objectsare more alike
    • Often falls in the range [0,1]
  • Dissimilarity
    • Numberical measure of how different re two data objects
    • Lower when objects are more alike
    • Miinimum Dissimilarity is often 0
    • Upper limit varies

Proximity refers to a similarity or dissimilarity

Data Quality

Examples of problems:

  • Noise and outliers
  • Missing Values
  • Duplicate data

Duplicate Data

Data set may include data objects that are duplicates, or almost duplicates of one another

  • Major issue when merging data from heterogeous sources

Example: Same person with multiple email addresses
Data Cleaning: Process of dealing with duplicate data issues

Data Preprocessing

  • Aggregation: Conbining two or more attributes
    • Data reduction
    • Change of scale
    • More “stable” data
  • Sampling
  • Dimensionality Reduction
  • Feature subset selection
  • Discretization
  • Attribute Transformation

Sampling

  • Sampling is the main technique employed for data selection
  • Statisticians sample because obtaining the entire set of data interest is too expensive or time consuming
  • Sampling is used in data mining because processing the entire set of data of interest is too expensive or time consuming

Key principle for effective sampling is

  1. using a sample will work almost as well as using the entire data sets, if the sample is representative.
  2. A sample is representative if it has approximately the same property as the original set of data

Types of sampling

  • Simple Random Sampling
  • Sampling without replacement
  • Sampling with replacement
  • Stratified sampling

Dimensionality Reduction

???? Need to learn later

Distributed and Cloud Computing Notes 1

Distributed and Cloud Computing Notes 1

Reasons for Distributed Systems

  • Functional Separation
    • Different Capabilities and purposes
  • Inherent Distribution
    • Information
    • People
  • Power imbalance and load variation
  • Reliability
  • Economies

Consequences of Distributed Systems

  • Concurrency - Each computer is autonomous
    • Carry our tasks independently
    • Tasks coordinate their actions by exchanging messages
    • System capacity can be increased by adding more resources
  • No global clock
  • Independent Failures

Motivation of Distributed Systems

  • To share resource and information
  • The emergence of pervasive networking technology
  • The emergence of mobile and ubiquitous computing
  • The increasing demand for multimedia services
  • The view of distributed systems as a utility

Maintenance of intranet

  • No rick if no connection to internet
  • Firewalls are used to limit services from/to an intranet
    • Limit FTP/Remote Desktop etc.

Mobile computing: Performing computing tasks while the user is on the move, away from his/her usual environment

Eight forms of transparency

  • Access transparency
  • Location transparency
  • Concurrency transparency
  • Replication transparency
  • Failure transparency
  • Mobility transparency
  • Performance transparency
  • Scaling transparency

List of Challenge

  • Heterogeneity
  • Security
    • Confidentiality
      • Protection against disclosure to unauthorized individual information
    • Integrity
      • Protection against alteration or corruption
    • Availability
      • Protection against interference targeting access to the resources
      • DDoS
    • Authenticity or Non-repudiation
      • Proof of sending / receiving an information
      • digital signature

Failure

Availability =MTTF/(MTTF+MTTR)

  • Mean time to failure(MTTF)
    • The average time of normal operation before the system fails
  • Mean time to repair (MTTR)
    • The average time it takes to repair the system and restore it to working condition

Single point failure

Single hardware/Software component failures cause the whole system crash. The key approach to enhancing availability is to make as many as possible partial failures by removing single points of failure

Checkpointing

  • The process of periodically saving the stage of an executing program to stable storage, from which the system can recover after a failure.
    • Each program stae saved is called a Checkpoint .
    • Checkpointing can be realized by operating system at kernel level/Third party library/by the application itself.

Jobs

  • Serial Jobs: Run on a single node
  • Parallel jobs: use multiple nodes
  • Interactive jobs: require fast turnaround time, and their input/output is directed to a termainal
  • Batch jobs: need more resources and don’t need immediate responses. Scheduled jobs.

job Management System

  • A user server: Let user submit jobs.
  • A job scheduler: performs job scheduling
  • A resource manager: allocates and monitors resources. Enforces scheduling policies, and collects accounting information.

Security Mechanisms

  • Encryption(AES, RSA)
  • Authentication(Password, Public key)
  • Authorization(access control)

  • Concurrency
    • Fair scheduling
    • Preserve dependencies
    • Avoid deadlocks
    • Object locking, data consistency, semaphores
  • Fault tolerance (No failure despite faults)
    • Fault detection
      • Checksums
      • Heartbeat
    • Fault masking
      • Retransmission of corrupted messages
      • Redundancy
    • Fault toleration
      • Exception handling
      • Timeouts
    • Fault recovery
      • Rollback mechanisms
  • Scalability
  • Openness
  • Distribution transparency <= Do not let other touch

Information Security Notes 1 - Classical Crypto System

Information Security Notes 1 - Classical Crypto System

What is Encryption

Encryption is composed of a key and an Encryption algorithm.

  1. Type of operations used for transforming plaintext to ciphertext
  2. The number of keys used
  3. The way in which the plaintext is processed

Encryption and Decryption

  • Unencrypted message = plaintext/message
  • Encrypted message = cipher/ciphertext

Cryptanalysis

Means attack

  • Brute-force
    • Tries every possible
  • Breaking the algorithm
    • Tries to exploit the weakness of the encryption algorithm

How to measured by the following dimensions

  • Attacker models
    • How strong is the attacker
    1. Ciphertext only attacks
    2. Known plaintext attacks
    3. Chosen plaintext attacks(Attacker can choose plaintext on his own)
    4. Chosen ciphertext attacks(Attacker can choose the cipher and obtain the plaintext)
  • Security Goal
    • What Goals does your attacker wants to achieve
    1. Computationally secure: The cost of breaking the cipher exceeds the value of the encryptited information
    2. Unconditionally secure: No matter how much time as opponent has, it is impossible for people decrypt. (secure against brute-force)
  • Assumptions:
    • What is the computational limitation
    • Always better to over-estimate the ability of your attackers
    1. Computation: attacker might have many computing resource(super-computers)
    2. Network: attacker might have control over the network/communication channel, they can send/drop/inject/view your packet
    3. Some problems are hard(NP=/=P), no polynomial time solutions
    4. We generally assume computation requiring 2^80 is unsolvable

Brute-force attack

  • Attackers try all possible sets of keys
  • By probability, it has to try at least half of them
  • We generally assume computation requiring 2^80 is unsolvable

HostHatch Hong Kong VPS review

Comments

Pros

  1. Cheap, Super Cheap
  2. guaranteed performance
  3. Decent Provider
  4. World Wide Locations

Cons

  1. Buggy panel
  2. Delay delivery
  3. M247 network

Information of the Deal

1
2
3
4
5
2 CPU core (50% dedicated, burstable up to 200%)
8 GB RAM
40 GB RAID-10 NVMe
5 TB bandwidth (1 TB in Hong Kong and Sydney)
$30 per year

Bench

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---------------------------------
Processor : Intel(R) Xeon(R) CPU E5-2690 v2 @ 3.00GHz
CPU cores : 2 @ 2999.998 MHz
AES-NI : ✔ Enabled
VM-x/AMD-V : ❌ Disabled
RAM : 7.8 GiB
Swap : 4.0 GiB
Disk : 39.1 GiB

fio Disk Speed Tests (Mixed R/W 50/50):
---------------------------------
Block Size | 4k (IOPS) | 64k (IOPS)
------ | --- ---- | ---- ----
Read | 193.83 MB/s (48.4k) | 2.60 GB/s (40.7k)
Write | 194.34 MB/s (48.5k) | 2.62 GB/s (40.9k)
Total | 388.18 MB/s (97.0k) | 5.22 GB/s (81.7k)
| |
Block Size | 512k (IOPS) | 1m (IOPS)
------ | --- ---- | ---- ----
Read | 4.26 GB/s (8.3k) | 4.92 GB/s (4.8k)
Write | 4.49 GB/s (8.7k) | 5.25 GB/s (5.1k)
Total | 8.75 GB/s (17.1k) | 10.18 GB/s (9.9k)

iperf3 Network Speed Tests (IPv4):
---------------------------------
Provider | Location (Link) | Send Speed | Recv Speed
| | |
Clouvider | London, UK (10G) | busy | busy
Online.net | Paris, FR (10G) | 431 Mbits/sec | 217 Mbits/sec
WorldStream | The Netherlands (10G) | busy | 281 Mbits/sec
Biznet | Jakarta, Indonesia (1G) | 118 Mbits/sec | 440 Mbits/sec
Clouvider | NYC, NY, US (10G) | 451 Mbits/sec | 365 Mbits/sec
Velocity Online | Tallahassee, FL, US (10G) | 59.1 Mbits/sec | 397 Mbits/sec
Clouvider | Los Angeles, CA, US (10G) | busy | busy
Iveloz Telecom | Sao Paulo, BR (2G) | busy | busy

Geekbench 5 Benchmark Test:
---------------------------------
Test | Value
|
Single Core | 606
Multi Core | 1149
Full Test | https://browser.geekbench.com/v5/cpu/5694857

Network

Looking Glass
Seems everything M247, just like other location of HH. With $30, what ever.

Tips for using HostHatch’s broken Panel

Their panel is very buggy, it seems that centos7 and ubuntu are bad, but when I reinstalled to debian10 then all functions are normal
So here’s what I did

  1. reinstall to Debian
  2. Mount the netboot.xyz
  3. reinstall the os you want from ISO

This is only my personal solution, not guaranteed to work

How to upgrade your linux kernel, Debian/Ubuntu

Ubuntu

  1. Download the ubuntu-mainline-kernel.sh Bash script utility. Open up your terminal and enter:

wget https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh

  1. install the previously downloaded script into our executable path:

sudo install ubuntu-mainline-kernel.sh /usr/local/bin/

  1. All is ready to upgrade the Ubuntu kernel to the latest version. To do so run do following command:

ubuntu-mainline-kernel.sh -i

The above command will search for the latest kernel version available. To continue with the kernel installation answer y.

  1. Finally, reboot your system

reboot

Debian

  1. Update the system
    apt update && apt full-upgrade -y
    apt install lsb-release

  2. Add the repo to the sources list

1
2
3
4
5
6
7
8
cat > /etc/apt/sources.list << EOF
deb http://cdn-aws.deb.debian.org/debian $(lsb_release -sc) main contrib non-free
deb http://cdn-aws.deb.debian.org/debian-security $(lsb_release -sc)/updates main contrib non-free
deb http://cdn-aws.deb.debian.org/debian $(lsb_release -sc)-updates main contrib non-free
deb http://cdn-aws.deb.debian.org/debian $(lsb_release -sc)-backports main contrib non-free
deb http://cdn-aws.deb.debian.org/debian $(lsb_release -sc)-proposed-updates main contrib non-free
# deb http://cdn-aws.deb.debian.org/debian $(lsb_release -sc)-backports-sloppy main contrib non-free
EOF
  1. Do the update again
    apt update

  2. upgrade your kernel
    apt install -t $(lsb_release -sc)-backports linux-image-$(dpkg --print-architecture) linux-headers-$(dpkg --print-architecture) --install-recommends -y
    update-grub
    reboot

Good Bye 2020, Hello 2021

For me, 2020 is not only about wuhan virus aka Couid19; It was a year of extreme decline in the face of my beloved Hong Kong.
Basically, I didn’t have the mental will to face anything throughout the 2020. Fucked up every every every thing.

I forget where this words of wisdon I saw:

We are in a time of dramatic change, before, change was part of life, now, it has become life itself

Can I start over again?

Btw, the image’s word is: “There are no heroes from sky, only mortals who step forward.”

Edit at 02-01-2021:

I thought for a day, if I could turn back the clock, if I could choose everything over again, what would I do?

In my memory, there are things that absolutely cannot be discarded, I will still choose this path now, the only hope to change just that one tragedy.
Perhaps I will make the same choice, after all, in addition to the pain and helplessness in the memory, there are some things in it that do not want to forget
Perhaps for those things, it’s worth starting over again.

Algorithm - Dynamic Programming

Algorithm - Dynamic Programming

What is Dynamic Programming?

Principle of Optimality (Bellman, 1957):
An optimal sequence of decisions has the property that whatever the initial state and decision are, the remaining decisions must constitute an optimal decision with regard to the state resulting from the first decision.

The Other Algorithmic Design Philosophy

  1. Divide-and-Conquer:
    The problem is divided and the subproblems are processed in a recursive manner, but the solutions of Divide-and-Conquer subproblems are usually not repeated, and when they are repeated, the same subproblems are usually recalculated.

  2. Greedy Approach:
    At each stage, starting from a certain starting point, each input is checked one by one to see if it is suitable to be added to the answer. If it is not possible to find a selection procedure to check one by one for the optimization problem to be handled, we will discuss it later.

Divide and Conquer and Dynamic Programming are very similar. The difference is that Dynamic Programming’s subproblems have many overlaps, which can be stored in a table without recalculation, exchanging space for time.