"> "> Yufei Luo's Blog - But I was so much older then, I am younger than that now.

中央处理器(CPU)

CPU组成

冯·诺依曼结构CPU的组成部件包括算术逻辑部件(ALU),寄存器,和连接它们的内部总线。从逻辑上说,这些组成部件可以被划分为运算器和控制器两大部分。

运算器接收控制器送来的命令并执行相应的动作,对数据进行加工和处理。它主要由算术逻辑单元(ALU,进行算数和逻辑运算)、暂存寄存器(暂存从主存中得到的数据)、通用寄存器(存放操作数和各种地址信息)、状态字寄存器(PSW,保存算术逻辑运算指令或测试指令产生的状态信息)、移位器(对操作数或计算结果进行移位运算)和计数器(CT,控制乘除运算的操作步骤)组成。

控制器分为硬布线控制器和微程序控制器两种,它的功能是执行指令,每条指令的执行是由控制器发出的一组微操作实现的。控制器包括程序计数器(PC,指向下一条指令在主存内的存放地址)、指令寄存器(IR,保存当前执行的指令)、指令译码器(对操作码字段进行译码,从而向控制器提供特定的操作信号)、存储器地址寄存器(MAR,存放要访问的主存单元的地址)、存储器数据寄存器(MDR,存放向主存写入的信息或是从主存读取到的信息)、时序系统(产生各种时序信号)、微操作信号发生器(根据IR、PSW的内容和时序信号,产生控制信号)。注意MAR、MDR和IR是用户不可见的。控制器的工作原理是根据指令操作码、微指令序列和条件信号来形成计算机各部件需要用到的控制信号。

另外,在现代处理器中,为了实现操作系统的虚拟内存功能,在CPU内部封装了一个内存管理单元(Memory Management Unit, MMU),用于实现虚拟地址和物理地址之间的相互转化。

阅读全文 »

应用层协议原理

概述

应用层的作用是为用户提供服务。应用层是协议簇的最高层,因此应用层协议不为任何其他协议提供服务,它们只接收来自于传输层协议的服务。

应用层核心:写出能够运行在不同端系统和通过网络彼此通信的程序,不需要在网络核心设备上如路由器、链路层交换机上运行的软件。

应用层模式

客户-服务器体系结构

在该体系结构中,有一个总是打开的主机,即服务器,它接收和服务来自其他许多被称为客户的主机请求;在该体系结构中,客户之间是不直接通信的;该服务器具有固定的、周知的地址。

客户-服务器体系结构的常见应用有:Web、FTP、Telnet和电子邮件。

这一体系结构对于服务器的性能要求较高。

阅读全文 »

数据的存储

数据的字长

计算机中,数据存储与访问的最小单位是字节。一个字节对应于8个二进制比特。一个字节可以表示的范围从\(00000000_2\sim 11111111_2\),这相当于十进制数的\(0\sim255\),或是十六进制数的\(00\sim FF\)

每台计算机都有一个字长,对应于指针类型数据的大小。由于指针的值是一个虚拟地址,因此字长也决定了虚拟地址空间的大小。例如32位的字长所能表示的虚拟空间为\(4\times 10^9\)字节(约4GB),而64位字长能表示的虚拟空间大小达\(1.84\times 10^{19}\)字节。64位的计算机上可以运行64位的程序,同时也可以兼容32位程序,而32位的计算机上只能运行32位的程序。

阅读全文 »

寄存器

  • 通用寄存器:X64将x86的8个通用寄存器扩展为64位,并且增加8个新的64位寄存器。64位寄存器命名以“r”开始,例如:eax扩展为64位就是rax,8个新的64位寄存器命名为r8到r15。每个寄存器的低32位,16位,8位可以作为操作数直接寻址,这包括向esi这样的寄存器,以前他的低8位不可以直接寻址。下表说明了64位通用寄存器的低位部分在汇编语言中的命名。

    除了r8~r15这8个寄存器只能供64位程序使用外,其余8个可以只使用低32字节以兼容32位程序。生成1字节和2字节数字的指令会保持剩下的字节不变;生成4字节数字的指令会把高位4个字节置为0。

    阅读全文 »

Overview

Introduction

Signature schemes allow a signer \(S\) who has established a public key \(pk\) to "sign" a message using the associated private key \(sk\) in such a way that anyone who knows \(pk\) (and knows that this public key was established by \(S\)) can verify that the message originated from \(S\) and was not modified in transit. (Note that the owner of the public key behaves as the sender, which is in contrast to the public-key encryption)

阅读全文 »

Math related with public-key encryption

Diffie-Hellman problems

Fix a cyclic group \(\mathbb{G}\) and a generator \(g\in \mathbb{G}\). Given elements \(h_{1},h_{2}\in \mathbb{G}\), define \(DH_{g}(h_{1},h_{2})=g^{log_{g}h_{1}\cdot log_{g}h_{2}}\). That is, if \(h_{1}=g^{x_{1}}\) and \(h_{2}=g^{x_{2}}\) then \[ DH_{g}(h_{1},h_{2})=g^{x_{1}\cdot x_{2}}=h_{1}^{x_{2}}=h_{2}^{x_{1}} \]

The computational Diffie-Hellman(CDH) problem is to compute \(DH_{g}(h_{1},h_{2})\) for uniform \(h_1\) and \(h_2\). It is not clear whether hardness of the discrete-logarithm problem implies that the CDH problem is hard as well.

阅读全文 »

Basic concepts

Definition

A hash function (with output length \(\ell\)) is a pair of probabilistic polynomial-time algorithms \((Gen,H)\) satisfying the following:

  • \(Gen\) is a probabilistic algorithm that takes as input a security parameter \(1^n\) and outputs a key \(s\). We assume that \(1^n\) is implicit in \(s\).
  • \(H\) takes as input a key \(s\) and a string \(x\in \{0,1\}^*\) and outputs a string \(H^{s}(x)\in \{0,1\}^{\ell(n)}\) (\(n\) is the security parameter implicit in \(s\)).

In general case, the function takes as input strings of arbitrary length. If \(H^s\) is defined only for inputs \(x\in\{0,1\}^{\ell '(n)}\) and \(\ell '(n)>\ell(n)\), then we say that \((Gen,H)\) is a fixed-length hash function for inputs of length \(\ell '\). In this case, \(H\) is also called a compression function.

阅读全文 »

Basic concepts

Message integrity

Message integrity (Message authentication): each party should be able to identify when a message it receives was sent by the party claiming to send it, and it was not modified in transit.

E.g. A bank should make sure a transfer request is sent by a legitimate user, and the received request should not be modified.

Remember that encryption does not privide any integrity unless it is specifically designed with that purpose!

阅读全文 »

Computational secure encryption

Perfect secrecy

Perfect secrecy: absolutely no information is leaked, even the eavesdropper has unlimited computational power(not practical in reality so it could be compromised in implementation).

Two attacks apply regardless of how the encryption scheme is constructed:

  1. Brute force attack: the adversary decrypt \(c\) using all keys \(k\in \mathcal{K}\).

  2. Random attack: the adversary guess a uniform key \(k\in \mathcal{K}\) and check to see whether \(Dec_{k}(c_{i})=m_{i}\) for all \(i\), which has success probability \(\frac{1}{|\mathcal{K}|}\).

    阅读全文 »

Basic concepts

What is cryptography?

The study of mathematical techniques for securing digital information, systems, and distributed computations against adversarial attacks.

Category

  • private(symmetric) key encryption: encryption and decryption use the same key.
  • public(asymmetric) key encryption: encryption and decryption use different keys.
    阅读全文 »