BitLocker 智能卡自签名证书

假定智能卡能被识别而且其中有自签名证书(如果是 YubiKey 可以参照这篇文章)。

修改注册表
将 HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\FVE 中的 DWORD 值 SelfSignedCertificates 设置为 1.

也可以把下面的文本保存为 REG 文件导入。

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\FVE]
"SelfSignedCertificates"=dword:00000001

Reference: Using Smart Cards with BitLocker

YubiKey PIV 配置

一般信息

默认 PIN 码为 123456. 默认PUK码为 12345678。

默认 3DES 管理密钥(9B)是 010203040506070801020304050607080102030405060708。

存在以下密钥槽:

  • 9A, 9C, 9D, 9E: RSA 1024, RSA 2048, or ECC secp256r1 keys (algorithms 6, 7, 11 respectively).
  • 9B: Triple-DES key (algorithm 3) for PIV management.

对于当前版本的 YubiKey NEO 和 YubiKey 4,存储对象的最大大小分别为 2025/3049 字节。

目前,所有功能都可通过接触式和非接触式接口获得(与规范要求相反)。

以上信息从 Yubico 网站翻译得来

配置

YubiKey PIV 接口在Windows中是只读智能卡,所以需要使用管理软件 YubiKey Manager 进行管理。先从官网下载并安装 YubiKey Manager。插入 YubiKey 并进入 PIV 设置。

YubiKey Manager
YubiKey Manager / PIV

首先需要设置 PIN 和 PUK,打开 Configure PINs > PIN 设置用户 PIN,如果 YubiKey 是第一次使用或者初始化过那可以勾选 “Use default”。PUK 同上,注意,PUK 可以直接重置 PIN,所以请务必设置,如果不需要 PUK 可以通过多次尝试错误 PUK 来屏蔽 PUK。

接下来还可以设置 Management Key,这个是为了保护 YubiKey 中的证书不被恶意修改的,可以不设置也可以设置。不设置的话默认值在一般信息中可以查找到。

最后就是导入证书了,YubiKey 有4个证书插槽,分别是 Authentication, Digital Signature, Key Management 和 Card Authentication(分别对应 9A, 9C, 9D, 9E)。其中 Digital Signature 插槽中的私钥操作每次都需要 PIN,而 Card Authentication 插槽永远不需要 PIN(但是我实测还是需要)。我的习惯是把证书导入 Authentication 和 Digital Signature(Digital Signature 的证书似乎不能用于 BitLocker)。

打开 Certificates 选择合适的插槽后选择“导入”或者“生成”证书,导入的话需要导入 PKCS#12 格式(PFX 或 P12 文件)的证书,如果之前是通过 CSR 向 CA 申请证书则需要导入 CA 签名后的 DES 格式证书。一般个人使用生成一张自签名证书即可。

YubiKey Manager / PIV / Certificates

注:Yubico 提供的 PIV 管理软件已经从 YubiKey PIV Manager 换成了 YubiKey Manager。经过我的测试, YubiKey PIV Manager 不支持 YubiKey 5 系列,但 YubiKey Manager 支持。

在 GitHub Desktop 中对 Commit 签名

GitHub 的文档中提到 GitHub Desktop 不支持签名,应用中也确实没有给出签名选项。不过,可以通过修改 GitHub Desktop 使用的 Git 的配置来签名。

首先打开 GitHub Desktop 的安装目录,Windows 一般在 “%USERPROFILE%/AppData/Local/GitHubDesktop” 下面。

可以看到几个 “app” 开头的、跟着版本号的目录,选择修改日期最近的那个目录,依次打开 resources/app/git/cmd 会看到 “git.exe”,在 “cmd” 目录里面打开命令提示符,用 git 命令配置 Commit 签名就可以了。下面的命令会默认对所有 Commit 签名。

git.exe config --global user.signingkey <Key ID>
git.exe config --global commit.gpgsign true

使用 TinyProxy 搭建代理服务器

安装

sudo apt update
sudo apt install tinyproxy

配置

TinyProxy配置文件位于
/etc/tinyproxy.conf

注释掉 Allow 127.0.0.1 即可允许任何局域网设备连接

管理服务

启动

sudo service tinyproxy start

停止

sudo service tinyproxy stop

重新启动

sudo service tinyproxy restart

YubiKey OTP 配置

YubiKey的OTP接口有两个插槽(slot),分别可以用来存放两个凭据(OTP、Static Password、HOTP-TOTP等)。OTP密码是长度为45的字符串,前12位是该OTP凭据的ID,后面的是一次性密码。(获取OTP可以打开记事本,把输入法换成英文,插入YubiKey,然后触摸一下金属圆盘)。

Yubico在生产YubiKey的时候会在插槽1放入一个OTP凭据,Yubico提供的凭据ID开头是“cc”,后期上传的凭据ID开头是“vv”。Yubico提供的OTP凭据是受信任的,后期上传的没有出厂自带的那么可信,因为在传输和保存的时候私钥可能会泄露。这是官方的说法:’vv‘ prefix credentials are not guaranteed to have the same availability as production ‘cc’ prefix credentials. Yubico reserves the right to revoke any ‘vv‘ prefix credential on the Yubico validation service (YubiCloud) at any time, for any reason, including if abuse is detected or if the credential is loaded onto a counterfeit YubiKey. (From Yubico AES Key Upload)

注意,YubiCloud不允许“cc”开头的凭据ID上传,你可以在YubiKey Personalization Tool上面生成“cc”甚至别的开头的凭据,不过只能上传到自己或第三方建立的OTP验证服务器上。

管理OTP接口

我们可以使用YubiKey Personalization Tool来管理YubiKey的OTP接口(YubiKey Personalization Tool支持命令行,这里只介绍GUI的使用,Linux下可以PPA安装),我们可以从Yubico支持页面获得YubiKey Personalization Tool。

YubiKey Personalization Tool

在YubiKey Personalization Tool中点“Yubico OTP”,然后点击“Quick”或者“Advanced”就可以管理YubiKey的OTP接口,一般来说,Slot 1不进行改变。

如果要增加一个OTP凭据,插入YubiKey,选择“Configuration Slot 2”,然后点击“Regenerate”来生成一个凭据(这里可以多点几次增加随机数的熵),如果需要使用第三方验证服务器那需要记下所有文本框中的内容,之后点“Write Configuration”向YubiKey中写入配置。写入完后需要上传凭据到YubiCloud,工具会要求你打开一个网站,工具会自动在网站中填充刚刚生成的凭据,点击上传即可。

提示:在生成凭据的时候,请使用一台受信任的电脑。在上传凭据时,确保使用HTTPS连接并确认网站的SSL证书是由受信任的CA颁发的。

YubiKey 介绍

介绍

YubiKey是由Yubico生产的身份认证设备,支持一次性密码(OTP)、公钥加密和身份认证,以及由FIDO联盟(FIDO U2F)开发的通用第二因素(U2F)协议。它让用户可以透过提交一次性密码或是使用设备产生的公开/私密金钥来安全地登录自己的帐户。针对不支持一次性密码的网站,YubiKey也可以存储静态密码。Facebook使用YubiKey作为员工凭证;Google同时为雇员和用户提供支持。还有一些密码管理器也支持YubiKey。 (YubiKey – 维基百科

YubiKey 5 NFC

YubiKey每个系列有多个版本,分别支持USB-A、USB-C和NFC接口。NANO版本非常小,适合一直放在USB口里面。还有一个Security Key by Yubico,只支持FIDO U2F和FIDO2,不支持别的接口(比如OTP),不推荐购买。还有FIPS版本,支持FIPS 140-2,应该是用来存放证书的(比如文档、代码的签名证书),没有需求不推荐购买。

最近Yubico出了新的YubiKey 5系列,在YubiKey 4系列的基础下增加了FIDO2和NFC(只有YubiKey 5 NFC支持)。目前淘宝上有卖但是价格很高,我的YubiKey 5 NFC是在官网买的, 价格45刀。

接口

YubiKey支持如下接口:
U2F
FIDO2 (YubiKey 5 Series & Security Key by Yubico only)
OTP
OATH
OpenPGP
PIV

U2F

U2F(通用第二因素),是一种开放的标准,通过USB和NFC验证用户对设备的访问权。通过USB验证时,YubiKey作为HID设备使用 。目前很多应用(Google、GitHub、DropBox、Facebook、Twitter等)都采用这个标准,U2F验证的方式是服务器提交质询(challenge),设备用私钥签名,返回响应(response)。特点是要求直接的USB访问而且验证的时候没有输入框,所以远程桌面的时候一般都不能用U2F。

index__1.png
The basic process flow of U2F (From Yubico)

FIDO2

FIDO2是FIDO联盟开发的提供免密码认证的协议,只有 YubiKey 5 Series 和 Security Key by Yubico 支持。应用方面目前只有微软支持,Windows 10 Insider Preview 版本现在可以在设置里面调整FIDO2设置(不要点重置安全密钥,可能会导致OTP和U2F凭据丢失),需要把Microsoft Account网页调成英语才能设置,这个协议我没有过多的了解,附上官方的网页。

FIDO2

OTP

OTP(一次性密码)是Yubico自己的协议,在进行OTP验证时,YubiKey作为HID设备使用。触摸YubiKey上面的金属圆盘即可激活并向电脑输入一串字符,前12位是密钥ID,后面是一次性密码。服务器与YubiKey拥有同样的密钥,验证时使用Yubico的私有算法计算一次性密码进行验证,通过计数器防止重放攻击。YubiKey有两个OTP插槽(slot),出厂时插槽1会自带一个密钥(已经被安全地保存到YubiCloud服务器),出厂密钥的ID是c开头的,自己生成的是v开头的。对个人来说出厂密钥是最可靠的。YubiKey OTP插槽中的密钥可以手动生成,但是不可以导出,因此千万不要手欠删除出厂密钥,我之前在搞FIDO2的时候重置了OTP插槽,就再也弄不回来了。

OATH

YubiKey的OATH接口与别的接口不同,它并不直接进行身份认证,它更接近手机上的谷歌身份验证器。OATH用于存储HOTPTOTP凭据,大多数应用的两步认证都支持它们。

OpenPGP

YubiKey可以被识别成OpenPGP智能卡,可以存放OpenPGP证书的私钥。

PIV

PIV接口可以存放X.509证书,用于代码和文档签名。Windows会把YubiKey识别为智能卡,可以用于EFS,Bitlocker好像因为证书问题不行(更新:已经解决Bitlocker证书问题,参考这篇文章)。

The Machine Learning

The tremendous development of artificial intelligence technology in recent years has made this technology famous, people even can hear this word from a primary school student who just knows how to type. However, as an important part of artificial intelligence, “machine learning” is not so famous. However, machine learning is a shortcut to “intimate contact” between ordinary people and artificial intelligence, even if they do not have in-depth study in computer science.

So, what is machine learning? You can simply understand from the literal meaning: give computers the ability to “learn”. Machine learning is a very interesting technique. It uses technical means to enable computers to analyze the information they receive and to form an “understanding” of the information. Machine learning is a very esoteric technique, but it is friendlier to the average user than to the developer. In other words, if people don’t plan to write a machine learning algorithm and just apply machine learning, it will be very simple and attractive.

In order to make simple use of existing machine learning techniques, we can use some open source libraries to achieve. For example, for most students, writing a TOEFL essay is a painful thing, and if we look through common machine learning documents, we will find a library called “scikit” for literary analysis such as semantic recognition. Therefore, we only need to write a program that uses this library (this is still difficult, but obviously it’s easier than writing a machine learning algorithm from the beginning, and it seems to have been written by some machine learning experts). So, we just import a few TOEFL essays we wrote before (this is called “training”), and then import a sample of the TOEFL essay you are about to write, the computer can analyze your logic, style and other writing habits and the sample. Then, rewrite “your own” TOEFL essay, does this sound great? (I am not trying to provide a lazy way to write a TOEFL essay, it is important to learn English well) Of course, machine learning can do a lot of other things like face recognition, OCR, even Alpha Go uses machine learning. So, machine learning fascinates me because machine learning can provide a quick way for ordinary people to solve practical problems.

[转载] Ubuntu 18.04 安装 Docker

第一种方法

从Ubuntu的仓库直接下载安装。安装比较简单,这种安装的Docker不是最新版本,不过对于学习够用了,依次执行下面命令进行安装。

$ sudo apt install docker.io

启动Docker服务:

$ sudo systemctl start docker
$ sudo systemctl enable docker

查看是否安装成功:

$ docker -v
Docker version 17.12.1-ce, build 7390fc6

第二种方法

从Docker仓库下载安装。这种安装方式首先要保证Ubuntu服务器能够访问Docker仓库地址:https://download.docker.com/linux/ubuntu,如果能够访问,按照下面的操作步骤进行安装。

$ sudo apt update
$ sudo apt install apt-transport-https ca-certificates curl software-properties-common

在/etc/apt/sources.list.d/docker.list文件中添加下面内容:

deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable

添加秘钥

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

安装docker-ce

$ sudo apt install docker-ce

查看是否安装成功:

$ docker -v
Docker version 18.03.1-ce, build 9ee9f40
原帖地址:https://blog.csdn.net/u010889616/article/details/80170767
作者:dmfrm

No more bugs, please!

In general, I am a normal person, which means that I don’t have any special skill. But there is a skill or ability that I really want, is to write code without bugs.

Let me explain this, programming is my hobby. However, when people write code, they make some logic, structure, and syntax errors. These errors are called “bugs.” For all programmers, it is annoying to have bugs in the code. I sometimes spent hours checking a large program and finally found a missing colon in a certain part of a line, what’s more, when the logic of the program goes wrong, people even need to rewrite the whole program to correct these errors. So, bugs may be the second thing that programmers hate. However, bugs in the code are almost inevitable, and someone even joked that programmers and bugs are inseparable. Therefore, I, or almost all programmers, have a dreaming ability (in my opinion, “super power”): no bugs when writing code.

Although this ability seems impossible to obtain, it is also a good thing to have a good dream.

printf("Hello World")
printf("There is a bug above!");

If I am the supreme leader of the world

First of all, I need to declare that it is simply impossible to become a “supreme leader” in today’s world. The following text is full of conjectures, hope they will never appear in the real world.

I can imagine how I became the supreme leader, a possible way is: I created a company, after decades of operation, the company has mastered most of the world’s money and resources. Then I use my huge assets to subvert the governments and other organizations in the world. Finally, I become the leader of the world.

As for how I will manage the world, since there is a “supreme leader”, I must be a dictator. As a dictator, in order to maintain my dictatorship, several necessary steps need to be taken. I will try to wipe everything that is against me from the earth. And to control people’s thinking, I will promote “hero-worship” in the world and the object is me, also I will monitor the communication of all citizens. Modify the language when necessary to make people unable to think about things that against me. After these steps, I will try to rebuild the history, because history is the only way people can know about the past, once history is wiped and rebuilt in the direction that I want, there is no reason to against my rule because nobody can give a standard of “better life”. Finally, I will establish a legal system that seems fair and reasonable (Just like Hangzhou $#@ $#$#& %&#%&@%&$$% &%@#[email protected]*# did), this will ensure nobody will even feel the anomaly of the world.