Also known as "DK" in RFC3961.
(cls, key, constant)
| 496 | |
| 497 | @classmethod |
| 498 | def derive(cls, key, constant): |
| 499 | # type: (Key, bytes) -> bytes |
| 500 | """ |
| 501 | Also known as "DK" in RFC3961. |
| 502 | """ |
| 503 | # RFC 3961 only says to n-fold the constant only if it is |
| 504 | # shorter than the cipher block size. But all Unix |
| 505 | # implementations n-fold constants if their length is larger |
| 506 | # than the block size as well, and n-folding when the length |
| 507 | # is equal to the block size is a no-op. |
| 508 | plaintext = _n_fold(constant, cls.blocksize) |
| 509 | rndseed = b"" |
| 510 | while len(rndseed) < cls.seedsize: |
| 511 | ciphertext = cls.basic_encrypt(key.key, plaintext) |
| 512 | rndseed += ciphertext |
| 513 | plaintext = ciphertext |
| 514 | # DK(Key, Constant) = random-to-key(DR(Key, Constant)) |
| 515 | return cls.random_to_key(rndseed[0 : cls.seedsize]).key |
| 516 | |
| 517 | @classmethod |
| 518 | def encrypt(cls, key, keyusage, plaintext, confounder, signtext=None): |
nothing calls this directly
no test coverage detected