< prev index next >

src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSASignature.java

Print this page




 336         }
 337     }
 338 
 339     void reset(boolean doCancel) {
 340         initialized = false;
 341         if (pCtxt != null) {
 342             pCtxt.dispose(doCancel);
 343             pCtxt = null;
 344         }
 345     }
 346 
 347     /**
 348      * calls ucrypto_sign_init(...) or ucrypto_verify_init(...)
 349      * @return pointer to the context
 350      */
 351     private native static long nativeInit(int mech, boolean sign,
 352                                           long keyValue, int keyLength);
 353 
 354     /**
 355      * calls ucrypto_sign_update(...) or ucrypto_verify_update(...)
 356      * @returns an error status code (0 means SUCCESS)
 357      */
 358     private native static int nativeUpdate(long pContext, boolean sign,
 359                                            byte[] in, int inOfs, int inLen);
 360     /**
 361      * calls ucrypto_sign_update(...) or ucrypto_verify_update(...)
 362      * @returns an error status code (0 means SUCCESS)
 363      */
 364     private native static int nativeUpdate(long pContext, boolean sign,
 365                                            long pIn, int inLen);
 366 
 367     /**
 368      * calls ucrypto_sign_final(...) or ucrypto_verify_final(...)
 369      * @returns the length of signature bytes or verification status.
 370      * If negative, it indicates an error status code
 371      */
 372     private native static int nativeFinal(long pContext, boolean sign,
 373                                           byte[] sig, int sigOfs, int sigLen);
 374 
 375     // actual init() implementation - caller should clone key if needed
 376     private void init(boolean sign, NativeKey key, int sigLength) {
 377         reset(true);
 378         this.sign = sign;
 379         this.sigLength = sigLength;
 380         this.key = key;
 381         long pCtxtVal = nativeInit(mech.value(), sign, key.value(),
 382                                    key.length());
 383         initialized = (pCtxtVal != 0L);
 384         if (initialized) {
 385             pCtxt = new SignatureContextRef(this, pCtxtVal, sign);
 386         } else {
 387             throw new UcryptoException("Cannot initialize Signature");
 388         }
 389     }




 336         }
 337     }
 338 
 339     void reset(boolean doCancel) {
 340         initialized = false;
 341         if (pCtxt != null) {
 342             pCtxt.dispose(doCancel);
 343             pCtxt = null;
 344         }
 345     }
 346 
 347     /**
 348      * calls ucrypto_sign_init(...) or ucrypto_verify_init(...)
 349      * @return pointer to the context
 350      */
 351     private native static long nativeInit(int mech, boolean sign,
 352                                           long keyValue, int keyLength);
 353 
 354     /**
 355      * calls ucrypto_sign_update(...) or ucrypto_verify_update(...)
 356      * @return an error status code (0 means SUCCESS)
 357      */
 358     private native static int nativeUpdate(long pContext, boolean sign,
 359                                            byte[] in, int inOfs, int inLen);
 360     /**
 361      * calls ucrypto_sign_update(...) or ucrypto_verify_update(...)
 362      * @return an error status code (0 means SUCCESS)
 363      */
 364     private native static int nativeUpdate(long pContext, boolean sign,
 365                                            long pIn, int inLen);
 366 
 367     /**
 368      * calls ucrypto_sign_final(...) or ucrypto_verify_final(...)
 369      * @return the length of signature bytes or verification status.
 370      * If negative, it indicates an error status code
 371      */
 372     private native static int nativeFinal(long pContext, boolean sign,
 373                                           byte[] sig, int sigOfs, int sigLen);
 374 
 375     // actual init() implementation - caller should clone key if needed
 376     private void init(boolean sign, NativeKey key, int sigLength) {
 377         reset(true);
 378         this.sign = sign;
 379         this.sigLength = sigLength;
 380         this.key = key;
 381         long pCtxtVal = nativeInit(mech.value(), sign, key.value(),
 382                                    key.length());
 383         initialized = (pCtxtVal != 0L);
 384         if (initialized) {
 385             pCtxt = new SignatureContextRef(this, pCtxtVal, sign);
 386         } else {
 387             throw new UcryptoException("Cannot initialize Signature");
 388         }
 389     }


< prev index next >