File: README.md

package info (click to toggle)
glome 0.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 716 kB
  • sloc: ansic: 2,468; python: 508; sh: 149; makefile: 20
file content (85 lines) | stat: -rw-r--r-- 2,316 bytes parent folder | download | duplicates (2)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# PyGLOME
**This is not an officially supported Google product.**

This repository contains a Python implementation for the GLOME
protocol. You can find the library in the folder pyglome. The test
files can be found in the test folder.

## Python API

### Requirements

-   Python >= 3.6
-   pyca/cryptography >= 2.5

### Example

We provide a brief example of use.  In order for Alice and Bob to communicate,
the first step would be to generate some new keys:

```python
import pyglome

alice_keys = pyglome.generate_keys()
bob_keys = pyglome.generate_keys()
```

Suppose that Alice knows Bob's `public_key` and wants to send Bob the message
`msg` and no other message have been shared before. Alice will need to:

```python
glome = pyglome.Glome(bob_keys.public, alice_keys.private)
first_tag = glome.tag(msg, counter=0)
```

And Alice will send Bob both `msg`, `first_tag` as well as Alice's public key.
On Bob's end he will need to do the following:

```python
glome = pyglome.Glome(alice_keys.public, bob_keys.private)
try:
    glome.check(first_tag, msg, counter=0)
except pyglome.TagCheckError as tag_error:
    ## Handle the exception.
## do what you have to do
```

### Key generation.

Should you want to use a preexisting key, it should match the format
`X25519Private/PublicKey` provided in [pyca/cryptography](https://cryptography.io/en/latest/).
Such a key can be easily read from a bytes object as follows:

```python
from cryptography.hazmat.primitives.asymmetric import x25519
my_private_key = x25519.X25519PrivateKey.from_private_bytes(private_key_bytes)
my_public_key = x25519.X25519PublicKey.from_public_bytes(public_key_bytes)
```

We provide a key generation function `generate_keys` that uses these methods to
create a new key pair from `os.urandom` bytes.

### Documentation

For more information see the in-code documentation.

### Test

In the test folder we have scripts that implement test classes based on unittest. To run all unittest use:

```
python -m test
```
from this directory. If you only want to execute a particular test module, then run:

```
python -m test.my_module_name
```

where `my_module_name` is the name of the test module to be executed (the name of the file without the .py). 

To run the fuzzing test use:
```
python -m test.fuzzing_test
```
from this directory.