Changeset View
Changeset View
Standalone View
Standalone View
crypto/openssh/sshbuf.h
Show First 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | |||||
int sshbuf_get_u32(struct sshbuf *buf, u_int32_t *valp); | int sshbuf_get_u32(struct sshbuf *buf, u_int32_t *valp); | ||||
int sshbuf_get_u16(struct sshbuf *buf, u_int16_t *valp); | int sshbuf_get_u16(struct sshbuf *buf, u_int16_t *valp); | ||||
int sshbuf_get_u8(struct sshbuf *buf, u_char *valp); | int sshbuf_get_u8(struct sshbuf *buf, u_char *valp); | ||||
int sshbuf_put_u64(struct sshbuf *buf, u_int64_t val); | int sshbuf_put_u64(struct sshbuf *buf, u_int64_t val); | ||||
int sshbuf_put_u32(struct sshbuf *buf, u_int32_t val); | int sshbuf_put_u32(struct sshbuf *buf, u_int32_t val); | ||||
int sshbuf_put_u16(struct sshbuf *buf, u_int16_t val); | int sshbuf_put_u16(struct sshbuf *buf, u_int16_t val); | ||||
int sshbuf_put_u8(struct sshbuf *buf, u_char val); | int sshbuf_put_u8(struct sshbuf *buf, u_char val); | ||||
#if defined(__FreeBSD__) && defined(__i386__) | |||||
#define sshbuf_get_time(b, vp) sshbuf_get_u32((b), (u_int32_t *)(vp)) | |||||
#define sshbuf_put_time(b, v) sshbuf_put_u32((b), (u_int32_t)(v)) | |||||
#else | |||||
#define sshbuf_get_time(b, vp) sshbuf_get_u64((b), (u_int64_t *)(vp)) | |||||
#define sshbuf_put_time(b, v) sshbuf_put_u64((b), (u_int64_t)(v)) | |||||
#endif | |||||
/* | /* | ||||
* Functions to extract or store SSH wire encoded strings (u32 len || data) | * Functions to extract or store SSH wire encoded strings (u32 len || data) | ||||
* The "cstring" variants admit no \0 characters in the string contents. | * The "cstring" variants admit no \0 characters in the string contents. | ||||
* Caller must free *valp. | * Caller must free *valp. | ||||
*/ | */ | ||||
int sshbuf_get_string(struct sshbuf *buf, u_char **valp, size_t *lenp); | int sshbuf_get_string(struct sshbuf *buf, u_char **valp, size_t *lenp); | ||||
int sshbuf_get_cstring(struct sshbuf *buf, char **valp, size_t *lenp); | int sshbuf_get_cstring(struct sshbuf *buf, char **valp, size_t *lenp); | ||||
int sshbuf_get_stringb(struct sshbuf *buf, struct sshbuf *v); | int sshbuf_get_stringb(struct sshbuf *buf, struct sshbuf *v); | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
int sshbuf_b64tod(struct sshbuf *buf, const char *b64); | int sshbuf_b64tod(struct sshbuf *buf, const char *b64); | ||||
/* | /* | ||||
* Duplicate the contents of a buffer to a string (caller to free). | * Duplicate the contents of a buffer to a string (caller to free). | ||||
* Returns NULL on buffer error, or if the buffer contains a premature | * Returns NULL on buffer error, or if the buffer contains a premature | ||||
* nul character. | * nul character. | ||||
*/ | */ | ||||
char *sshbuf_dup_string(struct sshbuf *buf); | char *sshbuf_dup_string(struct sshbuf *buf); | ||||
/* | |||||
* store struct pwd | |||||
*/ | |||||
int sshbuf_put_passwd(struct sshbuf *buf, const struct passwd *pwent); | |||||
/* | |||||
* extract struct pwd | |||||
*/ | |||||
struct passwd *sshbuf_get_passwd(struct sshbuf *buf); | |||||
/* | |||||
* free struct passwd obtained from sshbuf_get_passwd. | |||||
*/ | |||||
void sshbuf_free_passwd(struct passwd *pwent); | |||||
/* Macros for decoding/encoding integers */ | /* Macros for decoding/encoding integers */ | ||||
#define PEEK_U64(p) \ | #define PEEK_U64(p) \ | ||||
(((u_int64_t)(((const u_char *)(p))[0]) << 56) | \ | (((u_int64_t)(((const u_char *)(p))[0]) << 56) | \ | ||||
((u_int64_t)(((const u_char *)(p))[1]) << 48) | \ | ((u_int64_t)(((const u_char *)(p))[1]) << 48) | \ | ||||
((u_int64_t)(((const u_char *)(p))[2]) << 40) | \ | ((u_int64_t)(((const u_char *)(p))[2]) << 40) | \ | ||||
((u_int64_t)(((const u_char *)(p))[3]) << 32) | \ | ((u_int64_t)(((const u_char *)(p))[3]) << 32) | \ | ||||
((u_int64_t)(((const u_char *)(p))[4]) << 24) | \ | ((u_int64_t)(((const u_char *)(p))[4]) << 24) | \ | ||||
▲ Show 20 Lines • Show All 93 Lines • Show Last 20 Lines |