E_INVALID operation in aes_unwrap

E_INVALID operation in aes_unwrap

BY 23 Dec 2013 Native Application Development

       
Hi,
can anyone figure out the error here is my code

        ByteBuffer bufKey,bufKek;
        bufKek.Construct(16);
        bufKek.SetArray((byte *)”123456789012345″,0,16);   //key used for wrapping
        bufKek.Flip();
        bufKey.Construct(16);
        bufKey.SetArray((byte *)”100100100100100″,0,16); // key to be wrapped
        bufKey.Flip();
        AesCipher *asc=new AesCipher();
        asc->Construct(“ECB/128/PKCS7PADDING”,CIPHER_WRAP);        //wrap function 
        SecretKeyGenerator *kgen=new SecretKeyGenerator();
        kgen->Construct(bufKek);
        ISecretKey *ikey=kgen->GenerateKeyN();
        asc->SetKey(*ikey);
        ByteBuffer* enkey=asc->WrapN(*bufKey);
        AppLog(“enkey is %s”,enkey->GetPointer());

        AesCipher *asc1=new AesCipher();
        asc1->Construct(“ECB/128/PKCS7PADDING”,CIPHER_UNWRAP);   //un wrap function
        asc1->SetKey(*ikey);
        ByteBuffer *enkey1=asc->UnwrapN(*enkey);
        AppLog(“enkey is %s”,enkey1->GetPointer());

Written by