Commit e6782e05 authored by Niels Möller's avatar Niels Möller

Moved all typedefs for function types to nettle-types.h. Use

non-pointer types, so that the types can be used to declare functions.
Updated all users.

Rev: nettle/arcfour-meta.c:1.2
Rev: nettle/cbc.h:1.2
Rev: nettle/des-compat.c:1.2
Rev: nettle/examples/nettle-benchmark.c:1.3
Rev: nettle/examples/nettle-openssl.c:1.2
Rev: nettle/examples/rsa-encrypt.c:1.2
Rev: nettle/examples/rsa-keygen.c:1.2
Rev: nettle/nettle-internal.c:1.2
Rev: nettle/nettle-meta.h:1.2
Rev: nettle/nettle-types.h:1.2
Rev: nettle/testsuite/dsa-keygen-test.c:1.3
Rev: nettle/testsuite/rsa-encrypt-test.c:1.3
Rev: nettle/testsuite/rsa-keygen-test.c:1.3
Rev: nettle/testsuite/testutils.c:1.3
parent d2ea4c93
......@@ -31,8 +31,8 @@
const struct nettle_cipher nettle_arcfour128 =
{ "arcfour128", sizeof(struct arcfour_ctx),
0, 16,
(nettle_set_key_func) arcfour_set_key,
(nettle_set_key_func) arcfour_set_key,
(nettle_crypt_func) arcfour_crypt,
(nettle_crypt_func) arcfour_crypt
(nettle_set_key_func *) arcfour_set_key,
(nettle_set_key_func *) arcfour_set_key,
(nettle_crypt_func *) arcfour_crypt,
(nettle_crypt_func *) arcfour_crypt
};
......@@ -57,14 +57,14 @@ memcpy((ctx)->iv, (data), sizeof((ctx)->iv))
#define CBC_ENCRYPT(self, f, length, dst, src) \
(0 ? ((f)(&(self)->ctx, 0, NULL, NULL)) \
: cbc_encrypt((void *) &(self)->ctx, \
(nettle_crypt_func) (f), \
(nettle_crypt_func *) (f), \
sizeof((self)->iv), (self)->iv, \
(length), (dst), (src)))
#define CBC_DECRYPT(self, f, length, dst, src) \
(0 ? ((f)(&(self)->ctx, 0, NULL, NULL)) \
: cbc_decrypt((void *) &(self)->ctx, \
(nettle_crypt_func) (f), \
(nettle_crypt_func *) (f), \
sizeof((self)->iv), (self)->iv, \
(length), (dst), (src)))
......
......@@ -113,13 +113,13 @@ des_ncbc_encrypt(const_des_cblock *src, des_cblock *dst, long length,
switch (enc)
{
case DES_ENCRYPT:
nettle_cbc_encrypt(ctx, (nettle_crypt_func) des_encrypt,
nettle_cbc_encrypt(ctx, (nettle_crypt_func *) des_encrypt,
DES_BLOCK_SIZE, *iv,
length, *dst, *src);
break;
case DES_DECRYPT:
nettle_cbc_decrypt(ctx,
(nettle_crypt_func) des_decrypt,
(nettle_crypt_func *) des_decrypt,
DES_BLOCK_SIZE, *iv,
length, *dst, *src);
break;
......@@ -166,12 +166,12 @@ des_ede3_cbc_encrypt(const_des_cblock *src, des_cblock *dst, long length,
switch (enc)
{
case DES_ENCRYPT:
nettle_cbc_encrypt(&keys, (nettle_crypt_func) des_compat_des3_encrypt,
nettle_cbc_encrypt(&keys, (nettle_crypt_func *) des_compat_des3_encrypt,
DES_BLOCK_SIZE, *iv,
length, *dst, *src);
break;
case DES_DECRYPT:
nettle_cbc_decrypt(&keys, (nettle_crypt_func) des_compat_des3_decrypt,
nettle_cbc_decrypt(&keys, (nettle_crypt_func *) des_compat_des3_decrypt,
DES_BLOCK_SIZE, *iv,
length, *dst, *src);
break;
......
......@@ -86,7 +86,7 @@ time_function(void (*f)(void *arg), void *arg)
struct bench_hash_info
{
void *ctx;
nettle_hash_update_func update;
nettle_hash_update_func *update;
const uint8_t *data;
};
......@@ -100,7 +100,7 @@ bench_hash(void *arg)
struct bench_cipher_info
{
void *ctx;
nettle_crypt_func crypt;
nettle_crypt_func *crypt;
uint8_t *data;
};
......@@ -114,7 +114,7 @@ bench_cipher(void *arg)
struct bench_cbc_info
{
void *ctx;
nettle_crypt_func crypt;
nettle_crypt_func *crypt;
uint8_t *data;
......
......@@ -50,20 +50,21 @@
/* AES */
static nettle_set_key_func openssl_aes_set_encrypt_key;
static void
openssl_aes_set_encrypt_key(void *ctx, unsigned length, const uint8_t *key)
{
AES_set_encrypt_key(key, length * 8, ctx);
}
static nettle_set_key_func openssl_aes_set_decrypt_key;
static void
openssl_aes_set_decrypt_key(void *ctx, unsigned length, const uint8_t *key)
{
AES_set_decrypt_key(key, length * 8, ctx);
}
static nettle_crypt_func openssl_aes_encrypt;
static void
openssl_aes_encrypt(void *ctx, unsigned length,
uint8_t *dst, const uint8_t *src)
......@@ -78,6 +79,7 @@ openssl_aes_encrypt(void *ctx, unsigned length,
}
}
static nettle_crypt_func openssl_aes_decrypt;
static void
openssl_aes_decrypt(void *ctx, unsigned length,
uint8_t *dst, const uint8_t *src)
......@@ -123,14 +125,14 @@ nettle_openssl_aes256 = {
};
/* Arcfour */
static nettle_set_key_func openssl_arcfour_set_key;
static void
openssl_arcfour_set_key(void *ctx, unsigned length, const uint8_t *key)
{
RC4_set_key(ctx, length, key);
}
static nettle_crypt_func openssl_arcfour_crypt;
static void
openssl_arcfour_crypt(void *ctx, unsigned length,
uint8_t *dst, const uint8_t *src)
......@@ -147,13 +149,14 @@ nettle_openssl_arcfour128 = {
};
/* Blowfish */
static nettle_set_key_func openssl_bf_set_key;
static void
openssl_bf_set_key(void *ctx, unsigned length, const uint8_t *key)
{
BF_set_key(ctx, length, key);
}
static nettle_crypt_func openssl_bf_encrypt;
static void
openssl_bf_encrypt(void *ctx, unsigned length,
uint8_t *dst, const uint8_t *src)
......@@ -168,6 +171,7 @@ openssl_bf_encrypt(void *ctx, unsigned length,
}
}
static nettle_crypt_func openssl_bf_decrypt;
static void
openssl_bf_decrypt(void *ctx, unsigned length,
uint8_t *dst, const uint8_t *src)
......@@ -192,6 +196,7 @@ nettle_openssl_blowfish128 = {
/* DES */
static nettle_set_key_func openssl_des_set_key;
static void
openssl_des_set_key(void *ctx, unsigned length, const uint8_t *key)
{
......@@ -205,6 +210,7 @@ openssl_des_set_key(void *ctx, unsigned length, const uint8_t *key)
#define DES_BLOCK_SIZE 8
static nettle_crypt_func openssl_des_encrypt;
static void
openssl_des_encrypt(void *ctx, unsigned length,
uint8_t *dst, const uint8_t *src)
......@@ -219,6 +225,7 @@ openssl_des_encrypt(void *ctx, unsigned length,
}
}
static nettle_crypt_func openssl_des_decrypt;
static void
openssl_des_decrypt(void *ctx, unsigned length,
uint8_t *dst, const uint8_t *src)
......@@ -243,12 +250,14 @@ nettle_openssl_des = {
/* Cast128 */
static nettle_set_key_func openssl_cast_set_key;
static void
openssl_cast_set_key(void *ctx, unsigned length, const uint8_t *key)
{
CAST_set_key(ctx, length, key);
}
static nettle_crypt_func openssl_cast_encrypt;
static void
openssl_cast_encrypt(void *ctx, unsigned length,
uint8_t *dst, const uint8_t *src)
......@@ -263,6 +272,7 @@ openssl_cast_encrypt(void *ctx, unsigned length,
}
}
static nettle_crypt_func openssl_cast_decrypt;
static void
openssl_cast_decrypt(void *ctx, unsigned length,
uint8_t *dst, const uint8_t *src)
......@@ -288,13 +298,14 @@ nettle_openssl_cast128 = {
/* Hash functions */
/* md5 */
static nettle_hash_init_func openssl_md5_init;
static void
openssl_md5_init(void *ctx)
{
MD5_Init(ctx);
}
static nettle_hash_update_func openssl_md5_update;
static void
openssl_md5_update(void *ctx,
unsigned length,
......@@ -303,6 +314,7 @@ openssl_md5_update(void *ctx,
MD5_Update(ctx, src, length);
}
static nettle_hash_digest_func openssl_md5_digest;
static void
openssl_md5_digest(void *ctx,
unsigned length, uint8_t *dst)
......@@ -322,13 +334,14 @@ nettle_openssl_md5 = {
};
/* sha1 */
static nettle_hash_init_func openssl_sha1_init;
static void
openssl_sha1_init(void *ctx)
{
SHA1_Init(ctx);
}
static nettle_hash_update_func openssl_sha1_update;
static void
openssl_sha1_update(void *ctx,
unsigned length,
......@@ -337,6 +350,7 @@ openssl_sha1_update(void *ctx,
SHA1_Update(ctx, src, length);
}
static nettle_hash_digest_func openssl_sha1_digest;
static void
openssl_sha1_digest(void *ctx,
unsigned length, uint8_t *dst)
......
......@@ -220,7 +220,7 @@ main(int argc, char **argv)
mpz_init(x);
if (!rsa_encrypt(&key,
&ctx.yarrow, (nettle_random_func) yarrow256_random,
&ctx.yarrow, (nettle_random_func *) yarrow256_random,
sizeof(info.key), info.key,
x))
{
......
......@@ -113,7 +113,7 @@ main(int argc, char **argv)
if (!rsa_generate_keypair
(&pub, &priv,
(void *) &yarrow, (nettle_random_func) yarrow256_random,
(void *) &yarrow, (nettle_random_func *) yarrow256_random,
NULL, progress,
KEYSIZE, ESIZE))
{
......
......@@ -66,8 +66,8 @@ nettle_des = {
"des", sizeof(struct des_ctx),
DES_BLOCK_SIZE, DES_KEY_SIZE,
des_set_key_hack, des_set_key_hack,
(nettle_crypt_func) des_encrypt,
(nettle_crypt_func) des_decrypt
(nettle_crypt_func *) des_encrypt,
(nettle_crypt_func *) des_decrypt
};
const struct nettle_cipher
......@@ -75,8 +75,8 @@ nettle_des3 = {
"des3", sizeof(struct des3_ctx),
DES3_BLOCK_SIZE, DES3_KEY_SIZE,
des3_set_key_hack, des3_set_key_hack,
(nettle_crypt_func) des3_encrypt,
(nettle_crypt_func) des3_decrypt
(nettle_crypt_func *) des3_encrypt,
(nettle_crypt_func *) des3_decrypt
};
/* NOTE: This is not as nice as one might think, as it will crash if
......
......@@ -32,19 +32,6 @@
extern "C" {
#endif
/* Randomness. Used by key generation and dsa signature creation. */
typedef void (*nettle_random_func)(void *ctx,
unsigned length, uint8_t *dst);
/* Progress report function, mainly for key generation. */
typedef void (*nettle_progress_func)(void *ctx,
int c);
/* Ciphers */
typedef void (*nettle_set_key_func)(void *ctx,
unsigned length,
const uint8_t *key);
struct nettle_cipher
{
......@@ -58,11 +45,11 @@ struct nettle_cipher
/* Suggested key size; other sizes are sometimes possible. */
unsigned key_size;
nettle_set_key_func set_encrypt_key;
nettle_set_key_func set_decrypt_key;
nettle_set_key_func *set_encrypt_key;
nettle_set_key_func *set_decrypt_key;
nettle_crypt_func encrypt;
nettle_crypt_func decrypt;
nettle_crypt_func *encrypt;
nettle_crypt_func *decrypt;
};
#define _NETTLE_CIPHER(name, NAME, keysize) { \
......@@ -70,32 +57,32 @@ struct nettle_cipher
sizeof(struct name##_ctx), \
NAME##_BLOCK_SIZE, \
keysize / 8, \
(nettle_set_key_func) name##_set_key, \
(nettle_set_key_func) name##_set_key, \
(nettle_crypt_func) name##_encrypt, \
(nettle_crypt_func) name##_decrypt, \
(nettle_set_key_func *) name##_set_key, \
(nettle_set_key_func *) name##_set_key, \
(nettle_crypt_func *) name##_encrypt, \
(nettle_crypt_func *) name##_decrypt, \
}
#define _NETTLE_CIPHER_SEP(name, NAME, keysize) { \
#name #keysize, \
sizeof(struct name##_ctx), \
NAME##_BLOCK_SIZE, \
keysize / 8, \
(nettle_set_key_func) name##_set_encrypt_key, \
(nettle_set_key_func) name##_set_decrypt_key, \
(nettle_crypt_func) name##_encrypt, \
(nettle_crypt_func) name##_decrypt, \
#name #keysize, \
sizeof(struct name##_ctx), \
NAME##_BLOCK_SIZE, \
keysize / 8, \
(nettle_set_key_func *) name##_set_encrypt_key, \
(nettle_set_key_func *) name##_set_decrypt_key, \
(nettle_crypt_func *) name##_encrypt, \
(nettle_crypt_func *) name##_decrypt, \
}
#define _NETTLE_CIPHER_FIX(name, NAME, keysize) { \
#name, \
sizeof(struct name##_ctx), \
NAME##_BLOCK_SIZE, \
keysize / 8, \
(nettle_set_key_func) name##_set_key, \
(nettle_set_key_func) name##_set_key, \
(nettle_crypt_func) name##_encrypt, \
(nettle_crypt_func) name##_decrypt, \
#name, \
sizeof(struct name##_ctx), \
NAME##_BLOCK_SIZE, \
keysize / 8, \
(nettle_set_key_func *) name##_set_key, \
(nettle_set_key_func *) name##_set_key, \
(nettle_crypt_func *) name##_encrypt, \
(nettle_crypt_func *) name##_decrypt, \
}
extern const struct nettle_cipher nettle_aes128;
......@@ -118,15 +105,6 @@ extern const struct nettle_cipher nettle_arctwo64;
extern const struct nettle_cipher nettle_arctwo128;
extern const struct nettle_cipher nettle_arctwo_gutmann128;
/* Hash algorithms */
typedef void (*nettle_hash_init_func)(void *ctx);
typedef void (*nettle_hash_update_func)(void *ctx,
unsigned length,
const uint8_t *src);
typedef void (*nettle_hash_digest_func)(void *ctx,
unsigned length, uint8_t *dst);
struct nettle_hash
{
const char *name;
......@@ -140,9 +118,9 @@ struct nettle_hash
/* Internal block size */
unsigned block_size;
nettle_hash_init_func init;
nettle_hash_update_func update;
nettle_hash_digest_func digest;
nettle_hash_init_func *init;
nettle_hash_update_func *update;
nettle_hash_digest_func *digest;
};
#define _NETTLE_HASH(name, NAME) { \
......@@ -150,9 +128,9 @@ struct nettle_hash
sizeof(struct name##_ctx), \
NAME##_DIGEST_SIZE, \
NAME##_DATA_SIZE, \
(nettle_hash_init_func) name##_init, \
(nettle_hash_update_func) name##_update, \
(nettle_hash_digest_func) name##_digest \
(nettle_hash_init_func *) name##_init, \
(nettle_hash_update_func *) name##_update, \
(nettle_hash_digest_func *) name##_digest \
}
extern const struct nettle_hash nettle_md2;
......@@ -161,27 +139,6 @@ extern const struct nettle_hash nettle_md5;
extern const struct nettle_hash nettle_sha1;
extern const struct nettle_hash nettle_sha256;
/* ASCII armor codecs. NOTE: Experimental and subject to change. */
typedef unsigned (*nettle_armor_length_func)(unsigned length);
typedef void (*nettle_armor_init_func)(void *ctx);
typedef unsigned (*nettle_armor_encode_update_func)(void *ctx,
uint8_t *dst,
unsigned src_length,
const uint8_t *src);
typedef unsigned (*nettle_armor_encode_final_func)(void *ctx, uint8_t *dst);
typedef int (*nettle_armor_decode_update_func)(void *ctx,
unsigned *dst_length,
uint8_t *dst,
unsigned src_length,
const uint8_t *src);
typedef int (*nettle_armor_decode_final_func)(void *ctx);
struct nettle_armor
{
const char *name;
......@@ -190,15 +147,15 @@ struct nettle_armor
unsigned encode_final_length;
nettle_armor_init_func encode_init;
nettle_armor_length_func encode_length;
nettle_armor_encode_update_func encode_update;
nettle_armor_encode_final_func encode_final;
nettle_armor_init_func *encode_init;
nettle_armor_length_func *encode_length;
nettle_armor_encode_update_func *encode_update;
nettle_armor_encode_final_func *encode_final;
nettle_armor_init_func decode_init;
nettle_armor_length_func decode_length;
nettle_armor_decode_update_func decode_update;
nettle_armor_decode_final_func decode_final;
nettle_armor_init_func *decode_init;
nettle_armor_length_func *decode_length;
nettle_armor_decode_update_func *decode_update;
nettle_armor_decode_final_func *decode_final;
};
#define _NETTLE_ARMOR(name, NAME) { \
......@@ -206,14 +163,14 @@ struct nettle_armor
sizeof(struct name##_encode_ctx), \
sizeof(struct name##_decode_ctx), \
NAME##_ENCODE_FINAL_LENGTH, \
(nettle_armor_init_func) name##_encode_init, \
(nettle_armor_length_func) name##_encode_length, \
(nettle_armor_encode_update_func) name##_encode_update, \
(nettle_armor_encode_final_func) name##_encode_final, \
(nettle_armor_init_func) name##_decode_init, \
(nettle_armor_length_func) name##_decode_length, \
(nettle_armor_decode_update_func) name##_decode_update, \
(nettle_armor_decode_final_func) name##_decode_final, \
(nettle_armor_init_func *) name##_encode_init, \
(nettle_armor_length_func *) name##_encode_length, \
(nettle_armor_encode_update_func *) name##_encode_update, \
(nettle_armor_encode_final_func *) name##_encode_final, \
(nettle_armor_init_func *) name##_decode_init, \
(nettle_armor_length_func *) name##_decode_length, \
(nettle_armor_decode_update_func *) name##_decode_update, \
(nettle_armor_decode_final_func *) name##_decode_final, \
}
#define _NETTLE_ARMOR_0(name, NAME) { \
......@@ -221,17 +178,16 @@ struct nettle_armor
0, \
sizeof(struct name##_decode_ctx), \
NAME##_ENCODE_FINAL_LENGTH, \
(nettle_armor_init_func) name##_encode_init, \
(nettle_armor_length_func) name##_encode_length, \
(nettle_armor_encode_update_func) name##_encode_update, \
(nettle_armor_encode_final_func) name##_encode_final, \
(nettle_armor_init_func) name##_decode_init, \
(nettle_armor_length_func) name##_decode_length, \
(nettle_armor_decode_update_func) name##_decode_update, \
(nettle_armor_decode_final_func) name##_decode_final, \
(nettle_armor_init_func *) name##_encode_init, \
(nettle_armor_length_func *) name##_encode_length, \
(nettle_armor_encode_update_func *) name##_encode_update, \
(nettle_armor_encode_final_func *) name##_encode_final, \
(nettle_armor_init_func *) name##_decode_init, \
(nettle_armor_length_func *) name##_decode_length, \
(nettle_armor_decode_update_func *) name##_decode_update, \
(nettle_armor_decode_final_func *) name##_decode_final, \
}
extern const struct nettle_armor nettle_base64;
extern const struct nettle_armor nettle_base16;
......
......@@ -29,17 +29,56 @@
extern "C" {
#endif
/* Randomness. Used by key generation and dsa signature creation. */
typedef void (nettle_random_func)(void *ctx,
unsigned length, uint8_t *dst);
/* Progress report function, mainly for key generation. */
typedef void (nettle_progress_func)(void *ctx,
int c);
/* Ciphers */
typedef void (nettle_set_key_func)(void *ctx,
unsigned length,
const uint8_t *key);
/* Uses a void * for cipher contexts.
For block ciphers it would make sense with a const void * for the
context, but we use the same typedef for stream ciphers where the
internal state changes during the encryption. */
typedef void (*nettle_crypt_func)(void *ctx,
unsigned length, uint8_t *dst,
const uint8_t *src);
typedef void (nettle_crypt_func)(void *ctx,
unsigned length, uint8_t *dst,
const uint8_t *src);
/* Hash algorithms */
typedef void (nettle_hash_init_func)(void *ctx);
typedef void (nettle_hash_update_func)(void *ctx,
unsigned length,
const uint8_t *src);
typedef void (nettle_hash_digest_func)(void *ctx,
unsigned length, uint8_t *dst);
/* ASCII armor codecs. NOTE: Experimental and subject to change. */
typedef unsigned (nettle_armor_length_func)(unsigned length);
typedef void (nettle_armor_init_func)(void *ctx);
typedef unsigned (nettle_armor_encode_update_func)(void *ctx,
uint8_t *dst,
unsigned src_length,
const uint8_t *src);
typedef unsigned (nettle_armor_encode_final_func)(void *ctx, uint8_t *dst);
typedef int (nettle_armor_decode_update_func)(void *ctx,
unsigned *dst_length,
uint8_t *dst,
unsigned src_length,
const uint8_t *src);
/* FIXME: Move more of the typedefs to this file? */
typedef int (nettle_armor_decode_final_func)(void *ctx);
#ifdef __cplusplus
}
......
......@@ -23,7 +23,7 @@ test_main(void)
knuth_lfib_init(&lfib, 13);
if (!dsa_generate_keypair(&pub, &key,
&lfib, (nettle_random_func) knuth_lfib_random,
&lfib, (nettle_random_func *) knuth_lfib_random,
NULL, verbose ? progress : NULL,
1024))
FAIL();
......
......@@ -32,7 +32,7 @@ test_main(void)
fprintf(stderr, "msg: `%s', length = %d\n", msg, msg_length);
ASSERT(rsa_encrypt(&pub,
&lfib, (nettle_random_func) knuth_lfib_random,
&lfib, (nettle_random_func *) knuth_lfib_random,
msg_length, msg,
gibberish));
......
......@@ -27,7 +27,7 @@ test_main(void)
knuth_lfib_init(&lfib, 13);
if (!rsa_generate_keypair(&pub, &key,
&lfib, (nettle_random_func) knuth_lfib_random,
&lfib, (nettle_random_func *) knuth_lfib_random,
NULL, verbose ? progress : NULL,
1024, 50))
FAIL();
......@@ -49,7 +49,7 @@ test_main(void)
mpz_set_ui(pub.e, 17);
if (!rsa_generate_keypair(&pub, &key,
&lfib, (nettle_random_func) knuth_lfib_random,
&lfib, (nettle_random_func *) knuth_lfib_random,
NULL, verbose ? progress : NULL,
2000, 0))
FAIL();
......
......@@ -175,13 +175,30 @@ test_cipher(const struct nettle_cipher *cipher,
cipher->encrypt(ctx, length, data, cleartext);
if (!MEMEQ(length, data, ciphertext))
FAIL();
{
fprintf(stderr, "Encrypt failed:\nInput:");
print_hex(length, cleartext);
fprintf(stderr, "\nOutput: ");
print_hex(length, data);
fprintf(stderr, "\nExpected:");
print_hex(length, ciphertext);
fprintf(stderr, "\n");
FAIL();
}
cipher->set_decrypt_key(ctx, key_length, key);
cipher->decrypt(ctx, length, data, data);
if (!MEMEQ(length, data, cleartext))
FAIL();
{
fprintf(stderr, "Decrypt failed:\nInput:");
print_hex(length, ciphertext);
fprintf(stderr, "\nOutput: ");
print_hex(length, data);
fprintf(stderr, "\nExpected:");
print_hex(length, cleartext);
fprintf(stderr, "\n");
FAIL();
}
free(ctx);
free(data);
......@@ -760,7 +777,7 @@ test_dsa(const struct dsa_public_key *pub,
sha1_update(&sha1, LDATA("The magic words are squeamish ossifrage"));
dsa_sign(pub, key,
&lfib, (nettle_random_func) knuth_lfib_random,
&lfib, (nettle_random_func *) knuth_lfib_random,
&sha1, &signature);
if (verbose)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment