简体   繁体   中英

GNU Octave dimensions mismatch error?

I take an error on GNU Octave.

error: sim_encryption: A(I,J,...) = X: dimensions mismatch
error: called from
    sim_encryption at line 11 column 13
Line 11 is "    s( 1 , : )  =  mod( s + k , 2 ) ;" . 

When I search about error, it is said that the problem is about matrix, but matrixes are not look different. So what is the problem ?

ph  =  '3243f6a8885a308d313198a2e0370734' ;
kh  =  '2b7e151628aed2a6abf7158809cf4f3c' ;

k  =  zeros( 11 , 128 ) ;
r  =  zeros( 11 , 8 ) ;
s  =  zeros( 11 , 128 ) ;

s( 1 , : )  =  hex_to_bin( ph ) ;
k( 1 , : )  =  hex_to_bin( kh ) ;
r( 1 , : )  =  [ 0 0 0 0  0 0 0 1 ] ;
s( 1 , : )  =  mod( s + k , 2 ) ;

for  i  =  1  :  10 ,
    i ;
    [ k( i+1 , : ) , r( i+1 , : ) ]  =  key_schedule( k( i , : ) , r( i , : ) ) ;
    s( i+1 , : )  =  mod( k( i+1 , : ) + aes_round( s( i , : ) , i ) , 2 ) ;
    kh  =  bin_to_hex( k(i+1,:) , 32 ) ;
    sh  =  bin_to_hex( s(i+1,:) , 32 ) ;
end

ch  =  bin_to_hex( s(11,:) , 32 )

由于sk的大小均为11 x 128,因此mod(s + k, 2)的结果也是11 x 128,并且您试图覆盖s(1,:) ,即1 x 128

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM