需求:
通过C代码实现Https的Post操作。
方案:
1.选择支持HTTPS的开源库OpenSSL
2.将OpenSSL编译成.a或.so,是指在工程中编译源码成链接库
3.C代码调用OpenSSL的接口
步骤:
1. 工具:OpenSSL源码,NDK,Cygwin
2. 关键是Android.mk的设计
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH := $(call my-dir)
CRYPTO_PATH := crypto
SSL_PATH := ssl
local_c_includes := \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/include/openssl \
$(CRYPTO_PATH) \
$(CRYPTO_PATH)/asn1 \
$(CRYPTO_PATH)/evp \
$(SSL_PATH) \
arm_cflags := -DOPENSSL_BN_ASM_MONT -DAES_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM
arm_src_files := \
$(CRYPTO_PATH)/aes/asm/aes-armv4.S \
$(CRYPTO_PATH)/bn/asm/armv4-mont.S \
$(CRYPTO_PATH)/sha/asm/sha1-armv4-large.S \
$(CRYPTO_PATH)/sha/asm/sha256-armv4.S \
$(CRYPTO_PATH)/sha/asm/sha512-armv4.S
non_arm_src_files := $(CRYPTO_PATH)/aes/aes_core.c
local_crypto_src := \
$(CRYPTO_PATH)/cryptlib.c \
$(CRYPTO_PATH)/mem.c \
$(CRYPTO_PATH)/mem_clr.c \
$(CRYPTO_PATH)/mem_dbg.c \
$(CRYPTO_PATH)/cversion.c \
$(CRYPTO_PATH)/ex_data.c \
$(CRYPTO_PATH)/cpt_err.c \
$(CRYPTO_PATH)/ebcdic.c \
$(CRYPTO_PATH)/uid.c \
$(CRYPTO_PATH)/o_time.c \
$(CRYPTO_PATH)/o_str.c \
$(CRYPTO_PATH)/o_dir.c \
$(CRYPTO_PATH)/aes/aes_cbc.c \
$(CRYPTO_PATH)/aes/aes_cfb.c \
$(CRYPTO_PATH)/aes/aes_ctr.c \
$(CRYPTO_PATH)/aes/aes_ecb.c \
$(CRYPTO_PATH)/aes/aes_misc.c \
$(CRYPTO_PATH)/aes/aes_ofb.c \
$(CRYPTO_PATH)/aes/aes_wrap.c \
$(CRYPTO_PATH)/asn1/a_bitstr.c \
$(CRYPTO_PATH)/asn1/a_bool.c \
$(CRYPTO_PATH)/asn1/a_bytes.c \
$(CRYPTO_PATH)/asn1/a_d2i_fp.c \
$(CRYPTO_PATH)/asn1/a_digest.c \
$(CRYPTO_PATH)/asn1/a_dup.c \
$(CRYPTO_PATH)/asn1/a_enum.c \
$(CRYPTO_PATH)/asn1/a_gentm.c \
$(CRYPTO_PATH)/asn1/a_i2d_fp.c \
$(CRYPTO_PATH)/asn1/a_int.c \
$(CRYPTO_PATH)/asn1/a_mbstr.c \
$(CRYPTO_PATH)/asn1/a_object.c \
$(CRYPTO_PATH)/asn1/a_octet.c \
$(CRYPTO_PATH)/asn1/a_print.c \
$(CRYPTO_PATH)/asn1/a_set.c \
$(CRYPTO_PATH)/asn1/a_sign.c \
$(CRYPTO_PATH)/asn1/a_strex.c \
$(CRYPTO_PATH)/asn1/a_strnid.c \
$(CRYPTO_PATH)/asn1/a_time.c \
$(CRYPTO_PATH)/asn1/a_type.c \
$(CRYPTO_PATH)/asn1/a_utctm.c \
$(CRYPTO_PATH)/asn1/a_utf8.c \
$(CRYPTO_PATH)/asn1/a_verify.c \
$(CRYPTO_PATH)/asn1/ameth_lib.c \
$(CRYPTO_PATH)/asn1/asn1_err.c \
$(CRYPTO_PATH)/asn1/asn1_gen.c \
$(CRYPTO_PATH)/asn1/asn1_lib.c \
$(CRYPTO_PATH)/asn1/asn1_par.c \
$(CRYPTO_PATH)/asn1/asn_mime.c \
$(CRYPTO_PATH)/asn1/asn_moid.c \
$(CRYPTO_PATH)/asn1/asn_pack.c \
$(CRYPTO_PATH)/asn1/bio_asn1.c \
$(CRYPTO_PATH)/asn1/bio_ndef.c \
$(CRYPTO_PATH)/asn1/d2i_pr.c \
$(CRYPTO_PATH)/asn1/d2i_pu.c \
$(CRYPTO_PATH)/asn1/evp_asn1.c \
$(CRYPTO_PATH)/asn1/f_enum.c \
$(CRYPTO_PATH)/asn1/f_int.c \
$(CRYPTO_PATH)/asn1/f_string.c \
$(CRYPTO_PATH)/asn1/i2d_pr.c \
$(CRYPTO_PATH)/asn1/i2d_pu.c \
$(CRYPTO_PATH)/asn1/n_pkey.c \
$(CRYPTO_PATH)/asn1/nsseq.c \
$(CRYPTO_PATH)/asn1/p5_pbe.c \
$(CRYPTO_PATH)/asn1/p5_pbev2.c \
$(CRYPTO_PATH)/asn1/p8_pkey.c \
$(CRYPTO_PATH)/asn1/t_bitst.c \
$(CRYPTO_PATH)/asn1/t_crl.c \
$(CRYPTO_PATH)/asn1/t_pkey.c \
$(CRYPTO_PATH)/asn1/t_req.c \
$(CRYPTO_PATH)/asn1/t_spki.c \
$(CRYPTO_PATH)/asn1/t_x509.c \
$(CRYPTO_PATH)/asn1/t_x509a.c \
$(CRYPTO_PATH)/asn1/tasn_dec.c \
$(CRYPTO_PATH)/asn1/tasn_enc.c \
$(CRYPTO_PATH)/asn1/tasn_fre.c \
$(CRYPTO_PATH)/asn1/tasn_new.c \
$(CRYPTO_PATH)/asn1/tasn_prn.c \
$(CRYPTO_PATH)/asn1/tasn_typ.c \
$(CRYPTO_PATH)/asn1/tasn_utl.c \
$(CRYPTO_PATH)/asn1/x_algor.c \
$(CRYPTO_PATH)/asn1/x_attrib.c \
$(CRYPTO_PATH)/asn1/x_bignum.c \
$(CRYPTO_PATH)/asn1/x_crl.c \
$(CRYPTO_PATH)/asn1/x_exten.c \
$(CRYPTO_PATH)/asn1/x_info.c \
$(CRYPTO_PATH)/asn1/x_long.c \
$(CRYPTO_PATH)/asn1/x_name.c \
$(CRYPTO_PATH)/asn1/x_nx509.c \
$(CRYPTO_PATH)/asn1/x_pkey.c \
$(CRYPTO_PATH)/asn1/x_pubkey.c \
$(CRYPTO_PATH)/asn1/x_req.c \
$(CRYPTO_PATH)/asn1/x_sig.c \
$(CRYPTO_PATH)/asn1/x_spki.c \
$(CRYPTO_PATH)/asn1/x_val.c \
$(CRYPTO_PATH)/asn1/x_x509.c \
$(CRYPTO_PATH)/asn1/x_x509a.c \
$(CRYPTO_PATH)/bf/bf_cfb64.c \
$(CRYPTO_PATH)/bf/bf_ecb.c \
$(CRYPTO_PATH)/bf/bf_enc.c \
$(CRYPTO_PATH)/bf/bf_ofb64.c \
$(CRYPTO_PATH)/bf/bf_skey.c \
$(CRYPTO_PATH)/bio/b_dump.c \
$(CRYPTO_PATH)/bio/b_print.c \
$(CRYPTO_PATH)/bio/b_sock.c \
$(CRYPTO_PATH)/bio/bf_buff.c \
$(CRYPTO_PATH)/bio/bf_nbio.c \
$(CRYPTO_PATH)/bio/bf_null.c \
$(CRYPTO_PATH)/bio/bio_cb.c \
$(CRYPTO_PATH)/bio/bio_err.c \
$(CRYPTO_PATH)/bio/bio_lib.c \
$(CRYPTO_PATH)/bio/bss_acpt.c \
$(CRYPTO_PATH)/bio/bss_bio.c \
$(CRYPTO_PATH)/bio/bss_conn.c \
$(CRYPTO_PATH)/bio/bss_dgram.c \
$(CRYPTO_PATH)/bio/bss_fd.c \
$(CRYPTO_PATH)/bio/bss_file.c \
$(CRYPTO_PATH)/bio/bss_log.c \
$(CRYPTO_PATH)/bio/bss_mem.c \
$(CRYPTO_PATH)/bio/bss_null.c \
$(CRYPTO_PATH)/bio/bss_sock.c \
$(CRYPTO_PATH)/bn/bn_add.c \
$(CRYPTO_PATH)/bn/bn_asm.c \
$(CRYPTO_PATH)/bn/bn_blind.c \
$(CRYPTO_PATH)/bn/bn_ctx.c \
$(CRYPTO_PATH)/bn/bn_div.c \
$(CRYPTO_PATH)/bn/bn_err.c \
$(CRYPTO_PATH)/bn/bn_exp.c \
$(CRYPTO_PATH)/bn/bn_exp2.c \
$(CRYPTO_PATH)/bn/bn_gcd.c \
$(CRYPTO_PATH)/bn/bn_gf2m.c \
$(CRYPTO_PATH)/bn/bn_kron.c \
$(CRYPTO_PATH)/bn/bn_lib.c \
$(CRYPTO_PATH)/bn/bn_mod.c \
$(CRYPTO_PATH)/bn/bn_mont.c \
$(CRYPTO_PATH)/bn/bn_mpi.c \
$(CRYPTO_PATH)/bn/bn_mul.c \
$(CRYPTO_PATH)/bn/bn_nist.c \
$(CRYPTO_PATH)/bn/bn_prime.c \
$(CRYPTO_PATH)/bn/bn_print.c \
$(CRYPTO_PATH)/bn/bn_rand.c \
$(CRYPTO_PATH)/bn/bn_recp.c \
$(CRYPTO_PATH)/bn/bn_shift.c \
$(CRYPTO_PATH)/bn/bn_sqr.c \
$(CRYPTO_PATH)/bn/bn_sqrt.c \
$(CRYPTO_PATH)/bn/bn_word.c \
$(CRYPTO_PATH)/buffer/buf_err.c \
$(CRYPTO_PATH)/buffer/buffer.c \
$(CRYPTO_PATH)/comp/c_rle.c \
$(CRYPTO_PATH)/comp/c_zlib.c \
$(CRYPTO_PATH)/comp/comp_err.c \
$(CRYPTO_PATH)/comp/comp_lib.c \
$(CRYPTO_PATH)/conf/conf_api.c \
$(CRYPTO_PATH)/conf/conf_def.c \
$(CRYPTO_PATH)/conf/conf_err.c \
$(CRYPTO_PATH)/conf/conf_lib.c \
$(CRYPTO_PATH)/conf/conf_mall.c \
$(CRYPTO_PATH)/conf/conf_mod.c \
$(CRYPTO_PATH)/conf/conf_sap.c \
$(CRYPTO_PATH)/des/cbc_cksm.c \
$(CRYPTO_PATH)/des/cbc_enc.c \
$(CRYPTO_PATH)/des/cfb64ede.c \
$(CRYPTO_PATH)/des/cfb64enc.c \
$(CRYPTO_PATH)/des/cfb_enc.c \
$(CRYPTO_PATH)/des/des_enc.c \
$(CRYPTO_PATH)/des/des_old.c \
$(CRYPTO_PATH)/des/des_old2.c \
$(CRYPTO_PATH)/des/ecb3_enc.c \
$(CRYPTO_PATH)/des/ecb_enc.c \
$(CRYPTO_PATH)/des/ede_cbcm_enc.c \
$(CRYPTO_PATH)/des/enc_read.c \
$(CRYPTO_PATH)/des/enc_writ.c \
$(CRYPTO_PATH)/des/fcrypt.c \
$(CRYPTO_PATH)/des/fcrypt_b.c \
$(CRYPTO_PATH)/des/ofb64ede.c \
$(CRYPTO_PATH)/des/ofb64enc.c \
$(CRYPTO_PATH)/des/ofb_enc.c \
$(CRYPTO_PATH)/des/pcbc_enc.c \
$(CRYPTO_PATH)/des/qud_cksm.c \
$(CRYPTO_PATH)/des/rand_key.c \
$(CRYPTO_PATH)/des/read2pwd.c \
$(CRYPTO_PATH)/des/rpc_enc.c \
$(CRYPTO_PATH)/des/set_key.c \
$(CRYPTO_PATH)/des/str2key.c \
$(CRYPTO_PATH)/des/xcbc_enc.c \
$(CRYPTO_PATH)/dh/dh_ameth.c \
$(CRYPTO_PATH)/dh/dh_asn1.c \
$(CRYPTO_PATH)/dh/dh_check.c \
$(CRYPTO_PATH)/dh/dh_depr.c \
$(CRYPTO_PATH)/dh/dh_err.c \
$(CRYPTO_PATH)/dh/dh_gen.c \
$(CRYPTO_PATH)/dh/dh_key.c \
$(CRYPTO_PATH)/dh/dh_lib.c \
$(CRYPTO_PATH)/dh/dh_pmeth.c \
$(CRYPTO_PATH)/dsa/dsa_ameth.c \
$(CRYPTO_PATH)/dsa/dsa_asn1.c \
$(CRYPTO_PATH)/dsa/dsa_depr.c \
$(CRYPTO_PATH)/dsa/dsa_err.c \
$(CRYPTO_PATH)/dsa/dsa_gen.c \
$(CRYPTO_PATH)/dsa/dsa_key.c \
$(CRYPTO_PATH)/dsa/dsa_lib.c \
$(CRYPTO_PATH)/dsa/dsa_ossl.c \
$(CRYPTO_PATH)/dsa/dsa_pmeth.c \
$(CRYPTO_PATH)/dsa/dsa_prn.c \
$(CRYPTO_PATH)/dsa/dsa_sign.c \
$(CRYPTO_PATH)/dsa/dsa_vrf.c \
$(CRYPTO_PATH)/dso/dso_dl.c \
$(CRYPTO_PATH)/dso/dso_dlfcn.c \
$(CRYPTO_PATH)/dso/dso_err.c \
$(CRYPTO_PATH)/dso/dso_lib.c \
$(CRYPTO_PATH)/dso/dso_null.c \
$(CRYPTO_PATH)/dso/dso_openssl.c \
$(CRYPTO_PATH)/dso/dso_vms.c \
$(CRYPTO_PATH)/dso/dso_win32.c \
$(CRYPTO_PATH)/ec/ec2_mult.c \
$(CRYPTO_PATH)/ec/ec2_smpl.c \
$(CRYPTO_PATH)/ec/ec_ameth.c \
$(CRYPTO_PATH)/ec/ec_asn1.c \
$(CRYPTO_PATH)/ec/ec_check.c \
$(CRYPTO_PATH)/ec/ec_curve.c \
$(CRYPTO_PATH)/ec/ec_cvt.c \
$(CRYPTO_PATH)/ec/ec_err.c \
$(CRYPTO_PATH)/ec/ec_key.c \
$(CRYPTO_PATH)/ec/ec_lib.c \
$(CRYPTO_PATH)/ec/ec_mult.c \
$(CRYPTO_PATH)/ec/ec_pmeth.c \
$(CRYPTO_PATH)/ec/ec_print.c \
$(CRYPTO_PATH)/ec/eck_prn.c \
$(CRYPTO_PATH)/ec/ecp_mont.c \
$(CRYPTO_PATH)/ec/ecp_nist.c \
$(CRYPTO_PATH)/ec/ecp_smpl.c \
$(CRYPTO_PATH)/ecdh/ech_err.c \
$(CRYPTO_PATH)/ecdh/ech_key.c \
$(CRYPTO_PATH)/ecdh/ech_lib.c \
$(CRYPTO_PATH)/ecdh/ech_ossl.c \
$(CRYPTO_PATH)/ecdsa/ecs_asn1.c \
$(CRYPTO_PATH)/ecdsa/ecs_err.c \
$(CRYPTO_PATH)/ecdsa/ecs_lib.c \
$(CRYPTO_PATH)/ecdsa/ecs_ossl.c \
$(CRYPTO_PATH)/ecdsa/ecs_sign.c \
$(CRYPTO_PATH)/ecdsa/ecs_vrf.c \
$(CRYPTO_PATH)/err/err.c \
$(CRYPTO_PATH)/err/err_all.c \
$(CRYPTO_PATH)/err/err_prn.c \
$(CRYPTO_PATH)/evp/bio_b64.c \
$(CRYPTO_PATH)/evp/bio_enc.c \
$(CRYPTO_PATH)/evp/bio_md.c \
$(CRYPTO_PATH)/evp/bio_ok.c \
$(CRYPTO_PATH)/evp/c_all.c \
$(CRYPTO_PATH)/evp/c_allc.c \
$(CRYPTO_PATH)/evp/c_alld.c \
$(CRYPTO_PATH)/evp/digest.c \
$(CRYPTO_PATH)/evp/e_aes.c \
$(CRYPTO_PATH)/evp/e_bf.c \
$(CRYPTO_PATH)/evp/e_des.c \
$(CRYPTO_PATH)/evp/e_des3.c \
$(CRYPTO_PATH)/evp/e_null.c \
$(CRYPTO_PATH)/evp/e_old.c \
$(CRYPTO_PATH)/evp/e_rc2.c \
$(CRYPTO_PATH)/evp/e_rc4.c \
$(CRYPTO_PATH)/evp/e_rc5.c \
$(CRYPTO_PATH)/evp/e_xcbc_d.c \
$(CRYPTO_PATH)/evp/encode.c \
$(CRYPTO_PATH)/evp/evp_acnf.c \
$(CRYPTO_PATH)/evp/evp_enc.c \
$(CRYPTO_PATH)/evp/evp_err.c \
$(CRYPTO_PATH)/evp/evp_key.c \
$(CRYPTO_PATH)/evp/evp_lib.c \
$(CRYPTO_PATH)/evp/evp_pbe.c \
$(CRYPTO_PATH)/evp/evp_pkey.c \
$(CRYPTO_PATH)/evp/m_dss.c \
$(CRYPTO_PATH)/evp/m_dss1.c \
$(CRYPTO_PATH)/evp/m_ecdsa.c \
$(CRYPTO_PATH)/evp/m_md4.c \
$(CRYPTO_PATH)/evp/m_md5.c \
$(CRYPTO_PATH)/evp/m_mdc2.c \
$(CRYPTO_PATH)/evp/m_null.c \
$(CRYPTO_PATH)/evp/m_ripemd.c \
$(CRYPTO_PATH)/evp/m_sha1.c \
$(CRYPTO_PATH)/evp/m_sigver.c \
$(CRYPTO_PATH)/evp/m_wp.c \
$(CRYPTO_PATH)/evp/names.c \
$(CRYPTO_PATH)/evp/p5_crpt.c \
$(CRYPTO_PATH)/evp/p5_crpt2.c \
$(CRYPTO_PATH)/evp/p_dec.c \
$(CRYPTO_PATH)/evp/p_enc.c \
$(CRYPTO_PATH)/evp/p_lib.c \
$(CRYPTO_PATH)/evp/p_open.c \
$(CRYPTO_PATH)/evp/p_seal.c \
$(CRYPTO_PATH)/evp/p_sign.c \
$(CRYPTO_PATH)/evp/p_verify.c \
$(CRYPTO_PATH)/evp/pmeth_fn.c \
$(CRYPTO_PATH)/evp/pmeth_gn.c \
$(CRYPTO_PATH)/evp/pmeth_lib.c \
$(CRYPTO_PATH)/hmac/hm_ameth.c \
$(CRYPTO_PATH)/hmac/hm_pmeth.c \
$(CRYPTO_PATH)/hmac/hmac.c \
$(CRYPTO_PATH)/krb5/krb5_asn.c \
$(CRYPTO_PATH)/lhash/lh_stats.c \
$(CRYPTO_PATH)/lhash/lhash.c \
$(CRYPTO_PATH)/md4/md4_dgst.c \
$(CRYPTO_PATH)/md4/md4_one.c \
$(CRYPTO_PATH)/md5/md5_dgst.c \
$(CRYPTO_PATH)/md5/md5_one.c \
$(CRYPTO_PATH)/modes/cbc128.c \
$(CRYPTO_PATH)/modes/cfb128.c \
$(CRYPTO_PATH)/modes/ctr128.c \
$(CRYPTO_PATH)/modes/ofb128.c \
$(CRYPTO_PATH)/objects/o_names.c \
$(CRYPTO_PATH)/objects/obj_dat.c \
$(CRYPTO_PATH)/objects/obj_err.c \
$(CRYPTO_PATH)/objects/obj_lib.c \
$(CRYPTO_PATH)/objects/obj_xref.c \
$(CRYPTO_PATH)/ocsp/ocsp_asn.c \
$(CRYPTO_PATH)/ocsp/ocsp_cl.c \
$(CRYPTO_PATH)/ocsp/ocsp_err.c \
$(CRYPTO_PATH)/ocsp/ocsp_ext.c \
$(CRYPTO_PATH)/ocsp/ocsp_ht.c \
$(CRYPTO_PATH)/ocsp/ocsp_lib.c \
$(CRYPTO_PATH)/ocsp/ocsp_prn.c \
$(CRYPTO_PATH)/ocsp/ocsp_srv.c \
$(CRYPTO_PATH)/ocsp/ocsp_vfy.c \
$(CRYPTO_PATH)/pem/pem_all.c \
$(CRYPTO_PATH)/pem/pem_err.c \
$(CRYPTO_PATH)/pem/pem_info.c \
$(CRYPTO_PATH)/pem/pem_lib.c \
$(CRYPTO_PATH)/pem/pem_oth.c \
$(CRYPTO_PATH)/pem/pem_pk8.c \
$(CRYPTO_PATH)/pem/pem_pkey.c \
$(CRYPTO_PATH)/pem/pem_seal.c \
$(CRYPTO_PATH)/pem/pem_sign.c \
$(CRYPTO_PATH)/pem/pem_x509.c \
$(CRYPTO_PATH)/pem/pem_xaux.c \
$(CRYPTO_PATH)/pem/pvkfmt.c \
$(CRYPTO_PATH)/pkcs12/p12_add.c \
$(CRYPTO_PATH)/pkcs12/p12_asn.c \
$(CRYPTO_PATH)/pkcs12/p12_attr.c \
$(CRYPTO_PATH)/pkcs12/p12_crpt.c \
$(CRYPTO_PATH)/pkcs12/p12_crt.c \
$(CRYPTO_PATH)/pkcs12/p12_decr.c \
$(CRYPTO_PATH)/pkcs12/p12_init.c \
$(CRYPTO_PATH)/pkcs12/p12_key.c \
$(CRYPTO_PATH)/pkcs12/p12_kiss.c \
$(CRYPTO_PATH)/pkcs12/p12_mutl.c \
$(CRYPTO_PATH)/pkcs12/p12_npas.c \
$(CRYPTO_PATH)/pkcs12/p12_p8d.c \
$(CRYPTO_PATH)/pkcs12/p12_p8e.c \
$(CRYPTO_PATH)/pkcs12/p12_utl.c \
$(CRYPTO_PATH)/pkcs12/pk12err.c \
$(CRYPTO_PATH)/pkcs7/pk7_asn1.c \
$(CRYPTO_PATH)/pkcs7/pk7_attr.c \
$(CRYPTO_PATH)/pkcs7/pk7_doit.c \
$(CRYPTO_PATH)/pkcs7/pk7_lib.c \
$(CRYPTO_PATH)/pkcs7/pk7_mime.c \
$(CRYPTO_PATH)/pkcs7/pk7_smime.c \
$(CRYPTO_PATH)/pkcs7/pkcs7err.c \
$(CRYPTO_PATH)/rand/md_rand.c \
$(CRYPTO_PATH)/rand/rand_egd.c \
$(CRYPTO_PATH)/rand/rand_err.c \
$(CRYPTO_PATH)/rand/rand_lib.c \
$(CRYPTO_PATH)/rand/rand_unix.c \
$(CRYPTO_PATH)/rand/randfile.c \
$(CRYPTO_PATH)/rc2/rc2_cbc.c \
$(CRYPTO_PATH)/rc2/rc2_ecb.c \
$(CRYPTO_PATH)/rc2/rc2_skey.c \
$(CRYPTO_PATH)/rc2/rc2cfb64.c \
$(CRYPTO_PATH)/rc2/rc2ofb64.c \
$(CRYPTO_PATH)/rc4/rc4_enc.c \
$(CRYPTO_PATH)/rc4/rc4_skey.c \
$(CRYPTO_PATH)/ripemd/rmd_dgst.c \
$(CRYPTO_PATH)/ripemd/rmd_one.c \
$(CRYPTO_PATH)/rsa/rsa_ameth.c \
$(CRYPTO_PATH)/rsa/rsa_asn1.c \
$(CRYPTO_PATH)/rsa/rsa_chk.c \
$(CRYPTO_PATH)/rsa/rsa_eay.c \
$(CRYPTO_PATH)/rsa/rsa_err.c \
$(CRYPTO_PATH)/rsa/rsa_gen.c \
$(CRYPTO_PATH)/rsa/rsa_lib.c \
$(CRYPTO_PATH)/rsa/rsa_none.c \
$(CRYPTO_PATH)/rsa/rsa_null.c \
$(CRYPTO_PATH)/rsa/rsa_oaep.c \
$(CRYPTO_PATH)/rsa/rsa_pk1.c \
$(CRYPTO_PATH)/rsa/rsa_pmeth.c \
$(CRYPTO_PATH)/rsa/rsa_prn.c \
$(CRYPTO_PATH)/rsa/rsa_pss.c \
$(CRYPTO_PATH)/rsa/rsa_saos.c \
$(CRYPTO_PATH)/rsa/rsa_sign.c \
$(CRYPTO_PATH)/rsa/rsa_ssl.c \
$(CRYPTO_PATH)/rsa/rsa_x931.c \
$(CRYPTO_PATH)/sha/sha1_one.c \
$(CRYPTO_PATH)/sha/sha1dgst.c \
$(CRYPTO_PATH)/sha/sha256.c \
$(CRYPTO_PATH)/sha/sha512.c \
$(CRYPTO_PATH)/sha/sha_dgst.c \
$(CRYPTO_PATH)/stack/stack.c \
$(CRYPTO_PATH)/ts/ts_err.c \
$(CRYPTO_PATH)/txt_db/txt_db.c \
$(CRYPTO_PATH)/ui/ui_compat.c \
$(CRYPTO_PATH)/ui/ui_err.c \
$(CRYPTO_PATH)/ui/ui_lib.c \
$(CRYPTO_PATH)/ui/ui_openssl.c \
$(CRYPTO_PATH)/ui/ui_util.c \
$(CRYPTO_PATH)/x509/by_dir.c \
$(CRYPTO_PATH)/x509/by_file.c \
$(CRYPTO_PATH)/x509/x509_att.c \
$(CRYPTO_PATH)/x509/x509_cmp.c \
$(CRYPTO_PATH)/x509/x509_d2.c \
$(CRYPTO_PATH)/x509/x509_def.c \
$(CRYPTO_PATH)/x509/x509_err.c \
$(CRYPTO_PATH)/x509/x509_ext.c \
$(CRYPTO_PATH)/x509/x509_lu.c \
$(CRYPTO_PATH)/x509/x509_obj.c \
$(CRYPTO_PATH)/x509/x509_r2x.c \
$(CRYPTO_PATH)/x509/x509_req.c \
$(CRYPTO_PATH)/x509/x509_set.c \
$(CRYPTO_PATH)/x509/x509_trs.c \
$(CRYPTO_PATH)/x509/x509_txt.c \
$(CRYPTO_PATH)/x509/x509_v3.c \
$(CRYPTO_PATH)/x509/x509_vfy.c \
$(CRYPTO_PATH)/x509/x509_vpm.c \
$(CRYPTO_PATH)/x509/x509cset.c \
$(CRYPTO_PATH)/x509/x509name.c \
$(CRYPTO_PATH)/x509/x509rset.c \
$(CRYPTO_PATH)/x509/x509spki.c \
$(CRYPTO_PATH)/x509/x509type.c \
$(CRYPTO_PATH)/x509/x_all.c \
$(CRYPTO_PATH)/x509v3/pcy_cache.c \
$(CRYPTO_PATH)/x509v3/pcy_data.c \
$(CRYPTO_PATH)/x509v3/pcy_lib.c \
$(CRYPTO_PATH)/x509v3/pcy_map.c \
$(CRYPTO_PATH)/x509v3/pcy_node.c \
$(CRYPTO_PATH)/x509v3/pcy_tree.c \
$(CRYPTO_PATH)/x509v3/v3_akey.c \
$(CRYPTO_PATH)/x509v3/v3_akeya.c \
$(CRYPTO_PATH)/x509v3/v3_alt.c \
$(CRYPTO_PATH)/x509v3/v3_bcons.c \
$(CRYPTO_PATH)/x509v3/v3_bitst.c \
$(CRYPTO_PATH)/x509v3/v3_conf.c \
$(CRYPTO_PATH)/x509v3/v3_cpols.c \
$(CRYPTO_PATH)/x509v3/v3_crld.c \
$(CRYPTO_PATH)/x509v3/v3_enum.c \
$(CRYPTO_PATH)/x509v3/v3_extku.c \
$(CRYPTO_PATH)/x509v3/v3_genn.c \
$(CRYPTO_PATH)/x509v3/v3_ia5.c \
$(CRYPTO_PATH)/x509v3/v3_info.c \
$(CRYPTO_PATH)/x509v3/v3_int.c \
$(CRYPTO_PATH)/x509v3/v3_lib.c \
$(CRYPTO_PATH)/x509v3/v3_ncons.c \
$(CRYPTO_PATH)/x509v3/v3_ocsp.c \
$(CRYPTO_PATH)/x509v3/v3_pci.c \
$(CRYPTO_PATH)/x509v3/v3_pcia.c \
$(CRYPTO_PATH)/x509v3/v3_pcons.c \
$(CRYPTO_PATH)/x509v3/v3_pku.c \
$(CRYPTO_PATH)/x509v3/v3_pmaps.c \
$(CRYPTO_PATH)/x509v3/v3_prn.c \
$(CRYPTO_PATH)/x509v3/v3_purp.c \
$(CRYPTO_PATH)/x509v3/v3_skey.c \
$(CRYPTO_PATH)/x509v3/v3_sxnet.c \
$(CRYPTO_PATH)/x509v3/v3_utl.c \
$(CRYPTO_PATH)/x509v3/v3err.c
local_ssl_src := \
$(SSL_PATH)/s2_meth.c \
$(SSL_PATH)/s2_srvr.c \
$(SSL_PATH)/s2_clnt.c \
$(SSL_PATH)/s2_lib.c \
$(SSL_PATH)/s2_enc.c \
$(SSL_PATH)/s2_pkt.c \
$(SSL_PATH)/s3_meth.c \
$(SSL_PATH)/s3_srvr.c \
$(SSL_PATH)/s3_clnt.c \
$(SSL_PATH)/s3_lib.c \
$(SSL_PATH)/s3_enc.c \
$(SSL_PATH)/s3_pkt.c \
$(SSL_PATH)/s3_both.c \
$(SSL_PATH)/s23_meth.c \
$(SSL_PATH)/s23_srvr.c \
$(SSL_PATH)/s23_clnt.c \
$(SSL_PATH)/s23_lib.c \
$(SSL_PATH)/s23_pkt.c \
$(SSL_PATH)/t1_meth.c \
$(SSL_PATH)/t1_srvr.c \
$(SSL_PATH)/t1_clnt.c \
$(SSL_PATH)/t1_lib.c \
$(SSL_PATH)/t1_enc.c \
$(SSL_PATH)/t1_reneg.c \
$(SSL_PATH)/ssl_lib.c \
$(SSL_PATH)/ssl_err2.c \
$(SSL_PATH)/ssl_cert.c \
$(SSL_PATH)/ssl_sess.c \
$(SSL_PATH)/ssl_ciph.c \
$(SSL_PATH)/ssl_stat.c \
$(SSL_PATH)/ssl_rsa.c \
$(SSL_PATH)/ssl_asn1.c \
$(SSL_PATH)/ssl_txt.c \
$(SSL_PATH)/ssl_algs.c \
$(SSL_PATH)/bio_ssl.c \
$(SSL_PATH)/ssl_err.c \
$(SSL_PATH)/kssl.c
local_c_flags := -DNO_WINDOWS_BRAINDEATH
#######################################
# target
include $(CLEAR_VARS)
include $(LOCAL_PATH)/android-config.mk
LOCAL_SRC_FILES += $(local_crypto_src)
LOCAL_CFLAGS += $(local_c_flags)
LOCAL_C_INCLUDES += $(local_c_includes)
LOCAL_LDLIBS += -lz
ifeq ($(TARGET_ARCH),arm)
LOCAL_SRC_FILES += $(arm_src_files)
LOCAL_CFLAGS += $(arm_cflags)
else
LOCAL_SRC_FILES += $(non_arm_src_files)
endif
ifeq ($(TARGET_SIMULATOR),true)
# Make valgrind happy.
LOCAL_CFLAGS += -DPURIFY
LOCAL_LDLIBS += -ldl
endif
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE:= libcrypto
include $(BUILD_SHARED_LIBRARY)
#######################################
# host shared library
ifeq ($(WITH_HOST_DALVIK),true)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/../android-config.mk
LOCAL_SRC_FILES += $(local_crypto_src)
LOCAL_CFLAGS += $(local_c_flags) -DPURIFY
LOCAL_C_INCLUDES += $(local_c_includes)
LOCAL_SRC_FILES += $(non_arm_src_files)
LOCAL_LDLIBS += -ldl
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE:= libcrypto
include $(BUILD_SHARED_LIBRARY)
endif
#######################################
include $(CLEAR_VARS)
include $(LOCAL_PATH)/android-config.mk
LOCAL_C_INCLUDES += $(local_c_includes)
LOCAL_SRC_FILES += $(local_ssl_src)
LOCAL_SHARED_LIBRARIES += libcrypto
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libssl
include $(BUILD_SHARED_LIBRARY)
#######################################
include $(CLEAR_VARS)
LOCAL_C_INCLUDES += $(local_c_includes)
LOCAL_SRC_FILES += test.c
LOCAL_SHARED_LIBRARIES += libssl libcrypto
LOCAL_LDLIBS += -llog
LOCAL_MODULE := libtest
include $(BUILD_SHARED_LIBRARY)
3. 源码附件
相关推荐
在这个项目中,Android应用可能通过JNI层的函数调用到预先编译好的OpenSSL和cURL库,进行网络请求。开发者可能已经编写了Java层的接口,以友好的方式供Java代码调用这些C/C++函数,这样Java代码无需直接处理底层的...
在Android平台上进行安全加密操作时,JNI(Java Native Interface)和OpenSSL库是不可或缺的工具。OpenSSL是一个强大的安全套接层(SSL)和传输层安全(TLS)协议实现库,同时也提供了各种加密算法、证书处理等功能...
本文将深入探讨如何在Android环境下利用JNI集成OpenSSL库,以实现更安全的数据加密和通信。 OpenSSL是一个强大的安全套接字层密码库,包含各种主要的密码算法、常用的密钥和证书封装管理功能以及SSL协议,并提供...
在Android开发中,JNI(Java Native Interface)是一个关键的技术,允许Java代码和其他语言写的代码进行交互,通常是C++或C。在这个"android jni 加密demo"中,开发者使用JNI来实现多种加密算法,包括RSA、3DES、AES...
8. **rsademo**:这个压缩包中的子文件可能是一个RSA加密的演示程序,用于展示如何在Android环境下使用JNI和OpenSSL库进行RSA加密操作。 总结来说,这个“jni_demo.zip”提供了一个全面的Android JNI加密DEMO,涵盖...
Android提供了一个名为`<android/openssl/AES.h>`的库,里面包含了AES加密的函数,如`EVP_EncryptInit_ex()`, `EVP_EncryptUpdate()`, `EVP_EncryptFinal_ex()`等,用于初始化加密上下文、进行加密操作以及结束加密...
本项目主要探讨了如何使用C++语言通过JNI(Java Native Interface)与Android应用交互,实现基于OpenSSL库的加解密算法,包括RSA、AES、3DES、BASE64和MD5。以下是关于这些技术的详细解释: 1. **JNI(Java Native ...
这包括定义JNI函数接口,使用OpenSSL库(或者其他加密库)来实现AES算法,以及处理输入和输出数据。例如,我们可以定义一个JNI函数原型如下: ```c JNIEXPORT jbyteArray JNICALL Java_...
在Android开发中,JNI(Java Native Interface)是一种技术,允许Java代码和其他语言写的代码进行交互。这个场景下,我们讨论的是在JNI层实现Base64编码和解码,并且与Java层保持兼容。Base64是一种用于将二进制数据...
在集成这些库文件到 Android 项目时,通常需要将它们添加到项目的 `jniLibs` 目录下,并在 Java 代码中使用 System.loadLibrary() 方法加载对应的库。同时,需要注意版本兼容性问题,确保所使用的 OpenSSL 版本与...
编译完成后,将生成的`.a`或`.so`库文件添加到Android项目的`jniLibs`目录下,然后在Java或Kotlin代码中通过JNI(Java Native Interface)调用C/C++代码,即可在Android应用中使用OpenSSL提供的加密功能。...
在Android.mk或CMakeLists.txt文件中,链接所需的库,如OpenSSL或这里提到的`tiny-AES-c-master`库。在`.cpp`文件中,定义JNI函数,如下: ```cpp extern "C"JNIEXPORT jbyteArray JNICALL Java_...
本教程主要涉及的是在Android平台上通过JNI(Java Native Interface)使用RSA、3DES和BASE64算法进行加解密操作,这些技术都是在Native层实现的,以提供更高的性能和安全性。 首先,我们来了解这些加密算法: 1. *...
本篇将详细介绍如何在Android应用中通过JNI(Java Native Interface)调用C++动态库进行AES256位加密。 首先,我们要理解JNI的概念。JNI是Java平台的标准接口,允许Java代码和其他语言写的代码进行交互。在Android...
#aes encrypt with Android Jni based by openssl evp api 这是一个项目过程aes encrypt and decrpty,JNI打包,并使用OPENSSL EVP api。 ##文件夹树: | |-sosec (ndk build的根文件夹) |--myApp (主 cpp 文件夹...
对于Android,可以将.so文件放入项目的jniLibs目录下。 6. **测试和调试**: 完成集成后,务必进行充分的测试,确保OpenSSL库在目标设备上运行正常,无任何链接或运行时错误。如有问题,可以查看编译脚本的输出...
Android OpenSSL 1.1.1h 版本是针对Android平台的一个重要的安全库更新,它主要为ARM架构的设备提供加密支持。这个版本包含了针对armabi-v7a和arm64-v8a这两种常见的Android处理器架构的二进制库。在Android系统中,...
JNILibs.rar是一个压缩包,其中包含了用于Android平台的OpenSSL静态库。OpenSSL是一个开源的库,主要用于实现加密、安全通信以及数字证书等网络安全功能。在Android应用开发中,有时我们需要直接在本地代码(C/C++)...
在Android平台上,开发人员经常需要处理加密和安全通信任务,这时OpenSSL库就显得尤为重要。OpenSSL是一个开源的加密库,包含了大量的加密算法,如RSA、AES、MD5等,同时也提供了SSL/TLS协议的支持,使得应用程序...