Skip to content
Snippets Groups Projects
Select Git revision
2 results Searching

inode.c

Blame
  • crypto_user.c 13.12 KiB
    /*
     * Crypto user configuration API.
     *
     * Copyright (C) 2011 secunet Security Networks AG
     * Copyright (C) 2011 Steffen Klassert <steffen.klassert@secunet.com>
     *
     * This program is free software; you can redistribute it and/or modify it
     * under the terms and conditions of the GNU General Public License,
     * version 2, as published by the Free Software Foundation.
     *
     * This program is distributed in the hope it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
     * more details.
     *
     * You should have received a copy of the GNU General Public License along with
     * this program; if not, write to the Free Software Foundation, Inc.,
     * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
     */
    
    #include <linux/module.h>
    #include <linux/crypto.h>
    #include <linux/cryptouser.h>
    #include <linux/sched.h>
    #include <net/netlink.h>
    #include <linux/security.h>
    #include <net/net_namespace.h>
    #include <crypto/internal/skcipher.h>
    #include <crypto/internal/rng.h>
    #include <crypto/akcipher.h>
    #include <crypto/kpp.h>
    
    #include "internal.h"
    
    #define null_terminated(x)	(strnlen(x, sizeof(x)) < sizeof(x))
    
    static DEFINE_MUTEX(crypto_cfg_mutex);
    
    /* The crypto netlink socket */
    static struct sock *crypto_nlsk;
    
    struct crypto_dump_info {
    	struct sk_buff *in_skb;
    	struct sk_buff *out_skb;
    	u32 nlmsg_seq;
    	u16 nlmsg_flags;
    };
    
    static struct crypto_alg *crypto_alg_match(struct crypto_user_alg *p, int exact)
    {
    	struct crypto_alg *q, *alg = NULL;
    
    	down_read(&crypto_alg_sem);
    
    	list_for_each_entry(q, &crypto_alg_list, cra_list) {
    		int match = 0;
    
    		if ((q->cra_flags ^ p->cru_type) & p->cru_mask)
    			continue;
    
    		if (strlen(p->cru_driver_name))
    			match = !strcmp(q->cra_driver_name,
    					p->cru_driver_name);
    		else if (!exact)
    			match = !strcmp(q->cra_name, p->cru_name);
    
    		if (!match)
    			continue;
    
    		if (unlikely(!crypto_mod_get(q)))