MATH 165FS 密码学 Cryptography and Society 杜克大学

Introduction to topics in mathematical cryptography, and the role of cryptography within society, in both historic and modern contexts. Cryptographic systems studied will include: early historical ciphers; the Enigma machines of WWII; modern public channel cryptography. Students will learn: to encode/decode using each system; to quantify the complexity, strength, and weaknesses of each system; to use elementary techniques from combinatorics, graph theory, abstract algebra, and number theory; about the role cryptography plays in human society. Open only to students in the Focus Program. Department consent required.

Content: Cryptography is the process of hiding or encrypting information so that only the recipient of the information can read it. Cryptography has been used for thousands of years to encrypt information and is still used today for bank cards, computer passwords and e-commerce transactions.

MATH 165FS 密码学 Cryptography and Society 杜克大学
问题 1.

OCTET STRING encoding is by far the simplest to process. There are no invalid inputs to the encoder and the payload length is equal to the length of the input.
001 #include "asn1.h"
002 unsigned long der_octetstring_length (unsigned long noctets)
003 { return der_length(noctets);
$005 \quad} \quad$
der_octetstring_length.c :
001 #include "asn1.h"
002 unsigned long der_octetstring_length(unsigned long noctets)
004 return der_length(noctets);

This rather simple looking function computes the DER encoded length of an OCTET STRING with a given number of octets.

der_octetstring_encode.c :
001 \#include "asn $1 . \mathrm{h}$ "
002 int der_octetstring_encode(unsigned char *octets,
003 unsigned long noctets,
004 unsigned char *out,
005 unsigned long *outlen)
$007 /$ * check output size */
008 if (der_octetstring_length(noctets) > outlen) \{
009 return -1 ;
$012 /$ * store header and length */
013 der_put_header_length (\&out, ASN1_DER_OCTETSTRING,
014 noctets, outlen);
$016 /$ * store bytes */
017 memcpy (out, octets, noctets);
019 return 0 ;
问题 2.

Why isn’t a format like XML used?

The standards were written nearly a decade before XML was even a twinkle in the Tim

Bray’s eye. Despite the fact that ASN.1 predates XML, it is still not the only reason that

ASN.1 is preferred over XML. XML is huge in comparison to its ASN.1 equivalent.

This makes it less well adapted to use in hardware where memory constraints are tight.

Since a lot of cryptography is done on devices with very little memory (smart-cards are

a good example of this), it makes sense to use a compact format. It’s funny that many

people are clamoring for a binary version of XML with the view to speeding up parsing

and reducing size when a perfectly good standard that meets these requirements has

been in place since the 80s.


针对 Cryptography and Society 推荐三本教材:

✅ Cryptography In The Information Society 

✅ Foundations of Cryptography

✅ Cryptography and Data Security


  • 密码学的基础数学教材有:数论,有限域,离散数学,另外还可以选择性翻阅组合数学、概率论与数理统计、线性代数
  • 前三本是比较基础的,理解常规的对称加密算法比如DES,AES可能不需要太多的数学知识,但是公钥加密算法中比如RSA、椭圆曲线密码学(ECC)等涉及到群、域以及质数、大数分解等方面的知识,所以如果要对其原理理解的比较透彻,是要好好学习的。