int main (int argc, char *argv[]) { std::string pcd_file; if (argc > 1) { pcd_file = argv[1]; } else { printf ("\nUsage: pcl_example_nurbs_fitting_curve pcd-file \n\n"); printf (" pcd-file point-cloud file\n"); exit (0); } // #################### LOAD FILE ######################### printf (" loading %s\n", pcd_file.c_str ()); pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>); pcl::PCLPointCloud2 cloud2; if (pcl::io::loadPCDFile (pcd_file, cloud2) == -1) throw std::runtime_error (" PCD file not found."); fromPCLPointCloud2 (cloud2, *cloud); // convert to NURBS data structure pcl::on_nurbs::NurbsDataCurve2d data; PointCloud2Vector2d (cloud, data.interior); viewer.setSize (800, 600); viewer.addPointCloud<pcl::PointXYZ> (cloud, "cloud"); // #################### CURVE PARAMETERS ######################### unsigned order (3); unsigned n_control_points (10); pcl::on_nurbs::FittingCurve2d::Parameter curve_params; curve_params.smoothness = 0.000001; curve_params.rScale = 1.0; // #################### CURVE FITTING ######################### ON_NurbsCurve curve = pcl::on_nurbs::FittingCurve2d::initNurbsPCA (order, &data, n_control_points); pcl::on_nurbs::FittingCurve2d fit (&data, curve); fit.assemble (curve_params); Eigen::Vector2d fix1 (0.1, 0.1); Eigen::Vector2d fix2 (1.0, 0.0); // fit.addControlPointConstraint (0, fix1, 100.0); // fit.addControlPointConstraint (curve.CVCount () - 1, fix2, 100.0); fit.solve (); // visualize VisualizeCurve (fit.m_nurbs, 1.0, 0.0, 0.0, true); viewer.spin (); return 0; }
int crypto_aead_decrypt( unsigned char *m,unsigned long long *mlen, // message unsigned char *nsec, // not relavent to CLOC or SLIC const unsigned char *c,unsigned long long clen, // ciphertext const unsigned char *ad,unsigned long long adlen, // associated data const unsigned char *npub, // nonce const unsigned char *k // the master key ) { block estate, tstate, tmp; // encryption state, tag state, and temporary state estate = SETZERO(); unsigned char ltag[16]; // local copy of temporary tag value unsigned long long i, lastblocklen,j; /* set ciphertext length */ *mlen = clen - CRYPTO_ABYTES; /* generate round keys from master key */ AES128_KeyExpansion(k); /* process the first (partial) block of ad */ load_partial_block(&estate, ad, (adlen>STATE_LEN)?STATE_LEN:adlen, ONE_ZERO_PADDING); fix0(estate); AES128_encrypt(estate, estate); if((ad[0] & 0x80) || (adlen == 0)){ // appy h h(estate); } else{ // do nothing } if(adlen > STATE_LEN){ // ad is of moer than one block i = STATE_LEN; /* process the middle ad blocks, excluding the first and last (partial) block */ while((i+STATE_LEN) < adlen) { tmp = LOAD(ad+i); estate = XOR(estate, tmp); AES128_encrypt(estate, estate); i += STATE_LEN; } /* process the last (partial) ad block */ load_partial_block(&tmp, ad+i, adlen - i, ONE_ZERO_PADDING); estate = XOR(estate, tmp); AES128_encrypt(estate, estate); } /* process the nonce */ load_partial_block(&tmp, npub, CRYPTO_NPUBBYTES, PARAM_OZP); estate = XOR(estate, tmp); if((adlen % STATE_LEN) || (adlen == 0)){ /* apply f2 */ f2(estate); } else{ /* apply f1 */ f1(estate); } /* process ciphertext */ tstate = estate; AES128_encrypt(estate, estate); if(*mlen){ /* apply g2 to tag state */ g2(tstate); } else{ /* apply g1 to tag state */ g1(tstate); } AES128_encrypt(tstate, tstate); i = 0; /* process all the message except for the last message/ciphertext block */ while((i + STATE_LEN) < (*mlen)){ tmp = LOAD(c+i); estate = XOR(estate, tmp); STORE(m+i, estate); tstate = XOR(tmp, tstate); AES128_encrypt(tstate, tstate); fix1(tmp); print_state("after applying fix1\n", estate); AES128_encrypt(tmp, estate); i += STATE_LEN; } /* process the last block of the message/ciphetext */ lastblocklen = (*mlen) - i; if(lastblocklen > 0){ load_partial_block(&tmp, c+i, lastblocklen, ZERO_APPEND); estate = XOR(estate, tmp); print_state("after xoring last partial message block\n", estate); store_partial_block(m+i, estate, lastblocklen); unsigned char shift_bytes = (STATE_LEN - (unsigned char)lastblocklen); tmp = AND(SHR(_mm_set1_epi8(0xff), shift_bytes), tmp); tstate = XOR(tstate, tmp); /* add the one zero padding */ tstate = XOR(tstate, SHL(_mm_set_epi8(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x80), lastblocklen)); if((*mlen) % STATE_LEN){ /* apply f2 */ f2(tstate); } else{ /* apply f1 */ f1(tstate); } AES128_encrypt(tstate, tstate); } /* compare tag and output message */ STORE(ltag, tstate); for(j = 0; j < CRYPTO_ABYTES; j++){ if(ltag[j] != c[clen - CRYPTO_ABYTES + j]) return RETURN_TAG_NO_MATCH; } return RETURN_SUCCESS; }