Commit 04001db3 authored by David S. Miller's avatar David S. Miller

[IPSEC]: Remove debugging code.

parent 6c55c29f
...@@ -124,63 +124,6 @@ void skb_ah_walk(const struct sk_buff *skb, struct crypto_tfm *tfm) ...@@ -124,63 +124,6 @@ void skb_ah_walk(const struct sk_buff *skb, struct crypto_tfm *tfm)
BUG(); BUG();
} }
#if 0 /* obsolete? */
static void
ah_old_digest(struct xfrm_state *x, struct sk_buff *skb, u8 *auth_data)
{
struct ah_data *ahp = (struct ah_data*)x->data;
struct crypto_tfm *tfm = ahp->tfm;
u8 pad[512/8 - ahp->key_len];
memset(auth_data, 0, ahp->digest_len);
memset(pad, 0, sizeof(pad));
crypto_digest_init(tfm);
tfm->__crt_alg->cra_digest.dia_update(tfm->crt_ctx, ahp->key, ahp->key_len);
tfm->__crt_alg->cra_digest.dia_update(tfm->crt_ctx, ahp->key, sizeof(pad)-ahp->key_len);
skb_ah_walk(skb, tfm);
tfm->__crt_alg->cra_digest.dia_update(tfm->crt_ctx, ahp->key, ahp->key_len);
crypto_digest_final(tfm, auth_data);
}
#endif
/* I bring apologies for wrong use of crypto lib. Use of official
* api to get hmac digest is too chumbersome.
*/
static void
ah_hmac_digest(struct xfrm_state *x, struct sk_buff *skb, u8 *auth_data)
{
struct ah_data *ahp = (struct ah_data*)x->data;
struct crypto_tfm *tfm = ahp->tfm;
int i;
char tmp_digest[crypto_tfm_digestsize(tfm)];
char pad[crypto_tfm_blocksize(tfm)];
memset(auth_data, 0, ahp->digest_len);
memset(pad, 0, sizeof(pad));
memcpy(pad, ahp->key, ahp->key_len);
for (i = 0; i < crypto_tfm_blocksize(tfm); i++)
pad[i] ^= 0x36;
crypto_digest_init(tfm);
tfm->__crt_alg->cra_digest.dia_update(tfm->crt_ctx, pad, sizeof(pad));
skb_ah_walk(skb, tfm);
crypto_digest_final(tfm, tmp_digest);
memset(pad, 0, sizeof(pad));
memcpy(pad, ahp->key, ahp->key_len);
for (i = 0; i < crypto_tfm_blocksize(tfm); i++)
pad[i] ^= 0x5c;
crypto_digest_init(tfm);
tfm->__crt_alg->cra_digest.dia_update(tfm->crt_ctx, pad, sizeof(pad));
tfm->__crt_alg->cra_digest.dia_update(tfm->crt_ctx, tmp_digest, crypto_tfm_digestsize(tfm));
crypto_digest_final(tfm, auth_data);
}
int ah_output(struct sk_buff *skb) int ah_output(struct sk_buff *skb)
{ {
int err; int err;
...@@ -372,36 +315,3 @@ static void __exit ah4_fini(void) ...@@ -372,36 +315,3 @@ static void __exit ah4_fini(void)
if (inet_del_protocol(&ah4_protocol, IPPROTO_AH) < 0) if (inet_del_protocol(&ah4_protocol, IPPROTO_AH) < 0)
printk(KERN_INFO "ip ah close: can't remove protocol\n"); printk(KERN_INFO "ip ah close: can't remove protocol\n");
} }
void ah_destroy(struct xfrm_state *x)
{
}
struct ah_data debugging_ah_state =
{
.key = "PIZDETSPIZDETSPIZDETSPIZDETSPIZDETS",
.key_len = 32,
.digest_len = 16,
.digest = ah_hmac_digest
};
int ah_init_state(struct xfrm_state *x, void *args)
{
debugging_ah_state.tfm = crypto_alloc_tfm(CRYPTO_ALG_MD5);
x->data = &debugging_ah_state;
x->props.header_len = 16+16;
return 0;
}
struct xfrm_type ah_type =
{
.description = "AH4-HMAC",
.refcnt = ATOMIC_INIT(1),
.proto = IPPROTO_AH,
.algo = 0,
.init_state = ah_init_state,
.destructor = ah_destroy,
.input = ah_input,
.output = ah_output
};
...@@ -784,47 +784,6 @@ struct dst_ops xfrm4_dst_ops = { ...@@ -784,47 +784,6 @@ struct dst_ops xfrm4_dst_ops = {
.entry_size = sizeof(struct xfrm_dst), .entry_size = sizeof(struct xfrm_dst),
}; };
void create_debug_policy(void)
{
extern struct xfrm_type ah_type;
struct xfrm_policy *pol = xfrm_policy_alloc();
struct xfrm_state *x;
if (!pol)
panic("panic\n");
pol->expires = ~0UL;
pol->action = XFRM_POLICY_ALLOW;
pol->xfrm_nr = 1;
pol->xfrm_vec[0] = (struct xfrm_tmpl){
.id = { .proto = IPPROTO_AH },
.algos = ~0
};
pol->selector = (struct xfrm_selector){
.daddr = { .a4 = { .addr = __constant_htonl(0x7f000001),
.mask = ~0 } },
.dport = __constant_htons(8888),
.dport_mask = ~0,
.prefixlen_d = 32,
.proto = IPPROTO_UDP
};
xfrm_policy_list[XFRM_POLICY_OUT] = pol;
x = xfrm_state_alloc();
x->sel = pol->selector;
/* Debug. */
x->id.proto = IPPROTO_AH;
x->id.spi = 1;
x->id.daddr = pol->selector.daddr;
x->km.state = XFRM_STATE_VALID;
x->km.warn_bytes = 0;
x->replay.oseq = 1;
x->type = &ah_type;
x->type->init_state(x, NULL);
xfrm_state_insert(x);
}
void __init xfrm_init(void) void __init xfrm_init(void)
{ {
xfrm4_dst_ops.kmem_cachep = kmem_cache_create("xfrm4_dst_cache", xfrm4_dst_ops.kmem_cachep = kmem_cache_create("xfrm4_dst_cache",
...@@ -840,6 +799,4 @@ void __init xfrm_init(void) ...@@ -840,6 +799,4 @@ void __init xfrm_init(void)
xfrm_state_init(); xfrm_state_init();
xfrm_input_init(); xfrm_input_init();
ah4_init(); ah4_init();
create_debug_policy();
} }
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