~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/lib/crypto/mpi/mpi-mul.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /lib/crypto/mpi/mpi-mul.c (Version linux-6.12-rc7) and /lib/crypto/mpi/mpi-mul.c (Version linux-5.10.229)


  1 /* mpi-mul.c  -  MPI functions                      1 
  2  * Copyright (C) 1994, 1996, 1998, 2001, 2002,    
  3  *               2003 Free Software Foundation    
  4  *                                                
  5  * This file is part of Libgcrypt.                
  6  *                                                
  7  * Note: This code is heavily based on the GNU    
  8  *       Actually it's the same code with only    
  9  *       way the data is stored; this is to su    
 10  *       of an optional secure memory allocati    
 11  *       to avoid revealing of sensitive data     
 12  */                                               
 13                                                   
 14 #include "mpi-internal.h"                         
 15                                                   
 16 int mpi_mul(MPI w, MPI u, MPI v)                  
 17 {                                                 
 18         mpi_size_t usize, vsize, wsize;           
 19         mpi_ptr_t up, vp, wp;                     
 20         mpi_limb_t cy;                            
 21         int usign, vsign, sign_product;           
 22         int assign_wp = 0;                        
 23         mpi_ptr_t tmp_limb = NULL;                
 24         int err = 0;                              
 25                                                   
 26         if (u->nlimbs < v->nlimbs) {              
 27                 /* Swap U and V. */               
 28                 usize = v->nlimbs;                
 29                 usign = v->sign;                  
 30                 up    = v->d;                     
 31                 vsize = u->nlimbs;                
 32                 vsign = u->sign;                  
 33                 vp    = u->d;                     
 34         } else {                                  
 35                 usize = u->nlimbs;                
 36                 usign = u->sign;                  
 37                 up    = u->d;                     
 38                 vsize = v->nlimbs;                
 39                 vsign = v->sign;                  
 40                 vp    = v->d;                     
 41         }                                         
 42         sign_product = usign ^ vsign;             
 43         wp = w->d;                                
 44                                                   
 45         /* Ensure W has space enough to store     
 46         wsize = usize + vsize;                    
 47         if (w->alloced < wsize) {                 
 48                 if (wp == up || wp == vp) {       
 49                         wp = mpi_alloc_limb_sp    
 50                         if (!wp)                  
 51                                 return -ENOMEM    
 52                         assign_wp = 1;            
 53                 } else {                          
 54                         err = mpi_resize(w, ws    
 55                         if (err)                  
 56                                 return err;       
 57                         wp = w->d;                
 58                 }                                 
 59         } else { /* Make U and V not overlap w    
 60                 if (wp == up) {                   
 61                         /* W and U are identic    
 62                         up = tmp_limb = mpi_al    
 63                         if (!up)                  
 64                                 return -ENOMEM    
 65                         /* Is V identical too?    
 66                         if (wp == vp)             
 67                                 vp = up;          
 68                         /* Copy to the tempora    
 69                         MPN_COPY(up, wp, usize    
 70                 } else if (wp == vp) {            
 71                         /* W and V are identic    
 72                         vp = tmp_limb = mpi_al    
 73                         if (!vp)                  
 74                                 return -ENOMEM    
 75                         /* Copy to the tempora    
 76                         MPN_COPY(vp, wp, vsize    
 77                 }                                 
 78         }                                         
 79                                                   
 80         if (!vsize)                               
 81                 wsize = 0;                        
 82         else {                                    
 83                 err = mpihelp_mul(wp, up, usiz    
 84                 if (err) {                        
 85                         if (assign_wp)            
 86                                 mpi_free_limb_    
 87                         goto free_tmp_limb;       
 88                 }                                 
 89                 wsize -= cy ? 0:1;                
 90         }                                         
 91                                                   
 92         if (assign_wp)                            
 93                 mpi_assign_limb_space(w, wp, w    
 94         w->nlimbs = wsize;                        
 95         w->sign = sign_product;                   
 96                                                   
 97 free_tmp_limb:                                    
 98         if (tmp_limb)                             
 99                 mpi_free_limb_space(tmp_limb);    
100         return err;                               
101 }                                                 
102 EXPORT_SYMBOL_GPL(mpi_mul);                       
103                                                   
104 int mpi_mulm(MPI w, MPI u, MPI v, MPI m)          
105 {                                                 
106         return mpi_mul(w, u, v) ?:                
107                mpi_tdiv_r(w, w, m);               
108 }                                                 
109 EXPORT_SYMBOL_GPL(mpi_mulm);                      
110                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php