Skip to content

Commit a863e15

Browse files
seebeesjosecorella
authored andcommitted
feat: Updating the CMC specification (#60)
Moving some of the interface from the local CMC to the CMC Interface. Using the CMC requires a consistent interface. Currently the Caching CMM has an interface that relies on the Local CMC. This means that if a CMC was created according to the specification it would not function correctly.
1 parent ad2f0b1 commit a863e15

File tree

2 files changed

+55
-27
lines changed

2 files changed

+55
-27
lines changed

framework/cryptographic-materials-cache.md

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
### Changelog
1111

12+
- 0.4.0
13+
- Updating the interface. Moving elements from the Local CMC to the interface.
1214
- 0.3.0
1315
- [Return Nothing from Put Cache Entry in Cryptographic Materials Cache](../changes/2020-07-20_put-cache-entry-returns-nothing/change.md)
1416
- 0.2.0
@@ -42,19 +44,25 @@ in this document are to be interpreted as described in [RFC 2119](https://tools.
4244

4345
### Cache Identifier
4446

45-
The cache identifier used to uniquely identify a single cache entry in the cryptographic materials cache.
47+
The cache identifier used to uniquely identify a single cache entry
48+
in the cryptographic materials cache.
4649

4750
### Cache Entry
4851

49-
A cache entry represents an entry in the cryptographic materials cache.
50-
A cache entry contains the cryptographic materials, [encryption](structures.md#encryption-materials) or [decryption](structures.md#decryption-materials)
51-
materials to be cached along with other metadata.
52-
Some implementations of the CMC have the following metadata:
52+
A cache entry represents an entry in the cryptographic materials cache
53+
and MUST have the following information.
5354

55+
- [Materials](#materials)
5456
- [Creation Time](#creation-time)
5557
- [Expiry Time](#expiry-time)
5658
- [Usage Metadata](#usage-metadata)
5759

60+
#### Materials
61+
62+
The cryptographic materials,
63+
[encryption](structures.md#encryption-materials) or [decryption](structuresmd#decryption-materials)
64+
materials to be cached along with other metadata.
65+
5866
#### Creation Time
5967

6068
Timestamp when the cache entry was created.
@@ -70,13 +78,32 @@ The usage metadata is of the following two types:
7078
- [Messages Usage](#message-usage)
7179
- [Bytes Usage](#bytes-usage)
7280

81+
Updating usage metadata SHOULD be atomic.
82+
7383
##### Message Usage
7484

75-
The number of messages encrypted by the [encryption](structures.md#encryption-materials) materials cached in this cache entry.
85+
The number of messages encrypted
86+
by the [encryption materials](structures.md#encryption-materials)
87+
cached in this cache entry.
7688

7789
##### Bytes Usage
7890

79-
The number of bytes encrypted by the [encryption](structures.md#encryption-materials) materials cached in this cache entry.
91+
The number of bytes encrypted by the [encryption materials](structures.md#encryption-materials)
92+
cached in this cache entry.
93+
94+
### Time-to-live (TTL)
95+
96+
Each cache entry has a time-to-live (TTL)
97+
that represents a point in time at which the cache entry
98+
MUST be considered invalid.
99+
This is generale the [expiry time](#expiry-time).
100+
After a cache entry's TTL has elapsed,
101+
we say that the entry is _TTL-expired_,
102+
and a CMC MUST NOT return the entry to any caller.
103+
104+
However the [creation time](#creation-time) is also include
105+
in case a stricter view of TTL is enforced by a caller.
106+
This can be done by deleting the entry.
80107

81108
## Supported CMCs
82109

@@ -86,19 +113,26 @@ It provides non-blocking, locking, [cache entries](#cache-entry) per [cache iden
86113

87114
## Behaviors
88115

89-
The Cryptographic Materials Cache provides behaviours for putting cache entries, getting cache entries and deleting cache entries.
116+
The Cryptographic Materials Cache
117+
provides behaviors for putting cache entries,
118+
getting cache entries and deleting cache entries.
90119

91120
### Put Cache Entry
92121

93122
Attempts to put a cache entry for the specified cache ID.
94-
If a cache entry for the given cache ID does not exists in the cache, the CMC creates a new cache entry.
123+
If a cache entry for the given cache ID does not exists in the cache,
124+
the CMC creates a new cache entry.
95125
This operation MUST NOT return the inserted cache entry.
126+
The cache entry MUST include all [usage metadata](#usage-metadata)
127+
since this information can not be updated after the put operation.
96128

97129
### Get Cache Entry
98130

99131
Attempts to get a cache entry for the specified cache ID.
100-
The CMC MUST validate that the cache entry is valid prior to returning the cache entry.
101-
A successful call to Get Entry returns the [cache entry](#cache-entry) and an unsuccessful call returns a cache miss.
132+
The CMC MUST validate that the cache entry
133+
has not exceeded it's stored [TTL](#time-to-live-ttl).
134+
A successful call to Get Entry returns the [cache entry](#cache-entry)
135+
and an unsuccessful call returns a cache miss.
102136

103137
### Delete Cache Entry
104138

framework/local-cryptographic-materials-cache.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
### Changelog
99

10+
- 0.2.0
11+
12+
- Updating the interface. Moving elements from the Local CMC to the interface.
13+
1014
- 0.1.0
1115
- Initial record
1216
- [Refactor Cryptographic Materials Cache Specification](../changes/2020-07-14_refactor-cmc-spec/change.md)
@@ -36,14 +40,6 @@ per [cache identifier](cryptographic-materials-cache.md#cache-identifier).
3640
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL"
3741
in this document are to be interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119).
3842

39-
### Time-to-live (TTL)
40-
41-
Each cache entry has a time-to-live (TTL) field
42-
that represents a point in time at which the cache entry MUST be considered invalid.
43-
After a cache entry's TTL has elapsed,
44-
we say that the entry is _TTL-expired_,
45-
and the local CMC MUST NOT return the entry to any caller.
46-
4743
## Initialization
4844

4945
On initialization of the local CMC,
@@ -74,18 +70,14 @@ for TTL-expired entries to evict.
7470

7571
### Put Cache Entry
7672

77-
When calling the Put Cache Entry operation,
78-
the caller MUST provide a time delta value,
79-
which the local CMC uses to derive the cache entry's time-to-live (TTL) value.
80-
The local CMC MUST NOT return any TTL-expired entry.
81-
8273
When performing a Put Cache Entry operation,
83-
the local CMC MUST [prune TTL-expired cache entries](#pruning).
74+
the local CMC should not [prune TTL-expired cache entries](#pruning).
75+
This is because an entry is added after a get miss.
76+
A prune happens during the get operation.
8477

8578
While performing a Put Cache Entry operation,
8679
the local CMC MAY store more entries than the entry capacity.
87-
However, before returning the inserted cache entry,
88-
the local CMC MUST evict least-recently used entries
80+
However, before returning, the local CMC MUST evict least-recently used entries
8981
until the number of stored entries does not exceed the entry capacity.
9082

9183
### Get Cache Entry
@@ -100,6 +92,8 @@ To prune TTL-expired cache entries,
10092
the local CMC MUST evict all TTL-expired entries
10193
among the `N` least recently used entries,
10294
where `N` is the [Entry Pruning Tail Size](#entry-pruning-tail-size).
95+
This means that a maximum of `N` entries
96+
and a minimum of `0` entries will be evicted.
10397

10498
The local CMC SHOULD also periodically evict all TTL-expired entries
10599
among the `N` least recently used entries.

0 commit comments

Comments
 (0)