include/crypto/curve25519.h

Source file repositories/reference/linux-study-clean/include/crypto/curve25519.h

File Facts

System
Linux kernel
Corpus path
include/crypto/curve25519.h
Extension
.h
Size
1123 bytes
Lines
44
Domain
Repository Root And Misc
Bucket
include
Inferred role
Repository Root And Misc: implementation source
Status
source implementation candidate

Why This File Exists

Top-level or miscellaneous repository surface. Use this as map coverage unless a later manual pass promotes the file into a deeper subsystem dossier.

Dependency Surface

Detected Declarations

Annotated Snippet

#ifndef CURVE25519_H
#define CURVE25519_H

#include <linux/types.h>
#include <linux/random.h>

enum curve25519_lengths {
	CURVE25519_KEY_SIZE = 32
};

void curve25519_generic(u8 out[at_least CURVE25519_KEY_SIZE],
			const u8 scalar[at_least CURVE25519_KEY_SIZE],
			const u8 point[at_least CURVE25519_KEY_SIZE]);

bool __must_check
curve25519(u8 mypublic[at_least CURVE25519_KEY_SIZE],
	   const u8 secret[at_least CURVE25519_KEY_SIZE],
	   const u8 basepoint[at_least CURVE25519_KEY_SIZE]);

bool __must_check
curve25519_generate_public(u8 pub[at_least CURVE25519_KEY_SIZE],
			   const u8 secret[at_least CURVE25519_KEY_SIZE]);

static inline void
curve25519_clamp_secret(u8 secret[at_least CURVE25519_KEY_SIZE])
{
	secret[0] &= 248;
	secret[31] = (secret[31] & 127) | 64;
}

static inline void
curve25519_generate_secret(u8 secret[at_least CURVE25519_KEY_SIZE])
{
	get_random_bytes_wait(secret, CURVE25519_KEY_SIZE);
	curve25519_clamp_secret(secret);
}

#endif /* CURVE25519_H */

Annotation

Implementation Notes