jwawincrypt.pas 738 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661
  1. {******************************************************************************}
  2. { }
  3. { Windows Cryptography API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: wincrypt.h, released June 2000. The original Pascal }
  9. { code is: WinCrypt.pas, released December 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. // $Id: JwaWinCrypt.pas,v 1.13 2005/09/06 16:36:50 marquardt Exp $
  43. {$IFNDEF JWA_INCLUDEMODE}
  44. unit JwaWinCrypt;
  45. {$I jediapilib.inc}
  46. {$WEAKPACKAGEUNIT}
  47. interface
  48. uses
  49. JwaWindows;
  50. {$ENDIF !JWA_INCLUDEMODE}
  51. {$IFDEF JWA_INTERFACESECTION}
  52. {$HPPEMIT ''}
  53. {$HPPEMIT '#include <WinCrypt.h>'}
  54. {$HPPEMIT ''}
  55. {$HPPEMIT 'typedef HCRYPTPROV *PHCRYPTPROV'}
  56. {$HPPEMIT 'typedef HCRYPTKEY *PHCRYPTKEY'}
  57. {$HPPEMIT 'typedef HCRYPTHASH *PHCRYPTHASH'}
  58. {$HPPEMIT 'typedef PROV_ENUMALGS *PPROV_ENUMALGS'}
  59. {$HPPEMIT 'typedef PROV_ENUMALGS_EX *PPROV_ENUMALGS_EX'}
  60. {$HPPEMIT 'typedef PUBLICKEYSTRUC *PPUBLICKEYSTRUC'}
  61. {$HPPEMIT 'typedef RSAPUBKEY *PRSAPUBKEY'}
  62. {$HPPEMIT 'typedef DSSSEED *PDSSSEED'}
  63. {$HPPEMIT 'typedef PUBKEYVER3 *PPUBKEYVER3'}
  64. {$HPPEMIT 'typedef DHPRIVKEY_VER3 *PPRIVKEYVER3'}
  65. {$HPPEMIT 'typedef CERT_FORTEZZA_DATA_PROP *PCERT_FORTEZZA_DATA_PROP'}
  66. {$HPPEMIT 'typedef HCRYPTMSG *PHCRYPTMSG'}
  67. {$HPPEMIT 'typedef CMSG_RECIPIENT_ENCODE_INFO *PCMSG_RECIPIENT_ENCODE_INFO'}
  68. {$HPPEMIT 'typedef _CMSG_RECIPIENT_ENCODE_INFO CMSG_RECIPIENT_ENCODE_INFO'}
  69. {$HPPEMIT 'typedef PCMSG_KEY_AGREE_KEY_ENCRYPT_INFO *PPCMSG_KEY_AGREE_KEY_ENCRYPT_INFO'}
  70. {$HPPEMIT 'typedef HCERTSTORE *PHCERTSTORE'}
  71. {$HPPEMIT 'typedef PCCERT_CONTEXT *PPCCERT_CONTEXT'}
  72. {$HPPEMIT 'typedef PCCRL_CONTEXT *PPCCRL_CONTEXT'}
  73. {$HPPEMIT 'typedef PCERT_CHAIN_CONTEXT *PPCCERT_CHAIN_CONTEXT'}
  74. {$HPPEMIT ''}
  75. //
  76. // Algorithm IDs and Flags
  77. //
  78. // ALG_ID crackers
  79. function GET_ALG_CLASS(x: DWORD): DWORD;
  80. {$EXTERNALSYM GET_ALG_CLASS}
  81. function GET_ALG_TYPE(x: DWORD): DWORD;
  82. {$EXTERNALSYM GET_ALG_TYPE}
  83. function GET_ALG_SID(x: DWORD): DWORD;
  84. {$EXTERNALSYM GET_ALG_SID}
  85. // Algorithm classes
  86. const
  87. ALG_CLASS_ANY = 0;
  88. {$EXTERNALSYM ALG_CLASS_ANY}
  89. ALG_CLASS_SIGNATURE = 1 shl 13;
  90. {$EXTERNALSYM ALG_CLASS_SIGNATURE}
  91. ALG_CLASS_MSG_ENCRYPT = 2 shl 13;
  92. {$EXTERNALSYM ALG_CLASS_MSG_ENCRYPT}
  93. ALG_CLASS_DATA_ENCRYPT = 3 shl 13;
  94. {$EXTERNALSYM ALG_CLASS_DATA_ENCRYPT}
  95. ALG_CLASS_HASH = 4 shl 13;
  96. {$EXTERNALSYM ALG_CLASS_HASH}
  97. ALG_CLASS_KEY_EXCHANGE = 5 shl 13;
  98. {$EXTERNALSYM ALG_CLASS_KEY_EXCHANGE}
  99. ALG_CLASS_ALL = 7 shl 13;
  100. {$EXTERNALSYM ALG_CLASS_ALL}
  101. // Algorithm types
  102. ALG_TYPE_ANY = 0;
  103. {$EXTERNALSYM ALG_TYPE_ANY}
  104. ALG_TYPE_DSS = 1 shl 9;
  105. {$EXTERNALSYM ALG_TYPE_DSS}
  106. ALG_TYPE_RSA = 2 shl 9;
  107. {$EXTERNALSYM ALG_TYPE_RSA}
  108. ALG_TYPE_BLOCK = 3 shl 9;
  109. {$EXTERNALSYM ALG_TYPE_BLOCK}
  110. ALG_TYPE_STREAM = 4 shl 9;
  111. {$EXTERNALSYM ALG_TYPE_STREAM}
  112. ALG_TYPE_DH = 5 shl 9;
  113. {$EXTERNALSYM ALG_TYPE_DH}
  114. ALG_TYPE_SECURECHANNEL = 6 shl 9;
  115. {$EXTERNALSYM ALG_TYPE_SECURECHANNEL}
  116. // Generic sub-ids
  117. ALG_SID_ANY = 0;
  118. {$EXTERNALSYM ALG_SID_ANY}
  119. // Some RSA sub-ids
  120. ALG_SID_RSA_ANY = 0;
  121. {$EXTERNALSYM ALG_SID_RSA_ANY}
  122. ALG_SID_RSA_PKCS = 1;
  123. {$EXTERNALSYM ALG_SID_RSA_PKCS}
  124. ALG_SID_RSA_MSATWORK = 2;
  125. {$EXTERNALSYM ALG_SID_RSA_MSATWORK}
  126. ALG_SID_RSA_ENTRUST = 3;
  127. {$EXTERNALSYM ALG_SID_RSA_ENTRUST}
  128. ALG_SID_RSA_PGP = 4;
  129. {$EXTERNALSYM ALG_SID_RSA_PGP}
  130. // Some DSS sub-ids
  131. //
  132. ALG_SID_DSS_ANY = 0;
  133. {$EXTERNALSYM ALG_SID_DSS_ANY}
  134. ALG_SID_DSS_PKCS = 1;
  135. {$EXTERNALSYM ALG_SID_DSS_PKCS}
  136. ALG_SID_DSS_DMS = 2;
  137. {$EXTERNALSYM ALG_SID_DSS_DMS}
  138. // Block cipher sub ids
  139. // DES sub_ids
  140. ALG_SID_DES = 1;
  141. {$EXTERNALSYM ALG_SID_DES}
  142. ALG_SID_3DES = 3;
  143. {$EXTERNALSYM ALG_SID_3DES}
  144. ALG_SID_DESX = 4;
  145. {$EXTERNALSYM ALG_SID_DESX}
  146. ALG_SID_IDEA = 5;
  147. {$EXTERNALSYM ALG_SID_IDEA}
  148. ALG_SID_CAST = 6;
  149. {$EXTERNALSYM ALG_SID_CAST}
  150. ALG_SID_SAFERSK64 = 7;
  151. {$EXTERNALSYM ALG_SID_SAFERSK64}
  152. ALG_SID_SAFERSK128 = 8;
  153. {$EXTERNALSYM ALG_SID_SAFERSK128}
  154. ALG_SID_3DES_112 = 9;
  155. {$EXTERNALSYM ALG_SID_3DES_112}
  156. ALG_SID_CYLINK_MEK = 12;
  157. {$EXTERNALSYM ALG_SID_CYLINK_MEK}
  158. ALG_SID_RC5 = 13;
  159. {$EXTERNALSYM ALG_SID_RC5}
  160. // Fortezza sub-ids
  161. ALG_SID_SKIPJACK = 10;
  162. {$EXTERNALSYM ALG_SID_SKIPJACK}
  163. ALG_SID_TEK = 11;
  164. {$EXTERNALSYM ALG_SID_TEK}
  165. // KP_MODE
  166. CRYPT_MODE_CBCI = 6; // ANSI CBC Interleaved
  167. {$EXTERNALSYM CRYPT_MODE_CBCI}
  168. CRYPT_MODE_CFBP = 7; // ANSI CFB Pipelined
  169. {$EXTERNALSYM CRYPT_MODE_CFBP}
  170. CRYPT_MODE_OFBP = 8; // ANSI OFB Pipelined
  171. {$EXTERNALSYM CRYPT_MODE_OFBP}
  172. CRYPT_MODE_CBCOFM = 9; // ANSI CBC + OF Masking
  173. {$EXTERNALSYM CRYPT_MODE_CBCOFM}
  174. CRYPT_MODE_CBCOFMI = 10; // ANSI CBC + OFM Interleaved
  175. {$EXTERNALSYM CRYPT_MODE_CBCOFMI}
  176. // RC2 sub-ids
  177. ALG_SID_RC2 = 2;
  178. {$EXTERNALSYM ALG_SID_RC2}
  179. // Stream cipher sub-ids
  180. ALG_SID_RC4 = 1;
  181. {$EXTERNALSYM ALG_SID_RC4}
  182. ALG_SID_SEAL = 2;
  183. {$EXTERNALSYM ALG_SID_SEAL}
  184. // Diffie-Hellman sub-ids
  185. ALG_SID_DH_SANDF = 1;
  186. {$EXTERNALSYM ALG_SID_DH_SANDF}
  187. ALG_SID_DH_EPHEM = 2;
  188. {$EXTERNALSYM ALG_SID_DH_EPHEM}
  189. ALG_SID_AGREED_KEY_ANY = 3;
  190. {$EXTERNALSYM ALG_SID_AGREED_KEY_ANY}
  191. ALG_SID_KEA = 4;
  192. {$EXTERNALSYM ALG_SID_KEA}
  193. // Hash sub ids
  194. ALG_SID_MD2 = 1;
  195. {$EXTERNALSYM ALG_SID_MD2}
  196. ALG_SID_MD4 = 2;
  197. {$EXTERNALSYM ALG_SID_MD4}
  198. ALG_SID_MD5 = 3;
  199. {$EXTERNALSYM ALG_SID_MD5}
  200. ALG_SID_SHA = 4;
  201. {$EXTERNALSYM ALG_SID_SHA}
  202. ALG_SID_SHA1 = 4;
  203. {$EXTERNALSYM ALG_SID_SHA1}
  204. ALG_SID_MAC = 5;
  205. {$EXTERNALSYM ALG_SID_MAC}
  206. ALG_SID_RIPEMD = 6;
  207. {$EXTERNALSYM ALG_SID_RIPEMD}
  208. ALG_SID_RIPEMD160 = 7;
  209. {$EXTERNALSYM ALG_SID_RIPEMD160}
  210. ALG_SID_SSL3SHAMD5 = 8;
  211. {$EXTERNALSYM ALG_SID_SSL3SHAMD5}
  212. ALG_SID_HMAC = 9;
  213. {$EXTERNALSYM ALG_SID_HMAC}
  214. ALG_SID_TLS1PRF = 10;
  215. {$EXTERNALSYM ALG_SID_TLS1PRF}
  216. // secure channel sub ids
  217. ALG_SID_SSL3_MASTER = 1;
  218. {$EXTERNALSYM ALG_SID_SSL3_MASTER}
  219. ALG_SID_SCHANNEL_MASTER_HASH = 2;
  220. {$EXTERNALSYM ALG_SID_SCHANNEL_MASTER_HASH}
  221. ALG_SID_SCHANNEL_MAC_KEY = 3;
  222. {$EXTERNALSYM ALG_SID_SCHANNEL_MAC_KEY}
  223. ALG_SID_PCT1_MASTER = 4;
  224. {$EXTERNALSYM ALG_SID_PCT1_MASTER}
  225. ALG_SID_SSL2_MASTER = 5;
  226. {$EXTERNALSYM ALG_SID_SSL2_MASTER}
  227. ALG_SID_TLS1_MASTER = 6;
  228. {$EXTERNALSYM ALG_SID_TLS1_MASTER}
  229. ALG_SID_SCHANNEL_ENC_KEY = 7;
  230. {$EXTERNALSYM ALG_SID_SCHANNEL_ENC_KEY}
  231. // Our silly example sub-id
  232. ALG_SID_EXAMPLE = 80;
  233. {$EXTERNALSYM ALG_SID_EXAMPLE}
  234. type
  235. ALG_ID = Cardinal;
  236. {$EXTERNALSYM ALG_ID}
  237. // algorithm identifier definitions
  238. const
  239. CALG_MD2 = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_MD2;
  240. {$EXTERNALSYM CALG_MD2}
  241. CALG_MD4 = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_MD4;
  242. {$EXTERNALSYM CALG_MD4}
  243. CALG_MD5 = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_MD5;
  244. {$EXTERNALSYM CALG_MD5}
  245. CALG_SHA = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_SHA;
  246. {$EXTERNALSYM CALG_SHA}
  247. CALG_SHA1 = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_SHA1;
  248. {$EXTERNALSYM CALG_SHA1}
  249. CALG_MAC = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_MAC;
  250. {$EXTERNALSYM CALG_MAC}
  251. CALG_RSA_SIGN = ALG_CLASS_SIGNATURE or ALG_TYPE_RSA or ALG_SID_RSA_ANY;
  252. {$EXTERNALSYM CALG_RSA_SIGN}
  253. CALG_DSS_SIGN = ALG_CLASS_SIGNATURE or ALG_TYPE_DSS or ALG_SID_DSS_ANY;
  254. {$EXTERNALSYM CALG_DSS_SIGN}
  255. CALG_RSA_KEYX = ALG_CLASS_KEY_EXCHANGE or ALG_TYPE_RSA or ALG_SID_RSA_ANY;
  256. {$EXTERNALSYM CALG_RSA_KEYX}
  257. CALG_DES = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_DES;
  258. {$EXTERNALSYM CALG_DES}
  259. CALG_3DES_112 = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_3DES_112;
  260. {$EXTERNALSYM CALG_3DES_112}
  261. CALG_3DES = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_3DES;
  262. {$EXTERNALSYM CALG_3DES}
  263. CALG_DESX = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_DESX;
  264. {$EXTERNALSYM CALG_DESX}
  265. CALG_RC2 = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_RC2;
  266. {$EXTERNALSYM CALG_RC2}
  267. CALG_RC4 = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_STREAM or ALG_SID_RC4;
  268. {$EXTERNALSYM CALG_RC4}
  269. CALG_SEAL = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_STREAM or ALG_SID_SEAL;
  270. {$EXTERNALSYM CALG_SEAL}
  271. CALG_DH_SF = ALG_CLASS_KEY_EXCHANGE or ALG_TYPE_DH or ALG_SID_DH_SANDF;
  272. {$EXTERNALSYM CALG_DH_SF}
  273. CALG_DH_EPHEM = ALG_CLASS_KEY_EXCHANGE or ALG_TYPE_DH or ALG_SID_DH_EPHEM;
  274. {$EXTERNALSYM CALG_DH_EPHEM}
  275. CALG_AGREEDKEY_ANY = ALG_CLASS_KEY_EXCHANGE or ALG_TYPE_DH or ALG_SID_AGREED_KEY_ANY;
  276. {$EXTERNALSYM CALG_AGREEDKEY_ANY}
  277. CALG_KEA_KEYX = ALG_CLASS_KEY_EXCHANGE or ALG_TYPE_DH or ALG_SID_KEA;
  278. {$EXTERNALSYM CALG_KEA_KEYX}
  279. CALG_HUGHES_MD5 = ALG_CLASS_KEY_EXCHANGE or ALG_TYPE_ANY or ALG_SID_MD5;
  280. {$EXTERNALSYM CALG_HUGHES_MD5}
  281. CALG_SKIPJACK = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_SKIPJACK;
  282. {$EXTERNALSYM CALG_SKIPJACK}
  283. CALG_TEK = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_TEK;
  284. {$EXTERNALSYM CALG_TEK}
  285. CALG_CYLINK_MEK = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_CYLINK_MEK;
  286. {$EXTERNALSYM CALG_CYLINK_MEK}
  287. CALG_SSL3_SHAMD5 = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_SSL3SHAMD5;
  288. {$EXTERNALSYM CALG_SSL3_SHAMD5}
  289. CALG_SSL3_MASTER = ALG_CLASS_MSG_ENCRYPT or ALG_TYPE_SECURECHANNEL or ALG_SID_SSL3_MASTER;
  290. {$EXTERNALSYM CALG_SSL3_MASTER}
  291. CALG_SCHANNEL_MASTER_HASH = ALG_CLASS_MSG_ENCRYPT or ALG_TYPE_SECURECHANNEL or ALG_SID_SCHANNEL_MASTER_HASH;
  292. {$EXTERNALSYM CALG_SCHANNEL_MASTER_HASH}
  293. CALG_SCHANNEL_MAC_KEY = ALG_CLASS_MSG_ENCRYPT or ALG_TYPE_SECURECHANNEL or ALG_SID_SCHANNEL_MAC_KEY;
  294. {$EXTERNALSYM CALG_SCHANNEL_MAC_KEY}
  295. CALG_SCHANNEL_ENC_KEY = ALG_CLASS_MSG_ENCRYPT or ALG_TYPE_SECURECHANNEL or ALG_SID_SCHANNEL_ENC_KEY;
  296. {$EXTERNALSYM CALG_SCHANNEL_ENC_KEY}
  297. CALG_PCT1_MASTER = ALG_CLASS_MSG_ENCRYPT or ALG_TYPE_SECURECHANNEL or ALG_SID_PCT1_MASTER;
  298. {$EXTERNALSYM CALG_PCT1_MASTER}
  299. CALG_SSL2_MASTER = ALG_CLASS_MSG_ENCRYPT or ALG_TYPE_SECURECHANNEL or ALG_SID_SSL2_MASTER;
  300. {$EXTERNALSYM CALG_SSL2_MASTER}
  301. CALG_TLS1_MASTER = ALG_CLASS_MSG_ENCRYPT or ALG_TYPE_SECURECHANNEL or ALG_SID_TLS1_MASTER;
  302. {$EXTERNALSYM CALG_TLS1_MASTER}
  303. CALG_RC5 = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_RC5;
  304. {$EXTERNALSYM CALG_RC5}
  305. CALG_HMAC = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_HMAC;
  306. {$EXTERNALSYM CALG_HMAC}
  307. CALG_TLS1PRF = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_TLS1PRF;
  308. {$EXTERNALSYM CALG_TLS1PRF}
  309. // resource number for signatures in the CSP
  310. SIGNATURE_RESOURCE_NUMBER = $29A;
  311. {$EXTERNALSYM SIGNATURE_RESOURCE_NUMBER}
  312. type
  313. PVTableProvStruc = ^VTableProvStruc;
  314. _VTableProvStruc = record
  315. Version: DWORD;
  316. FuncVerifyImage: FARPROC;
  317. FuncReturnhWnd: FARPROC;
  318. dwProvType: DWORD;
  319. pbContextInfo: LPBYTE;
  320. cbContextInfo: DWORD;
  321. pszProvName: LPSTR;
  322. end;
  323. {$EXTERNALSYM _VTableProvStruc}
  324. VTableProvStruc = _VTableProvStruc;
  325. {$EXTERNALSYM VTableProvStruc}
  326. TVTableProvStruc = VTableProvStruc;
  327. HCRYPTPROV = ULONG_PTR;
  328. {$EXTERNALSYM HCRYPTPROV}
  329. HCRYPTKEY = ULONG_PTR;
  330. {$EXTERNALSYM HCRYPTKEY}
  331. HCRYPTHASH = ULONG_PTR;
  332. {$EXTERNALSYM HCRYPTHASH}
  333. PHCRYPTPROV = ^HCRYPTPROV;
  334. {$NODEFINE PHCRYPTPROV}
  335. PHCRYPTKEY = ^HCRYPTKEY;
  336. {$NODEFINE PHCRYPTKEY}
  337. PHCRYPTHASH = ^HCRYPTHASH;
  338. {$NODEFINE PHCRYPTHASH}
  339. // dwFlags definitions for CryptAcquireContext
  340. const
  341. CRYPT_VERIFYCONTEXT = DWORD($F0000000);
  342. {$EXTERNALSYM CRYPT_VERIFYCONTEXT}
  343. CRYPT_NEWKEYSET = $00000008;
  344. {$EXTERNALSYM CRYPT_NEWKEYSET}
  345. CRYPT_DELETEKEYSET = $00000010;
  346. {$EXTERNALSYM CRYPT_DELETEKEYSET}
  347. CRYPT_MACHINE_KEYSET = $00000020;
  348. {$EXTERNALSYM CRYPT_MACHINE_KEYSET}
  349. CRYPT_SILENT = $00000040;
  350. {$EXTERNALSYM CRYPT_SILENT}
  351. // dwFlag definitions for CryptGenKey
  352. CRYPT_EXPORTABLE = $00000001;
  353. {$EXTERNALSYM CRYPT_EXPORTABLE}
  354. CRYPT_USER_PROTECTED = $00000002;
  355. {$EXTERNALSYM CRYPT_USER_PROTECTED}
  356. CRYPT_CREATE_SALT = $00000004;
  357. {$EXTERNALSYM CRYPT_CREATE_SALT}
  358. CRYPT_UPDATE_KEY = $00000008;
  359. {$EXTERNALSYM CRYPT_UPDATE_KEY}
  360. CRYPT_NO_SALT = $00000010;
  361. {$EXTERNALSYM CRYPT_NO_SALT}
  362. CRYPT_PREGEN = $00000040;
  363. {$EXTERNALSYM CRYPT_PREGEN}
  364. CRYPT_RECIPIENT = $00000010;
  365. {$EXTERNALSYM CRYPT_RECIPIENT}
  366. CRYPT_INITIATOR = $00000040;
  367. {$EXTERNALSYM CRYPT_INITIATOR}
  368. CRYPT_ONLINE = $00000080;
  369. {$EXTERNALSYM CRYPT_ONLINE}
  370. CRYPT_SF = $00000100;
  371. {$EXTERNALSYM CRYPT_SF}
  372. CRYPT_CREATE_IV = $00000200;
  373. {$EXTERNALSYM CRYPT_CREATE_IV}
  374. CRYPT_KEK = $00000400;
  375. {$EXTERNALSYM CRYPT_KEK}
  376. CRYPT_DATA_KEY = $00000800;
  377. {$EXTERNALSYM CRYPT_DATA_KEY}
  378. CRYPT_VOLATILE = $00001000;
  379. {$EXTERNALSYM CRYPT_VOLATILE}
  380. CRYPT_SGCKEY = $00002000;
  381. {$EXTERNALSYM CRYPT_SGCKEY}
  382. RSA1024BIT_KEY = $04000000;
  383. {$EXTERNALSYM RSA1024BIT_KEY}
  384. // dwFlags definitions for CryptDeriveKey
  385. CRYPT_SERVER = $00000400;
  386. {$EXTERNALSYM CRYPT_SERVER}
  387. KEY_LENGTH_MASK = DWORD($FFFF0000);
  388. {$EXTERNALSYM KEY_LENGTH_MASK}
  389. // dwFlag definitions for CryptExportKey
  390. CRYPT_Y_ONLY = $00000001;
  391. {$EXTERNALSYM CRYPT_Y_ONLY}
  392. CRYPT_SSL2_FALLBACK = $00000002;
  393. {$EXTERNALSYM CRYPT_SSL2_FALLBACK}
  394. CRYPT_DESTROYKEY = $00000004;
  395. {$EXTERNALSYM CRYPT_DESTROYKEY}
  396. CRYPT_OAEP = $00000040; // used with RSA encryptions/decryptions
  397. // CryptExportKey, CryptImportKey,
  398. // CryptEncrypt and CryptDecrypt
  399. {$EXTERNALSYM CRYPT_OAEP}
  400. CRYPT_BLOB_VER3 = $00000080; // export version 3 of a blob type
  401. {$EXTERNALSYM CRYPT_BLOB_VER3}
  402. // dwFlags definitions for CryptCreateHash
  403. CRYPT_SECRETDIGEST = $00000001;
  404. {$EXTERNALSYM CRYPT_SECRETDIGEST}
  405. // dwFlags definitions for CryptHashSessionKey
  406. CRYPT_LITTLE_ENDIAN = $00000001;
  407. {$EXTERNALSYM CRYPT_LITTLE_ENDIAN}
  408. // dwFlags definitions for CryptSignHash and CryptVerifySignature
  409. CRYPT_NOHASHOID = $00000001;
  410. {$EXTERNALSYM CRYPT_NOHASHOID}
  411. CRYPT_TYPE2_FORMAT = $00000002;
  412. {$EXTERNALSYM CRYPT_TYPE2_FORMAT}
  413. CRYPT_X931_FORMAT = $00000004;
  414. {$EXTERNALSYM CRYPT_X931_FORMAT}
  415. // dwFlag definitions for CryptSetProviderEx and CryptGetDefaultProvider
  416. CRYPT_MACHINE_DEFAULT = $00000001;
  417. {$EXTERNALSYM CRYPT_MACHINE_DEFAULT}
  418. CRYPT_USER_DEFAULT = $00000002;
  419. {$EXTERNALSYM CRYPT_USER_DEFAULT}
  420. CRYPT_DELETE_DEFAULT = $00000004;
  421. {$EXTERNALSYM CRYPT_DELETE_DEFAULT}
  422. // exported key blob definitions
  423. SIMPLEBLOB = $1;
  424. {$EXTERNALSYM SIMPLEBLOB}
  425. PUBLICKEYBLOB = $6;
  426. {$EXTERNALSYM PUBLICKEYBLOB}
  427. PRIVATEKEYBLOB = $7;
  428. {$EXTERNALSYM PRIVATEKEYBLOB}
  429. PLAINTEXTKEYBLOB = $8;
  430. {$EXTERNALSYM PLAINTEXTKEYBLOB}
  431. OPAQUEKEYBLOB = $9;
  432. {$EXTERNALSYM OPAQUEKEYBLOB}
  433. PUBLICKEYBLOBEX = $A;
  434. {$EXTERNALSYM PUBLICKEYBLOBEX}
  435. SYMMETRICWRAPKEYBLOB = $B;
  436. {$EXTERNALSYM SYMMETRICWRAPKEYBLOB}
  437. AT_KEYEXCHANGE = 1;
  438. {$EXTERNALSYM AT_KEYEXCHANGE}
  439. AT_SIGNATURE = 2;
  440. {$EXTERNALSYM AT_SIGNATURE}
  441. CRYPT_USERDATA = 1;
  442. {$EXTERNALSYM CRYPT_USERDATA}
  443. // dwParam
  444. KP_IV = 1; // Initialization vector
  445. {$EXTERNALSYM KP_IV}
  446. KP_SALT = 2; // Salt value
  447. {$EXTERNALSYM KP_SALT}
  448. KP_PADDING = 3; // Padding values
  449. {$EXTERNALSYM KP_PADDING}
  450. KP_MODE = 4; // Mode of the cipher
  451. {$EXTERNALSYM KP_MODE}
  452. KP_MODE_BITS = 5; // Number of bits to feedback
  453. {$EXTERNALSYM KP_MODE_BITS}
  454. KP_PERMISSIONS = 6; // Key permissions DWORD
  455. {$EXTERNALSYM KP_PERMISSIONS}
  456. KP_ALGID = 7; // Key algorithm
  457. {$EXTERNALSYM KP_ALGID}
  458. KP_BLOCKLEN = 8; // Block size of the cipher
  459. {$EXTERNALSYM KP_BLOCKLEN}
  460. KP_KEYLEN = 9; // Length of key in bits
  461. {$EXTERNALSYM KP_KEYLEN}
  462. KP_SALT_EX = 10; // Length of salt in bytes
  463. {$EXTERNALSYM KP_SALT_EX}
  464. KP_P = 11; // DSS/Diffie-Hellman P value
  465. {$EXTERNALSYM KP_P}
  466. KP_G = 12; // DSS/Diffie-Hellman G value
  467. {$EXTERNALSYM KP_G}
  468. KP_Q = 13; // DSS Q value
  469. {$EXTERNALSYM KP_Q}
  470. KP_X = 14; // Diffie-Hellman X value
  471. {$EXTERNALSYM KP_X}
  472. KP_Y = 15; // Y value
  473. {$EXTERNALSYM KP_Y}
  474. KP_RA = 16; // Fortezza RA value
  475. {$EXTERNALSYM KP_RA}
  476. KP_RB = 17; // Fortezza RB value
  477. {$EXTERNALSYM KP_RB}
  478. KP_INFO = 18; // for putting information into an RSA envelope
  479. {$EXTERNALSYM KP_INFO}
  480. KP_EFFECTIVE_KEYLEN = 19; // setting and getting RC2 effective key length
  481. {$EXTERNALSYM KP_EFFECTIVE_KEYLEN}
  482. KP_SCHANNEL_ALG = 20; // for setting the Secure Channel algorithms
  483. {$EXTERNALSYM KP_SCHANNEL_ALG}
  484. KP_CLIENT_RANDOM = 21; // for setting the Secure Channel client random data
  485. {$EXTERNALSYM KP_CLIENT_RANDOM}
  486. KP_SERVER_RANDOM = 22; // for setting the Secure Channel server random data
  487. {$EXTERNALSYM KP_SERVER_RANDOM}
  488. KP_RP = 23;
  489. {$EXTERNALSYM KP_RP}
  490. KP_PRECOMP_MD5 = 24;
  491. {$EXTERNALSYM KP_PRECOMP_MD5}
  492. KP_PRECOMP_SHA = 25;
  493. {$EXTERNALSYM KP_PRECOMP_SHA}
  494. KP_CERTIFICATE = 26; // for setting Secure Channel certificate data (PCT1)
  495. {$EXTERNALSYM KP_CERTIFICATE}
  496. KP_CLEAR_KEY = 27; // for setting Secure Channel clear key data (PCT1)
  497. {$EXTERNALSYM KP_CLEAR_KEY}
  498. KP_PUB_EX_LEN = 28;
  499. {$EXTERNALSYM KP_PUB_EX_LEN}
  500. KP_PUB_EX_VAL = 29;
  501. {$EXTERNALSYM KP_PUB_EX_VAL}
  502. KP_KEYVAL = 30;
  503. {$EXTERNALSYM KP_KEYVAL}
  504. KP_ADMIN_PIN = 31;
  505. {$EXTERNALSYM KP_ADMIN_PIN}
  506. KP_KEYEXCHANGE_PIN = 32;
  507. {$EXTERNALSYM KP_KEYEXCHANGE_PIN}
  508. KP_SIGNATURE_PIN = 33;
  509. {$EXTERNALSYM KP_SIGNATURE_PIN}
  510. KP_PREHASH = 34;
  511. {$EXTERNALSYM KP_PREHASH}
  512. KP_OAEP_PARAMS = 36; // for setting OAEP params on RSA keys
  513. {$EXTERNALSYM KP_OAEP_PARAMS}
  514. KP_CMS_KEY_INFO = 37;
  515. {$EXTERNALSYM KP_CMS_KEY_INFO}
  516. KP_CMS_DH_KEY_INFO = 38;
  517. {$EXTERNALSYM KP_CMS_DH_KEY_INFO}
  518. KP_PUB_PARAMS = 39; // for setting public parameters
  519. {$EXTERNALSYM KP_PUB_PARAMS}
  520. KP_VERIFY_PARAMS = 40; // for verifying DSA and DH parameters
  521. {$EXTERNALSYM KP_VERIFY_PARAMS}
  522. KP_HIGHEST_VERSION = 41; // for TLS protocol version setting
  523. {$EXTERNALSYM KP_HIGHEST_VERSION}
  524. // KP_PADDING
  525. PKCS5_PADDING = 1; // PKCS 5 (sec 6.2) padding method
  526. {$EXTERNALSYM PKCS5_PADDING}
  527. RANDOM_PADDING = 2;
  528. {$EXTERNALSYM RANDOM_PADDING}
  529. ZERO_PADDING = 3;
  530. {$EXTERNALSYM ZERO_PADDING}
  531. // KP_MODE
  532. CRYPT_MODE_CBC = 1; // Cipher block chaining
  533. {$EXTERNALSYM CRYPT_MODE_CBC}
  534. CRYPT_MODE_ECB = 2; // Electronic code book
  535. {$EXTERNALSYM CRYPT_MODE_ECB}
  536. CRYPT_MODE_OFB = 3; // Output feedback mode
  537. {$EXTERNALSYM CRYPT_MODE_OFB}
  538. CRYPT_MODE_CFB = 4; // Cipher feedback mode
  539. {$EXTERNALSYM CRYPT_MODE_CFB}
  540. CRYPT_MODE_CTS = 5; // Ciphertext stealing mode
  541. {$EXTERNALSYM CRYPT_MODE_CTS}
  542. // KP_PERMISSIONS
  543. CRYPT_ENCRYPT = $0001; // Allow encryption
  544. {$EXTERNALSYM CRYPT_ENCRYPT}
  545. CRYPT_DECRYPT = $0002; // Allow decryption
  546. {$EXTERNALSYM CRYPT_DECRYPT}
  547. CRYPT_EXPORT = $0004; // Allow key to be exported
  548. {$EXTERNALSYM CRYPT_EXPORT}
  549. CRYPT_READ = $0008; // Allow parameters to be read
  550. {$EXTERNALSYM CRYPT_READ}
  551. CRYPT_WRITE = $0010; // Allow parameters to be set
  552. {$EXTERNALSYM CRYPT_WRITE}
  553. CRYPT_MAC = $0020; // Allow MACs to be used with key
  554. {$EXTERNALSYM CRYPT_MAC}
  555. CRYPT_EXPORT_KEY = $0040; // Allow key to be used for exporting keys
  556. {$EXTERNALSYM CRYPT_EXPORT_KEY}
  557. CRYPT_IMPORT_KEY = $0080; // Allow key to be used for importing keys
  558. {$EXTERNALSYM CRYPT_IMPORT_KEY}
  559. HP_ALGID = $0001; // Hash algorithm
  560. {$EXTERNALSYM HP_ALGID}
  561. HP_HASHVAL = $0002; // Hash value
  562. {$EXTERNALSYM HP_HASHVAL}
  563. HP_HASHSIZE = $0004; // Hash value size
  564. {$EXTERNALSYM HP_HASHSIZE}
  565. HP_HMAC_INFO = $0005; // information for creating an HMAC
  566. {$EXTERNALSYM HP_HMAC_INFO}
  567. HP_TLS1PRF_LABEL = $0006; // label for TLS1 PRF
  568. {$EXTERNALSYM HP_TLS1PRF_LABEL}
  569. HP_TLS1PRF_SEED = $0007; // seed for TLS1 PRF
  570. {$EXTERNALSYM HP_TLS1PRF_SEED}
  571. CRYPT_FAILED = FALSE;
  572. {$EXTERNALSYM CRYPT_FAILED}
  573. CRYPT_SUCCEED = TRUE;
  574. {$EXTERNALSYM CRYPT_SUCCEED}
  575. function RCRYPT_SUCCEEDED(rt: BOOL): BOOL;
  576. {$EXTERNALSYM RCRYPT_SUCCEEDED}
  577. function RCRYPT_FAILED(rt: BOOL): BOOL;
  578. {$EXTERNALSYM RCRYPT_FAILED}
  579. //
  580. // CryptGetProvParam
  581. //
  582. const
  583. PP_ENUMALGS = 1;
  584. {$EXTERNALSYM PP_ENUMALGS}
  585. PP_ENUMCONTAINERS = 2;
  586. {$EXTERNALSYM PP_ENUMCONTAINERS}
  587. PP_IMPTYPE = 3;
  588. {$EXTERNALSYM PP_IMPTYPE}
  589. PP_NAME = 4;
  590. {$EXTERNALSYM PP_NAME}
  591. PP_VERSION = 5;
  592. {$EXTERNALSYM PP_VERSION}
  593. PP_CONTAINER = 6;
  594. {$EXTERNALSYM PP_CONTAINER}
  595. PP_CHANGE_PASSWORD = 7;
  596. {$EXTERNALSYM PP_CHANGE_PASSWORD}
  597. PP_KEYSET_SEC_DESCR = 8; // get/set security descriptor of keyset
  598. {$EXTERNALSYM PP_KEYSET_SEC_DESCR}
  599. PP_CERTCHAIN = 9; // for retrieving certificates from tokens
  600. {$EXTERNALSYM PP_CERTCHAIN}
  601. PP_KEY_TYPE_SUBTYPE = 10;
  602. {$EXTERNALSYM PP_KEY_TYPE_SUBTYPE}
  603. PP_PROVTYPE = 16;
  604. {$EXTERNALSYM PP_PROVTYPE}
  605. PP_KEYSTORAGE = 17;
  606. {$EXTERNALSYM PP_KEYSTORAGE}
  607. PP_APPLI_CERT = 18;
  608. {$EXTERNALSYM PP_APPLI_CERT}
  609. PP_SYM_KEYSIZE = 19;
  610. {$EXTERNALSYM PP_SYM_KEYSIZE}
  611. PP_SESSION_KEYSIZE = 20;
  612. {$EXTERNALSYM PP_SESSION_KEYSIZE}
  613. PP_UI_PROMPT = 21;
  614. {$EXTERNALSYM PP_UI_PROMPT}
  615. PP_ENUMALGS_EX = 22;
  616. {$EXTERNALSYM PP_ENUMALGS_EX}
  617. PP_ENUMMANDROOTS = 25;
  618. {$EXTERNALSYM PP_ENUMMANDROOTS}
  619. PP_ENUMELECTROOTS = 26;
  620. {$EXTERNALSYM PP_ENUMELECTROOTS}
  621. PP_KEYSET_TYPE = 27;
  622. {$EXTERNALSYM PP_KEYSET_TYPE}
  623. PP_ADMIN_PIN = 31;
  624. {$EXTERNALSYM PP_ADMIN_PIN}
  625. PP_KEYEXCHANGE_PIN = 32;
  626. {$EXTERNALSYM PP_KEYEXCHANGE_PIN}
  627. PP_SIGNATURE_PIN = 33;
  628. {$EXTERNALSYM PP_SIGNATURE_PIN}
  629. PP_SIG_KEYSIZE_INC = 34;
  630. {$EXTERNALSYM PP_SIG_KEYSIZE_INC}
  631. PP_KEYX_KEYSIZE_INC = 35;
  632. {$EXTERNALSYM PP_KEYX_KEYSIZE_INC}
  633. PP_UNIQUE_CONTAINER = 36;
  634. {$EXTERNALSYM PP_UNIQUE_CONTAINER}
  635. PP_SGC_INFO = 37;
  636. {$EXTERNALSYM PP_SGC_INFO}
  637. PP_USE_HARDWARE_RNG = 38;
  638. {$EXTERNALSYM PP_USE_HARDWARE_RNG}
  639. PP_KEYSPEC = 39;
  640. {$EXTERNALSYM PP_KEYSPEC}
  641. PP_ENUMEX_SIGNING_PROT = 40;
  642. {$EXTERNALSYM PP_ENUMEX_SIGNING_PROT}
  643. CRYPT_FIRST = 1;
  644. {$EXTERNALSYM CRYPT_FIRST}
  645. CRYPT_NEXT = 2;
  646. {$EXTERNALSYM CRYPT_NEXT}
  647. CRYPT_SGC_ENUM = 4;
  648. {$EXTERNALSYM CRYPT_SGC_ENUM}
  649. CRYPT_IMPL_HARDWARE = 1;
  650. {$EXTERNALSYM CRYPT_IMPL_HARDWARE}
  651. CRYPT_IMPL_SOFTWARE = 2;
  652. {$EXTERNALSYM CRYPT_IMPL_SOFTWARE}
  653. CRYPT_IMPL_MIXED = 3;
  654. {$EXTERNALSYM CRYPT_IMPL_MIXED}
  655. CRYPT_IMPL_UNKNOWN = 4;
  656. {$EXTERNALSYM CRYPT_IMPL_UNKNOWN}
  657. CRYPT_IMPL_REMOVABLE = 8;
  658. {$EXTERNALSYM CRYPT_IMPL_REMOVABLE}
  659. // key storage flags
  660. CRYPT_SEC_DESCR = $00000001;
  661. {$EXTERNALSYM CRYPT_SEC_DESCR}
  662. CRYPT_PSTORE = $00000002;
  663. {$EXTERNALSYM CRYPT_PSTORE}
  664. CRYPT_UI_PROMPT = $00000004;
  665. {$EXTERNALSYM CRYPT_UI_PROMPT}
  666. // protocol flags
  667. CRYPT_FLAG_PCT1 = $0001;
  668. {$EXTERNALSYM CRYPT_FLAG_PCT1}
  669. CRYPT_FLAG_SSL2 = $0002;
  670. {$EXTERNALSYM CRYPT_FLAG_SSL2}
  671. CRYPT_FLAG_SSL3 = $0004;
  672. {$EXTERNALSYM CRYPT_FLAG_SSL3}
  673. CRYPT_FLAG_TLS1 = $0008;
  674. {$EXTERNALSYM CRYPT_FLAG_TLS1}
  675. CRYPT_FLAG_IPSEC = $0010;
  676. {$EXTERNALSYM CRYPT_FLAG_IPSEC}
  677. CRYPT_FLAG_SIGNING = $0020;
  678. {$EXTERNALSYM CRYPT_FLAG_SIGNING}
  679. // SGC flags
  680. CRYPT_SGC = $0001;
  681. {$EXTERNALSYM CRYPT_SGC}
  682. CRYPT_FASTSGC = $0002;
  683. {$EXTERNALSYM CRYPT_FASTSGC}
  684. //
  685. // CryptSetProvParam
  686. //
  687. PP_CLIENT_HWND = 1;
  688. {$EXTERNALSYM PP_CLIENT_HWND}
  689. PP_CONTEXT_INFO = 11;
  690. {$EXTERNALSYM PP_CONTEXT_INFO}
  691. PP_KEYEXCHANGE_KEYSIZE = 12;
  692. {$EXTERNALSYM PP_KEYEXCHANGE_KEYSIZE}
  693. PP_SIGNATURE_KEYSIZE = 13;
  694. {$EXTERNALSYM PP_SIGNATURE_KEYSIZE}
  695. PP_KEYEXCHANGE_ALG = 14;
  696. {$EXTERNALSYM PP_KEYEXCHANGE_ALG}
  697. PP_SIGNATURE_ALG = 15;
  698. {$EXTERNALSYM PP_SIGNATURE_ALG}
  699. PP_DELETEKEY = 24;
  700. {$EXTERNALSYM PP_DELETEKEY}
  701. PROV_RSA_FULL = 1;
  702. {$EXTERNALSYM PROV_RSA_FULL}
  703. PROV_RSA_SIG = 2;
  704. {$EXTERNALSYM PROV_RSA_SIG}
  705. PROV_DSS = 3;
  706. {$EXTERNALSYM PROV_DSS}
  707. PROV_FORTEZZA = 4;
  708. {$EXTERNALSYM PROV_FORTEZZA}
  709. PROV_MS_EXCHANGE = 5;
  710. {$EXTERNALSYM PROV_MS_EXCHANGE}
  711. PROV_SSL = 6;
  712. {$EXTERNALSYM PROV_SSL}
  713. PROV_RSA_SCHANNEL = 12;
  714. {$EXTERNALSYM PROV_RSA_SCHANNEL}
  715. PROV_DSS_DH = 13;
  716. {$EXTERNALSYM PROV_DSS_DH}
  717. PROV_EC_ECDSA_SIG = 14;
  718. {$EXTERNALSYM PROV_EC_ECDSA_SIG}
  719. PROV_EC_ECNRA_SIG = 15;
  720. {$EXTERNALSYM PROV_EC_ECNRA_SIG}
  721. PROV_EC_ECDSA_FULL = 16;
  722. {$EXTERNALSYM PROV_EC_ECDSA_FULL}
  723. PROV_EC_ECNRA_FULL = 17;
  724. {$EXTERNALSYM PROV_EC_ECNRA_FULL}
  725. PROV_DH_SCHANNEL = 18;
  726. {$EXTERNALSYM PROV_DH_SCHANNEL}
  727. PROV_SPYRUS_LYNKS = 20;
  728. {$EXTERNALSYM PROV_SPYRUS_LYNKS}
  729. PROV_RNG = 21;
  730. {$EXTERNALSYM PROV_RNG}
  731. PROV_INTEL_SEC = 22;
  732. {$EXTERNALSYM PROV_INTEL_SEC}
  733. //
  734. // STT defined Providers
  735. //
  736. PROV_STT_MER = 7;
  737. {$EXTERNALSYM PROV_STT_MER}
  738. PROV_STT_ACQ = 8;
  739. {$EXTERNALSYM PROV_STT_ACQ}
  740. PROV_STT_BRND = 9;
  741. {$EXTERNALSYM PROV_STT_BRND}
  742. PROV_STT_ROOT = 10;
  743. {$EXTERNALSYM PROV_STT_ROOT}
  744. PROV_STT_ISS = 11;
  745. {$EXTERNALSYM PROV_STT_ISS}
  746. //
  747. // Provider friendly names
  748. //
  749. MS_DEF_PROV_A = 'Microsoft Base Cryptographic Provider v1.0';
  750. {$EXTERNALSYM MS_DEF_PROV_A}
  751. MS_DEF_PROV_W = 'Microsoft Base Cryptographic Provider v1.0';
  752. {$EXTERNALSYM MS_DEF_PROV_W}
  753. {$IFDEF UNICODE}
  754. MS_DEF_PROV = MS_DEF_PROV_W;
  755. {$EXTERNALSYM MS_DEF_PROV}
  756. {$ELSE}
  757. MS_DEF_PROV = MS_DEF_PROV_A;
  758. {$EXTERNALSYM MS_DEF_PROV}
  759. {$ENDIF UNICODE}
  760. MS_ENHANCED_PROV_A = 'Microsoft Enhanced Cryptographic Provider v1.0';
  761. {$EXTERNALSYM MS_ENHANCED_PROV_A}
  762. MS_ENHANCED_PROV_W = 'Microsoft Enhanced Cryptographic Provider v1.0';
  763. {$EXTERNALSYM MS_ENHANCED_PROV_W}
  764. {$IFDEF UNICODE}
  765. MS_ENHANCED_PROV = MS_ENHANCED_PROV_W;
  766. {$EXTERNALSYM MS_ENHANCED_PROV}
  767. {$ELSE}
  768. MS_ENHANCED_PROV = MS_ENHANCED_PROV_A;
  769. {$EXTERNALSYM MS_ENHANCED_PROV}
  770. {$ENDIF UNICODE}
  771. MS_STRONG_PROV_A = 'Microsoft Strong Cryptographic Provider';
  772. {$EXTERNALSYM MS_STRONG_PROV_A}
  773. MS_STRONG_PROV_W = 'Microsoft Strong Cryptographic Provider';
  774. {$EXTERNALSYM MS_STRONG_PROV_W}
  775. {$IFDEF UNICODE}
  776. MS_STRONG_PROV = MS_STRONG_PROV_W;
  777. {$EXTERNALSYM MS_STRONG_PROV}
  778. {$ELSE}
  779. MS_STRONG_PROV = MS_STRONG_PROV_A;
  780. {$EXTERNALSYM MS_STRONG_PROV}
  781. {$ENDIF UNICODE}
  782. MS_DEF_RSA_SIG_PROV_A = 'Microsoft RSA Signature Cryptographic Provider';
  783. {$EXTERNALSYM MS_DEF_RSA_SIG_PROV_A}
  784. MS_DEF_RSA_SIG_PROV_W = 'Microsoft RSA Signature Cryptographic Provider';
  785. {$EXTERNALSYM MS_DEF_RSA_SIG_PROV_W}
  786. {$IFDEF UNICODE}
  787. MS_DEF_RSA_SIG_PROV = MS_DEF_RSA_SIG_PROV_W;
  788. {$EXTERNALSYM MS_DEF_RSA_SIG_PROV}
  789. {$ELSE}
  790. MS_DEF_RSA_SIG_PROV = MS_DEF_RSA_SIG_PROV_A;
  791. {$EXTERNALSYM MS_DEF_RSA_SIG_PROV}
  792. {$ENDIF UNICODE}
  793. MS_DEF_RSA_SCHANNEL_PROV_A = 'Microsoft RSA SChannel Cryptographic Provider';
  794. {$EXTERNALSYM MS_DEF_RSA_SCHANNEL_PROV_A}
  795. MS_DEF_RSA_SCHANNEL_PROV_W = 'Microsoft RSA SChannel Cryptographic Provider';
  796. {$EXTERNALSYM MS_DEF_RSA_SCHANNEL_PROV_W}
  797. {$IFDEF UNICODE}
  798. MS_DEF_RSA_SCHANNEL_PROV = MS_DEF_RSA_SCHANNEL_PROV_W;
  799. {$EXTERNALSYM MS_DEF_RSA_SCHANNEL_PROV}
  800. {$ELSE}
  801. MS_DEF_RSA_SCHANNEL_PROV = MS_DEF_RSA_SCHANNEL_PROV_A;
  802. {$EXTERNALSYM MS_DEF_RSA_SCHANNEL_PROV}
  803. {$ENDIF UNICODE}
  804. MS_DEF_DSS_PROV_A = 'Microsoft Base DSS Cryptographic Provider';
  805. {$EXTERNALSYM MS_DEF_DSS_PROV_A}
  806. MS_DEF_DSS_PROV_W = 'Microsoft Base DSS Cryptographic Provider';
  807. {$EXTERNALSYM MS_DEF_DSS_PROV_W}
  808. {$IFDEF UNICODE}
  809. MS_DEF_DSS_PROV = MS_DEF_DSS_PROV_W;
  810. {$EXTERNALSYM MS_DEF_DSS_PROV}
  811. {$ELSE}
  812. MS_DEF_DSS_PROV = MS_DEF_DSS_PROV_A;
  813. {$EXTERNALSYM MS_DEF_DSS_PROV}
  814. {$ENDIF UNICODE}
  815. MS_DEF_DSS_DH_PROV_A = 'Microsoft Base DSS and Diffie-Hellman Cryptographic Provider';
  816. {$EXTERNALSYM MS_DEF_DSS_DH_PROV_A}
  817. MS_DEF_DSS_DH_PROV_W = 'Microsoft Base DSS and Diffie-Hellman Cryptographic Provider';
  818. {$EXTERNALSYM MS_DEF_DSS_DH_PROV_W}
  819. {$IFDEF UNICODE}
  820. MS_DEF_DSS_DH_PROV = MS_DEF_DSS_DH_PROV_W;
  821. {$EXTERNALSYM MS_DEF_DSS_DH_PROV}
  822. {$ELSE}
  823. MS_DEF_DSS_DH_PROV = MS_DEF_DSS_DH_PROV_A;
  824. {$EXTERNALSYM MS_DEF_DSS_DH_PROV}
  825. {$ENDIF UNICODE}
  826. MS_ENH_DSS_DH_PROV_A = 'Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider';
  827. {$EXTERNALSYM MS_ENH_DSS_DH_PROV_A}
  828. MS_ENH_DSS_DH_PROV_W = 'Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider';
  829. {$EXTERNALSYM MS_ENH_DSS_DH_PROV_W}
  830. {$IFDEF UNICODE}
  831. MS_ENH_DSS_DH_PROV = MS_ENH_DSS_DH_PROV_W;
  832. {$EXTERNALSYM MS_ENH_DSS_DH_PROV}
  833. {$ELSE}
  834. MS_ENH_DSS_DH_PROV = MS_ENH_DSS_DH_PROV_A;
  835. {$EXTERNALSYM MS_ENH_DSS_DH_PROV}
  836. {$ENDIF UNICODE}
  837. MS_DEF_DH_SCHANNEL_PROV_A = 'Microsoft DH SChannel Cryptographic Provider';
  838. {$EXTERNALSYM MS_DEF_DH_SCHANNEL_PROV_A}
  839. MS_DEF_DH_SCHANNEL_PROV_W = 'Microsoft DH SChannel Cryptographic Provider';
  840. {$EXTERNALSYM MS_DEF_DH_SCHANNEL_PROV_W}
  841. {$IFDEF UNICODE}
  842. MS_DEF_DH_SCHANNEL_PROV = MS_DEF_DH_SCHANNEL_PROV_W;
  843. {$EXTERNALSYM MS_DEF_DH_SCHANNEL_PROV}
  844. {$ELSE}
  845. MS_DEF_DH_SCHANNEL_PROV = MS_DEF_DH_SCHANNEL_PROV_A;
  846. {$EXTERNALSYM MS_DEF_DH_SCHANNEL_PROV}
  847. {$ENDIF UNICODE}
  848. MS_SCARD_PROV_A = 'Microsoft Base Smart Card Crypto Provider';
  849. {$EXTERNALSYM MS_SCARD_PROV_A}
  850. MS_SCARD_PROV_W = 'Microsoft Base Smart Card Crypto Provider';
  851. {$EXTERNALSYM MS_SCARD_PROV_W}
  852. {$IFDEF UNICODE}
  853. MS_SCARD_PROV = MS_SCARD_PROV_W;
  854. {$EXTERNALSYM MS_SCARD_PROV}
  855. {$ELSE}
  856. MS_SCARD_PROV = MS_SCARD_PROV_A;
  857. {$EXTERNALSYM MS_SCARD_PROV}
  858. {$ENDIF UNICODE}
  859. MAXUIDLEN = 64;
  860. {$EXTERNALSYM MAXUIDLEN}
  861. // Exponentiation Offload Reg Location
  862. EXPO_OFFLOAD_REG_VALUE = 'ExpoOffload';
  863. {$EXTERNALSYM EXPO_OFFLOAD_REG_VALUE}
  864. EXPO_OFFLOAD_FUNC_NAME = 'OffloadModExpo';
  865. {$EXTERNALSYM EXPO_OFFLOAD_FUNC_NAME}
  866. CUR_BLOB_VERSION = 2;
  867. {$EXTERNALSYM CUR_BLOB_VERSION}
  868. // structure for use with CryptSetKeyParam for CMS keys
  869. // DO NOT USE THIS STRUCTURE!!!!!
  870. type
  871. PCMS_KEY_INFO = ^CMS_KEY_INFO;
  872. {$EXTERNALSYM PCMS_KEY_INFO}
  873. _CMS_KEY_INFO = record
  874. dwVersion: DWORD; // sizeof(CMS_KEY_INFO)
  875. Algid: ALG_ID; // algorithmm id for the key to be converted
  876. pbOID: LPBYTE; // pointer to OID to hash in with Z
  877. cbOID: DWORD; // length of OID to hash in with Z
  878. end;
  879. {$EXTERNALSYM _CMS_KEY_INFO}
  880. CMS_KEY_INFO = _CMS_KEY_INFO;
  881. {$EXTERNALSYM CMS_KEY_INFO}
  882. TCmsKeyInfo = CMS_KEY_INFO;
  883. PCmsKeyInfo = PCMS_KEY_INFO;
  884. // structure for use with CryptSetHashParam with CALG_HMAC
  885. PHMAC_Info = ^HMAC_Info;
  886. {$EXTERNALSYM PHMAC_Info}
  887. _HMAC_Info = record
  888. HashAlgid: ALG_ID;
  889. pbInnerString: LPBYTE;
  890. cbInnerString: DWORD;
  891. pbOuterString: LPBYTE;
  892. cbOuterString: DWORD;
  893. end;
  894. {$EXTERNALSYM _HMAC_Info}
  895. HMAC_Info = _HMAC_Info;
  896. {$EXTERNALSYM HMAC_Info}
  897. THMacInfo = HMAC_Info;
  898. PHMacInfo = PHMAC_Info;
  899. // structure for use with CryptSetKeyParam with KP_SCHANNEL_ALG
  900. PSCHANNEL_ALG = ^SCHANNEL_ALG;
  901. {$EXTERNALSYM PSCHANNEL_ALG}
  902. _SCHANNEL_ALG = record
  903. dwUse: DWORD;
  904. Algid: ALG_ID;
  905. cBits: DWORD;
  906. dwFlags: DWORD;
  907. dwReserved: DWORD;
  908. end;
  909. {$EXTERNALSYM _SCHANNEL_ALG}
  910. SCHANNEL_ALG = _SCHANNEL_ALG;
  911. {$EXTERNALSYM SCHANNEL_ALG}
  912. TSChannelAlg = SCHANNEL_ALG;
  913. PSChannelAlg = PSCHANNEL_ALG;
  914. // uses of algortihms for SCHANNEL_ALG structure
  915. const
  916. SCHANNEL_MAC_KEY = $00000000;
  917. {$EXTERNALSYM SCHANNEL_MAC_KEY}
  918. SCHANNEL_ENC_KEY = $00000001;
  919. {$EXTERNALSYM SCHANNEL_ENC_KEY}
  920. // uses of dwFlags SCHANNEL_ALG structure
  921. INTERNATIONAL_USAGE = $00000001;
  922. {$EXTERNALSYM INTERNATIONAL_USAGE}
  923. type
  924. PPROV_ENUMALGS = ^PROV_ENUMALGS;
  925. {$NODEFINE PPROV_ENUMALGS}
  926. _PROV_ENUMALGS = record
  927. aiAlgid: ALG_ID;
  928. dwBitLen: DWORD;
  929. dwNameLen: DWORD;
  930. szName: array [0..19] of CHAR;
  931. end;
  932. {$EXTERNALSYM _PROV_ENUMALGS}
  933. PROV_ENUMALGS = _PROV_ENUMALGS;
  934. {$EXTERNALSYM PROV_ENUMALGS}
  935. TProvEnumAlgs = PROV_ENUMALGS;
  936. PProvEnumAlgs = PPROV_ENUMALGS;
  937. PPROV_ENUMALGS_EX = ^PROV_ENUMALGS_EX;
  938. {$NODEFINE PPROV_ENUMALGS_EX}
  939. _PROV_ENUMALGS_EX = record
  940. aiAlgid: ALG_ID;
  941. dwDefaultLen: DWORD;
  942. dwMinLen: DWORD;
  943. dwMaxLen: DWORD;
  944. dwProtocols: DWORD;
  945. dwNameLen: DWORD;
  946. szName: array [0..19] of CHAR;
  947. dwLongNameLen: DWORD;
  948. szLongName: array [0..39] of CHAR;
  949. end;
  950. {$EXTERNALSYM _PROV_ENUMALGS_EX}
  951. PROV_ENUMALGS_EX = _PROV_ENUMALGS_EX;
  952. {$EXTERNALSYM PROV_ENUMALGS_EX}
  953. TProvEnumAlgsEx = PROV_ENUMALGS_EX;
  954. PProvEnumAlgsEx = PPROV_ENUMALGS_EX;
  955. PPUBLICKEYSTRUC = ^PUBLICKEYSTRUC;
  956. {$NODEFINE PPUBLICKEYSTRUC}
  957. _PUBLICKEYSTRUC = record
  958. bType: BYTE;
  959. bVersion: BYTE;
  960. reserved: WORD;
  961. aiKeyAlg: ALG_ID;
  962. end;
  963. {$EXTERNALSYM _PUBLICKEYSTRUC}
  964. PUBLICKEYSTRUC = _PUBLICKEYSTRUC;
  965. {$EXTERNALSYM PUBLICKEYSTRUC}
  966. BLOBHEADER = _PUBLICKEYSTRUC;
  967. {$EXTERNALSYM BLOBHEADER}
  968. TPublicKeyStruc = PUBLICKEYSTRUC;
  969. PRSAPUBKEY = ^RSAPUBKEY;
  970. {$NODEFINE PRSAPUBKEY}
  971. _RSAPUBKEY = record
  972. magic: DWORD; // Has to be RSA1
  973. bitlen: DWORD; // # of bits in modulus
  974. pubexp: DWORD; // public exponent
  975. // Modulus data follows
  976. end;
  977. {$EXTERNALSYM _RSAPUBKEY}
  978. RSAPUBKEY = _RSAPUBKEY;
  979. {$EXTERNALSYM RSAPUBKEY}
  980. TRsaPubKey = RSAPUBKEY;
  981. _PUBKEY = record
  982. magic: DWORD;
  983. bitlen: DWORD; // # of bits in modulus
  984. end;
  985. {$EXTERNALSYM _PUBKEY}
  986. DHPUBKEY = _PUBKEY;
  987. {$EXTERNALSYM DHPUBKEY}
  988. DSSPUBKEY = _PUBKEY;
  989. {$EXTERNALSYM DSSPUBKEY}
  990. KEAPUBKEY = _PUBKEY;
  991. {$EXTERNALSYM KEAPUBKEY}
  992. TEKPUBKEY = _PUBKEY;
  993. {$EXTERNALSYM TEKPUBKEY}
  994. PDSSSEED = ^DSSSEED;
  995. {$NODEFINE PDSSSEED}
  996. _DSSSEED = record
  997. counter: DWORD;
  998. seed: array [0..19] of BYTE;
  999. end;
  1000. {$EXTERNALSYM _DSSSEED}
  1001. DSSSEED = _DSSSEED;
  1002. {$EXTERNALSYM DSSSEED}
  1003. TDssSeed = DSSSEED;
  1004. PPUBKEYVER3 = ^PUBKEYVER3;
  1005. {$NODEFINE PPUBKEYVER3}
  1006. _PUBKEYVER3 = record
  1007. magic: DWORD;
  1008. bitlenP: DWORD; // # of bits in prime modulus
  1009. bitlenQ: DWORD; // # of bits in prime q, 0 if not available
  1010. bitlenJ: DWORD; // # of bits in (p-1)/q, 0 if not available
  1011. DSSSeed: DSSSEED;
  1012. end;
  1013. {$EXTERNALSYM _PUBKEYVER3}
  1014. PUBKEYVER3 = _PUBKEYVER3;
  1015. {$EXTERNALSYM PUBKEYVER3}
  1016. DHPUBKEY_VER3 = PUBKEYVER3;
  1017. {$EXTERNALSYM DHPUBKEY_VER3}
  1018. TPubKeyVer3 = PUBKEYVER3;
  1019. PPRIVKEYVER3 = ^DHPRIVKEY_VER3;
  1020. {$NODEFINE PPRIVKEYVER3}
  1021. _PRIVKEYVER3 = record
  1022. magic: DWORD;
  1023. bitlenP: DWORD; // # of bits in prime modulus
  1024. bitlenQ: DWORD; // # of bits in prime q, 0 if not available
  1025. bitlenJ: DWORD; // # of bits in (p-1)/q, 0 if not available
  1026. bitlenX: DWORD; // # of bits in X
  1027. DSSSeed: DSSSEED;
  1028. end;
  1029. {$EXTERNALSYM _PRIVKEYVER3}
  1030. DHPRIVKEY_VER3 = _PRIVKEYVER3;
  1031. {$EXTERNALSYM DHPRIVKEY_VER3}
  1032. DSSPRIVKEY_VER3 = _PRIVKEYVER3;
  1033. {$EXTERNALSYM DSSPRIVKEY_VER3}
  1034. TDssPrivKey3 = DHPRIVKEY_VER3;
  1035. PKEY_TYPE_SUBTYPE = ^KEY_TYPE_SUBTYPE;
  1036. {$EXTERNALSYM PKEY_TYPE_SUBTYPE}
  1037. _KEY_TYPE_SUBTYPE = record
  1038. dwKeySpec: DWORD;
  1039. Type_: GUID;
  1040. Subtype: GUID;
  1041. end;
  1042. {$EXTERNALSYM _KEY_TYPE_SUBTYPE}
  1043. KEY_TYPE_SUBTYPE = _KEY_TYPE_SUBTYPE;
  1044. {$EXTERNALSYM KEY_TYPE_SUBTYPE}
  1045. TKeyTypeSubType = KEY_TYPE_SUBTYPE;
  1046. PKeyTypeSubType = PKEY_TYPE_SUBTYPE;
  1047. PCERT_FORTEZZA_DATA_PROP = ^CERT_FORTEZZA_DATA_PROP;
  1048. {$NODEFINE PCERT_FORTEZZA_DATA_PROP}
  1049. _CERT_FORTEZZA_DATA_PROP = record
  1050. SerialNumber: array [0..7] of Byte;
  1051. CertIndex: Integer;
  1052. CertLabel: array [0..35] of Byte;
  1053. end;
  1054. {$EXTERNALSYM _CERT_FORTEZZA_DATA_PROP}
  1055. CERT_FORTEZZA_DATA_PROP = _CERT_FORTEZZA_DATA_PROP;
  1056. {$EXTERNALSYM CERT_FORTEZZA_DATA_PROP}
  1057. TCertFortezzaDataProp = CERT_FORTEZZA_DATA_PROP;
  1058. PCertFortezzaDataProp = PCERT_FORTEZZA_DATA_PROP;
  1059. //+-------------------------------------------------------------------------
  1060. // CRYPTOAPI BLOB definitions
  1061. //--------------------------------------------------------------------------
  1062. type
  1063. _CRYPTOAPI_BLOB = record
  1064. cbData: DWORD;
  1065. pbData: LPBYTE;
  1066. end;
  1067. {$EXTERNALSYM _CRYPTOAPI_BLOB}
  1068. CRYPT_INTEGER_BLOB = _CRYPTOAPI_BLOB;
  1069. TCryptIntegerBlob = CRYPT_INTEGER_BLOB;
  1070. {$EXTERNALSYM CRYPT_INTEGER_BLOB}
  1071. PCRYPT_INTEGER_BLOB = ^_CRYPTOAPI_BLOB;
  1072. {$EXTERNALSYM PCRYPT_INTEGER_BLOB}
  1073. PCryptIntegerBlob = PCRYPT_INTEGER_BLOB;
  1074. CRYPT_UINT_BLOB = _CRYPTOAPI_BLOB;
  1075. {$EXTERNALSYM CRYPT_UINT_BLOB}
  1076. TCryptUintBlob = CRYPT_UINT_BLOB;
  1077. PCRYPT_UINT_BLOB = ^_CRYPTOAPI_BLOB;
  1078. {$EXTERNALSYM PCRYPT_UINT_BLOB}
  1079. PCryptUintBlob = PCRYPT_UINT_BLOB;
  1080. CRYPT_OBJID_BLOB = _CRYPTOAPI_BLOB;
  1081. {$EXTERNALSYM CRYPT_OBJID_BLOB}
  1082. TCryptObjIdBlob = CRYPT_OBJID_BLOB;
  1083. PCRYPT_OBJID_BLOB = ^_CRYPTOAPI_BLOB;
  1084. {$EXTERNALSYM PCRYPT_OBJID_BLOB}
  1085. PCryptObjIdBlob = PCRYPT_OBJID_BLOB;
  1086. CERT_NAME_BLOB = _CRYPTOAPI_BLOB;
  1087. {$EXTERNALSYM CERT_NAME_BLOB}
  1088. TCertNameBlob = CERT_NAME_BLOB;
  1089. PCERT_NAME_BLOB = ^_CRYPTOAPI_BLOB;
  1090. {$EXTERNALSYM PCERT_NAME_BLOB}
  1091. PCertNameBlob = PCERT_NAME_BLOB;
  1092. CERT_RDN_VALUE_BLOB = _CRYPTOAPI_BLOB;
  1093. {$EXTERNALSYM CERT_RDN_VALUE_BLOB}
  1094. TCertRdnValueBlob = CERT_RDN_VALUE_BLOB;
  1095. PCERT_RDN_VALUE_BLOB = ^_CRYPTOAPI_BLOB;
  1096. {$EXTERNALSYM PCERT_RDN_VALUE_BLOB}
  1097. PCertRdnValueBlob = PCERT_RDN_VALUE_BLOB;
  1098. CERT_BLOB = _CRYPTOAPI_BLOB;
  1099. {$EXTERNALSYM CERT_BLOB}
  1100. TCertBlob = CERT_BLOB;
  1101. PCERT_BLOB = ^_CRYPTOAPI_BLOB;
  1102. {$EXTERNALSYM PCERT_BLOB}
  1103. PCertBlob = PCERT_BLOB;
  1104. CRL_BLOB = _CRYPTOAPI_BLOB;
  1105. {$EXTERNALSYM CRL_BLOB}
  1106. TCrlBlob = CRL_BLOB;
  1107. PCRL_BLOB = ^_CRYPTOAPI_BLOB;
  1108. {$EXTERNALSYM PCRL_BLOB}
  1109. PCrlBlob = PCRL_BLOB;
  1110. DATA_BLOB = _CRYPTOAPI_BLOB;
  1111. {$EXTERNALSYM DATA_BLOB}
  1112. TDataBlob = DATA_BLOB;
  1113. PDATA_BLOB = ^_CRYPTOAPI_BLOB;
  1114. {$EXTERNALSYM PDATA_BLOB}
  1115. PDataBlob = PDATA_BLOB;
  1116. CRYPT_DATA_BLOB = _CRYPTOAPI_BLOB;
  1117. {$EXTERNALSYM CRYPT_DATA_BLOB}
  1118. TCryptDataBlob = CRYPT_DATA_BLOB;
  1119. PCRYPT_DATA_BLOB = ^_CRYPTOAPI_BLOB;
  1120. {$EXTERNALSYM PCRYPT_DATA_BLOB}
  1121. PCryptDataBlob = PCRYPT_DATA_BLOB;
  1122. CRYPT_HASH_BLOB = _CRYPTOAPI_BLOB;
  1123. {$EXTERNALSYM CRYPT_HASH_BLOB}
  1124. TCryptHashBlob = CRYPT_HASH_BLOB;
  1125. PCRYPT_HASH_BLOB = ^_CRYPTOAPI_BLOB;
  1126. {$EXTERNALSYM PCRYPT_HASH_BLOB}
  1127. PCryptHashBlob = PCRYPT_HASH_BLOB;
  1128. CRYPT_DIGEST_BLOB = _CRYPTOAPI_BLOB;
  1129. {$EXTERNALSYM CRYPT_DIGEST_BLOB}
  1130. TCryptDigestBlob = CRYPT_DIGEST_BLOB;
  1131. PCRYPT_DIGEST_BLOB = ^_CRYPTOAPI_BLOB;
  1132. {$EXTERNALSYM PCRYPT_DIGEST_BLOB}
  1133. PCryptDigestBlob = PCRYPT_DIGEST_BLOB;
  1134. CRYPT_DER_BLOB = _CRYPTOAPI_BLOB;
  1135. {$EXTERNALSYM CRYPT_DER_BLOB}
  1136. TCyptDerBlob = CRYPT_DER_BLOB;
  1137. PCRYPT_DER_BLOB = ^_CRYPTOAPI_BLOB;
  1138. {$EXTERNALSYM PCRYPT_DER_BLOB}
  1139. PCyptDerBlob = PCRYPT_DER_BLOB;
  1140. CRYPT_ATTR_BLOB = _CRYPTOAPI_BLOB;
  1141. {$EXTERNALSYM CRYPT_ATTR_BLOB}
  1142. TCryptAttrBlob = CRYPT_ATTR_BLOB;
  1143. PCRYPT_ATTR_BLOB = ^_CRYPTOAPI_BLOB;
  1144. {$EXTERNALSYM PCRYPT_ATTR_BLOB}
  1145. PCryptAttrBlob = PCRYPT_ATTR_BLOB;
  1146. // structure for use with CryptSetKeyParam for CMS keys
  1147. PCMS_DH_KEY_INFO = ^CMS_DH_KEY_INFO;
  1148. {$EXTERNALSYM PCMS_DH_KEY_INFO}
  1149. _CMS_DH_KEY_INFO = record
  1150. dwVersion: DWORD; // sizeof(CMS_DH_KEY_INFO)
  1151. Algid: ALG_ID; // algorithmm id for the key to be converted
  1152. pszContentEncObjId: LPSTR; // pointer to OID to hash in with Z
  1153. PubInfo: CRYPT_DATA_BLOB; // OPTIONAL - public information
  1154. pReserved: Pointer; // reserved - should be NULL
  1155. end;
  1156. {$EXTERNALSYM _CMS_DH_KEY_INFO}
  1157. CMS_DH_KEY_INFO = _CMS_DH_KEY_INFO;
  1158. {$EXTERNALSYM CMS_DH_KEY_INFO}
  1159. TCmsDhKeyInfo = CMS_DH_KEY_INFO;
  1160. PCmsDhKeyInfo = PCMS_DH_KEY_INFO;
  1161. function CryptAcquireContextA(var phProv: HCRYPTPROV; pszContainer: LPCSTR;
  1162. pszProvider: LPCSTR; dwProvType: DWORD; dwFlags: DWORD): BOOL; stdcall;
  1163. {$EXTERNALSYM CryptAcquireContextA}
  1164. function CryptAcquireContextW(var phProv: HCRYPTPROV; pszContainer: LPCWSTR;
  1165. pszProvider: LPCWSTR; dwProvType: DWORD; dwFlags: DWORD): BOOL; stdcall;
  1166. {$EXTERNALSYM CryptAcquireContextW}
  1167. function CryptAcquireContext(var phProv: HCRYPTPROV; pszContainer: LPCTSTR;
  1168. pszProvider: LPCTSTR; dwProvType: DWORD; dwFlags: DWORD): BOOL; stdcall;
  1169. {$EXTERNALSYM CryptAcquireContext}
  1170. function CryptReleaseContext(hProv: HCRYPTPROV; dwFlags: ULONG_PTR): BOOL; stdcall;
  1171. {$EXTERNALSYM CryptReleaseContext}
  1172. function CryptGenKey(hProv: HCRYPTPROV; Algid: ALG_ID; dwFlags: DWORD;
  1173. var phKey: HCRYPTKEY): BOOL; stdcall;
  1174. {$EXTERNALSYM CryptGenKey}
  1175. function CryptDeriveKey(hProv: HCRYPTPROV; Algid: ALG_ID; hBaseData: HCRYPTHASH;
  1176. dwFlags: DWORD; var phKey: HCRYPTKEY): BOOL; stdcall;
  1177. {$EXTERNALSYM CryptDeriveKey}
  1178. function CryptDestroyKey(hKey: HCRYPTKEY): BOOL; stdcall;
  1179. {$EXTERNALSYM CryptDestroyKey}
  1180. function CryptSetKeyParam(hKey: HCRYPTKEY; dwParam: DWORD; pbData: LPBYTE;
  1181. dwFlags: DWORD): BOOL; stdcall;
  1182. {$EXTERNALSYM CryptSetKeyParam}
  1183. function CryptGetKeyParam(hKey: HCRYPTKEY; dwParam: DWORD; pbData: LPBYTE;
  1184. var pdwDataLen: DWORD; dwFlags: DWORD): BOOL; stdcall;
  1185. {$EXTERNALSYM CryptGetKeyParam}
  1186. function CryptSetHashParam(hHash: HCRYPTHASH; dwParam: DWORD; pbData: LPBYTE;
  1187. dwFlags: DWORD): BOOL; stdcall;
  1188. {$EXTERNALSYM CryptSetHashParam}
  1189. function CryptGetHashParam(hHash: HCRYPTHASH; dwParam: DWORD; pbData: LPBYTE;
  1190. var pdwDataLen: DWORD; dwFlags: DWORD): BOOL; stdcall;
  1191. {$EXTERNALSYM CryptGetHashParam}
  1192. function CryptSetProvParam(hProv: HCRYPTPROV; dwParam: DWORD; pbData: LPBYTE;
  1193. dwFlags: DWORD): BOOL; stdcall;
  1194. {$EXTERNALSYM CryptSetProvParam}
  1195. function CryptGetProvParam(hProv: HCRYPTPROV; dwParam: DWORD; pbData: LPBYTE;
  1196. var pdwDataLen: DWORD; dwFlags: DWORD): BOOL; stdcall;
  1197. {$EXTERNALSYM CryptGetProvParam}
  1198. function CryptGenRandom(hProv: HCRYPTPROV; dwLen: DWORD; pbBuffer: LPBYTE): BOOL; stdcall;
  1199. {$EXTERNALSYM CryptGenRandom}
  1200. function CryptGetUserKey(hProv: HCRYPTPROV; dwKeySpec: DWORD; var phUserKey: HCRYPTKEY): BOOL; stdcall;
  1201. {$EXTERNALSYM CryptGetUserKey}
  1202. function CryptExportKey(hKey, hExpKey: HCRYPTKEY; dwBlobType, dwFlags: DWORD;
  1203. pbData: LPBYTE; var pdwDataLen: DWORD): BOOL; stdcall;
  1204. {$EXTERNALSYM CryptExportKey}
  1205. function CryptImportKey(hProv: HCRYPTPROV; pbData: LPBYTE; dwDataLen: DWORD;
  1206. hPubKey: HCRYPTKEY; dwFlags: DWORD; var phKey: HCRYPTKEY): BOOL; stdcall;
  1207. {$EXTERNALSYM CryptImportKey}
  1208. function CryptEncrypt(hKey: HCRYPTKEY; hHash: HCRYPTHASH; Final: BOOL;
  1209. dwFlags: DWORD; pbData: LPBYTE; var pdwDataLen: DWORD; dwBufLen: DWORD): BOOL; stdcall;
  1210. {$EXTERNALSYM CryptEncrypt}
  1211. function CryptDecrypt(hKey: HCRYPTKEY; hHash: HCRYPTHASH; Final: BOOL;
  1212. dwFlags: DWORD; pbData: LPBYTE; var pdwDataLen: DWORD): BOOL; stdcall;
  1213. {$EXTERNALSYM CryptDecrypt}
  1214. function CryptCreateHash(hProv: HCRYPTPROV; Algid: ALG_ID; hKey: HCRYPTKEY;
  1215. dwFlags: DWORD; var phHash: HCRYPTHASH): BOOL; stdcall;
  1216. {$EXTERNALSYM CryptCreateHash}
  1217. function CryptHashData(hHash: HCRYPTHASH; pbData: LPBYTE; dwDataLen, dwFlags: DWORD): BOOL; stdcall;
  1218. {$EXTERNALSYM CryptHashData}
  1219. function CryptHashSessionKey(hHash: HCRYPTHASH; hKey: HCRYPTKEY; dwFlags: DWORD): BOOL; stdcall;
  1220. {$EXTERNALSYM CryptHashSessionKey}
  1221. function CryptDestroyHash(hHash: HCRYPTHASH): BOOL; stdcall;
  1222. {$EXTERNALSYM CryptDestroyHash}
  1223. function CryptSignHashA(hHash: HCRYPTHASH; dwKeySpec: DWORD; sDescription: LPCSTR;
  1224. dwFlags: DWORD; pbSignature: LPBYTE; var pdwSigLen: DWORD): BOOL; stdcall;
  1225. {$EXTERNALSYM CryptSignHashA}
  1226. function CryptSignHashW(hHash: HCRYPTHASH; dwKeySpec: DWORD; sDescription: LPCWSTR;
  1227. dwFlags: DWORD; pbSignature: LPBYTE; var pdwSigLen: DWORD): BOOL; stdcall;
  1228. {$EXTERNALSYM CryptSignHashW}
  1229. function CryptSignHash(hHash: HCRYPTHASH; dwKeySpec: DWORD; sDescription: LPCTSTR;
  1230. dwFlags: DWORD; pbSignature: LPBYTE; var pdwSigLen: DWORD): BOOL; stdcall;
  1231. {$EXTERNALSYM CryptSignHash}
  1232. function CryptVerifySignatureA(hHash: HCRYPTHASH; pbSignature: LPBYTE;
  1233. dwSigLen: DWORD; hPubKey: HCRYPTKEY; sDescription: LPCSTR; dwFlags: DWORD): BOOL; stdcall;
  1234. {$EXTERNALSYM CryptVerifySignatureA}
  1235. function CryptVerifySignatureW(hHash: HCRYPTHASH; pbSignature: LPBYTE;
  1236. dwSigLen: DWORD; hPubKey: HCRYPTKEY; sDescription: LPCWSTR; dwFlags: DWORD): BOOL; stdcall;
  1237. {$EXTERNALSYM CryptVerifySignatureW}
  1238. function CryptVerifySignature(hHash: HCRYPTHASH; pbSignature: LPBYTE;
  1239. dwSigLen: DWORD; hPubKey: HCRYPTKEY; sDescription: LPCTSTR; dwFlags: DWORD): BOOL; stdcall;
  1240. {$EXTERNALSYM CryptVerifySignature}
  1241. function CryptSetProviderA(pszProvName: LPCSTR; dwProvType: DWORD): BOOL; stdcall;
  1242. {$EXTERNALSYM CryptSetProviderA}
  1243. function CryptSetProviderW(pszProvName: LPCWSTR; dwProvType: DWORD): BOOL; stdcall;
  1244. {$EXTERNALSYM CryptSetProviderW}
  1245. function CryptSetProvider(pszProvName: LPCTSTR; dwProvType: DWORD): BOOL; stdcall;
  1246. {$EXTERNALSYM CryptSetProvider}
  1247. function CryptSetProviderExA(pszProvName: LPCSTR; dwProvType: DWORD;
  1248. pdwReserved: LPDWORD; dwFlags: DWORD): BOOL; stdcall;
  1249. {$EXTERNALSYM CryptSetProviderExA}
  1250. function CryptSetProviderExW(pszProvName: LPCWSTR; dwProvType: DWORD;
  1251. pdwReserved: LPDWORD; dwFlags: DWORD): BOOL; stdcall;
  1252. {$EXTERNALSYM CryptSetProviderExW}
  1253. function CryptSetProviderEx(pszProvName: LPCTSTR; dwProvType: DWORD;
  1254. pdwReserved: LPDWORD; dwFlags: DWORD): BOOL; stdcall;
  1255. {$EXTERNALSYM CryptSetProviderEx}
  1256. function CryptGetDefaultProviderA(dwProvType: DWORD; pdwReserved: LPDWORD;
  1257. dwFlags: DWORD; pszProvName: LPSTR; var pcbProvName: DWORD): BOOL; stdcall;
  1258. {$EXTERNALSYM CryptGetDefaultProviderA}
  1259. function CryptGetDefaultProviderW(dwProvType: DWORD; pdwReserved: LPDWORD;
  1260. dwFlags: DWORD; pszProvName: LPWSTR; var pcbProvName: DWORD): BOOL; stdcall;
  1261. {$EXTERNALSYM CryptGetDefaultProviderW}
  1262. function CryptGetDefaultProvider(dwProvType: DWORD; pdwReserved: LPDWORD;
  1263. dwFlags: DWORD; pszProvName: LPTSTR; var pcbProvName: DWORD): BOOL; stdcall;
  1264. {$EXTERNALSYM CryptGetDefaultProvider}
  1265. function CryptEnumProviderTypesA(dwIndex: DWORD; pdwReserved: LPDWORD;
  1266. dwFlags: DWORD; var pdwProvType: DWORD; pszTypeName: LPSTR;
  1267. var pcbTypeName: DWORD): BOOL; stdcall;
  1268. {$EXTERNALSYM CryptEnumProviderTypesA}
  1269. function CryptEnumProviderTypesW(dwIndex: DWORD; pdwReserved: LPDWORD;
  1270. dwFlags: DWORD; var pdwProvType: DWORD; pszTypeName: LPWSTR;
  1271. var pcbTypeName: DWORD): BOOL; stdcall;
  1272. {$EXTERNALSYM CryptEnumProviderTypesW}
  1273. function CryptEnumProviderTypes(dwIndex: DWORD; pdwReserved: LPDWORD;
  1274. dwFlags: DWORD; var pdwProvType: DWORD; pszTypeName: LPTSTR;
  1275. var pcbTypeName: DWORD): BOOL; stdcall;
  1276. {$EXTERNALSYM CryptEnumProviderTypes}
  1277. function CryptEnumProvidersA(dwIndex: DWORD; pdwReserved: LPDWORD; dwFlags: DWORD;
  1278. var pdwProvType: DWORD; pszProvName: LPSTR; var pcbProvName: DWORD): BOOL; stdcall;
  1279. {$EXTERNALSYM CryptEnumProvidersA}
  1280. function CryptEnumProvidersW(dwIndex: DWORD; pdwReserved: LPDWORD; dwFlags: DWORD;
  1281. var pdwProvType: DWORD; pszProvName: LPWSTR; var pcbProvName: DWORD): BOOL; stdcall;
  1282. {$EXTERNALSYM CryptEnumProvidersW}
  1283. function CryptEnumProviders(dwIndex: DWORD; pdwReserved: LPDWORD; dwFlags: DWORD;
  1284. var pdwProvType: DWORD; pszProvName: LPTSTR; var pcbProvName: DWORD): BOOL; stdcall;
  1285. {$EXTERNALSYM CryptEnumProviders}
  1286. function CryptContextAddRef(hProv: HCRYPTPROV; pdwReserved: LPDWORD; dwFlags: DWORD): BOOL; stdcall;
  1287. {$EXTERNALSYM CryptContextAddRef}
  1288. function CryptDuplicateKey(hKey: HCRYPTKEY; pdwReserved: LPDWORD; dwFlags: DWORD;
  1289. var phKey: HCRYPTKEY): BOOL; stdcall;
  1290. {$EXTERNALSYM CryptDuplicateKey}
  1291. function CryptDuplicateHash(hHash: HCRYPTHASH; pdwReserved: LPDWORD;
  1292. dwFlags: DWORD; var phHash: HCRYPTHASH): BOOL; stdcall;
  1293. {$EXTERNALSYM CryptDuplicateHash}
  1294. //+-------------------------------------------------------------------------
  1295. // In a CRYPT_BIT_BLOB the last byte may contain 0-7 unused bits. Therefore, the
  1296. // overall bit length is cbData * 8 - cUnusedBits.
  1297. //--------------------------------------------------------------------------
  1298. type
  1299. PCRYPT_BIT_BLOB = ^CRYPT_BIT_BLOB;
  1300. {$EXTERNALSYM PCRYPT_BIT_BLOB}
  1301. _CRYPT_BIT_BLOB = record
  1302. cbData: DWORD;
  1303. pbData: LPBYTE;
  1304. cUnusedBits: DWORD;
  1305. end;
  1306. {$EXTERNALSYM _CRYPT_BIT_BLOB}
  1307. CRYPT_BIT_BLOB = _CRYPT_BIT_BLOB;
  1308. {$EXTERNALSYM CRYPT_BIT_BLOB}
  1309. TCryptBitBlob = CRYPT_BIT_BLOB;
  1310. PCryptBitBlob = PCRYPT_BIT_BLOB;
  1311. //+-------------------------------------------------------------------------
  1312. // Type used for any algorithm
  1313. //
  1314. // Where the Parameters CRYPT_OBJID_BLOB is in its encoded representation. For most
  1315. // algorithm types, the Parameters CRYPT_OBJID_BLOB is NULL (Parameters.cbData = 0).
  1316. //--------------------------------------------------------------------------
  1317. type
  1318. PCRYPT_ALGORITHM_IDENTIFIER = ^CRYPT_ALGORITHM_IDENTIFIER;
  1319. {$EXTERNALSYM PCRYPT_ALGORITHM_IDENTIFIER}
  1320. _CRYPT_ALGORITHM_IDENTIFIER = record
  1321. pszObjId: LPSTR;
  1322. Parameters: CRYPT_OBJID_BLOB;
  1323. end;
  1324. {$EXTERNALSYM _CRYPT_ALGORITHM_IDENTIFIER}
  1325. CRYPT_ALGORITHM_IDENTIFIER = _CRYPT_ALGORITHM_IDENTIFIER;
  1326. {$EXTERNALSYM CRYPT_ALGORITHM_IDENTIFIER}
  1327. TCryptAlgorithmIdentifier = CRYPT_ALGORITHM_IDENTIFIER;
  1328. PCryptAlgorithmIdentifier = PCRYPT_ALGORITHM_IDENTIFIER;
  1329. // Following are the definitions of various algorithm object identifiers
  1330. // RSA
  1331. const
  1332. szOID_RSA = '1.2.840.113549';
  1333. {$EXTERNALSYM szOID_RSA}
  1334. szOID_PKCS = '1.2.840.113549.1';
  1335. {$EXTERNALSYM szOID_PKCS}
  1336. szOID_RSA_HASH = '1.2.840.113549.2';
  1337. {$EXTERNALSYM szOID_RSA_HASH}
  1338. szOID_RSA_ENCRYPT = '1.2.840.113549.3';
  1339. {$EXTERNALSYM szOID_RSA_ENCRYPT}
  1340. szOID_PKCS_1 = '1.2.840.113549.1.1';
  1341. {$EXTERNALSYM szOID_PKCS_1}
  1342. szOID_PKCS_2 = '1.2.840.113549.1.2';
  1343. {$EXTERNALSYM szOID_PKCS_2}
  1344. szOID_PKCS_3 = '1.2.840.113549.1.3';
  1345. {$EXTERNALSYM szOID_PKCS_3}
  1346. szOID_PKCS_4 = '1.2.840.113549.1.4';
  1347. {$EXTERNALSYM szOID_PKCS_4}
  1348. szOID_PKCS_5 = '1.2.840.113549.1.5';
  1349. {$EXTERNALSYM szOID_PKCS_5}
  1350. szOID_PKCS_6 = '1.2.840.113549.1.6';
  1351. {$EXTERNALSYM szOID_PKCS_6}
  1352. szOID_PKCS_7 = '1.2.840.113549.1.7';
  1353. {$EXTERNALSYM szOID_PKCS_7}
  1354. szOID_PKCS_8 = '1.2.840.113549.1.8';
  1355. {$EXTERNALSYM szOID_PKCS_8}
  1356. szOID_PKCS_9 = '1.2.840.113549.1.9';
  1357. {$EXTERNALSYM szOID_PKCS_9}
  1358. szOID_PKCS_10 = '1.2.840.113549.1.10';
  1359. {$EXTERNALSYM szOID_PKCS_10}
  1360. szOID_PKCS_12 = '1.2.840.113549.1.12';
  1361. {$EXTERNALSYM szOID_PKCS_12}
  1362. szOID_RSA_RSA = '1.2.840.113549.1.1.1';
  1363. {$EXTERNALSYM szOID_RSA_RSA}
  1364. szOID_RSA_MD2RSA = '1.2.840.113549.1.1.2';
  1365. {$EXTERNALSYM szOID_RSA_MD2RSA}
  1366. szOID_RSA_MD4RSA = '1.2.840.113549.1.1.3';
  1367. {$EXTERNALSYM szOID_RSA_MD4RSA}
  1368. szOID_RSA_MD5RSA = '1.2.840.113549.1.1.4';
  1369. {$EXTERNALSYM szOID_RSA_MD5RSA}
  1370. szOID_RSA_SHA1RSA = '1.2.840.113549.1.1.5';
  1371. {$EXTERNALSYM szOID_RSA_SHA1RSA}
  1372. szOID_RSA_SETOAEP_RSA = '1.2.840.113549.1.1.6';
  1373. {$EXTERNALSYM szOID_RSA_SETOAEP_RSA}
  1374. szOID_RSA_DH = '1.2.840.113549.1.3.1';
  1375. {$EXTERNALSYM szOID_RSA_DH}
  1376. szOID_RSA_data = '1.2.840.113549.1.7.1';
  1377. {$EXTERNALSYM szOID_RSA_data}
  1378. szOID_RSA_signedData = '1.2.840.113549.1.7.2';
  1379. {$EXTERNALSYM szOID_RSA_signedData}
  1380. szOID_RSA_envelopedData = '1.2.840.113549.1.7.3';
  1381. {$EXTERNALSYM szOID_RSA_envelopedData}
  1382. szOID_RSA_signEnvData = '1.2.840.113549.1.7.4';
  1383. {$EXTERNALSYM szOID_RSA_signEnvData}
  1384. szOID_RSA_digestedData = '1.2.840.113549.1.7.5';
  1385. {$EXTERNALSYM szOID_RSA_digestedData}
  1386. szOID_RSA_hashedData = '1.2.840.113549.1.7.5';
  1387. {$EXTERNALSYM szOID_RSA_hashedData}
  1388. szOID_RSA_encryptedData = '1.2.840.113549.1.7.6';
  1389. {$EXTERNALSYM szOID_RSA_encryptedData}
  1390. szOID_RSA_emailAddr = '1.2.840.113549.1.9.1';
  1391. {$EXTERNALSYM szOID_RSA_emailAddr}
  1392. szOID_RSA_unstructName = '1.2.840.113549.1.9.2';
  1393. {$EXTERNALSYM szOID_RSA_unstructName}
  1394. szOID_RSA_contentType = '1.2.840.113549.1.9.3';
  1395. {$EXTERNALSYM szOID_RSA_contentType}
  1396. szOID_RSA_messageDigest = '1.2.840.113549.1.9.4';
  1397. {$EXTERNALSYM szOID_RSA_messageDigest}
  1398. szOID_RSA_signingTime = '1.2.840.113549.1.9.5';
  1399. {$EXTERNALSYM szOID_RSA_signingTime}
  1400. szOID_RSA_counterSign = '1.2.840.113549.1.9.6';
  1401. {$EXTERNALSYM szOID_RSA_counterSign}
  1402. szOID_RSA_challengePwd = '1.2.840.113549.1.9.7';
  1403. {$EXTERNALSYM szOID_RSA_challengePwd}
  1404. szOID_RSA_unstructAddr = '1.2.840.113549.1.9.8';
  1405. {$EXTERNALSYM szOID_RSA_unstructAddr}
  1406. szOID_RSA_extCertAttrs = '1.2.840.113549.1.9.9';
  1407. {$EXTERNALSYM szOID_RSA_extCertAttrs}
  1408. szOID_RSA_certExtensions = '1.2.840.113549.1.9.14';
  1409. {$EXTERNALSYM szOID_RSA_certExtensions}
  1410. szOID_RSA_SMIMECapabilities = '1.2.840.113549.1.9.15';
  1411. {$EXTERNALSYM szOID_RSA_SMIMECapabilities}
  1412. szOID_RSA_preferSignedData = '1.2.840.113549.1.9.15.1';
  1413. {$EXTERNALSYM szOID_RSA_preferSignedData}
  1414. szOID_RSA_SMIMEalg = '1.2.840.113549.1.9.16.3';
  1415. {$EXTERNALSYM szOID_RSA_SMIMEalg}
  1416. szOID_RSA_SMIMEalgESDH = '1.2.840.113549.1.9.16.3.5';
  1417. {$EXTERNALSYM szOID_RSA_SMIMEalgESDH}
  1418. szOID_RSA_SMIMEalgCMS3DESwrap = '1.2.840.113549.1.9.16.3.6';
  1419. {$EXTERNALSYM szOID_RSA_SMIMEalgCMS3DESwrap}
  1420. szOID_RSA_SMIMEalgCMSRC2wrap = '1.2.840.113549.1.9.16.3.7';
  1421. {$EXTERNALSYM szOID_RSA_SMIMEalgCMSRC2wrap}
  1422. szOID_RSA_MD2 = '1.2.840.113549.2.2';
  1423. {$EXTERNALSYM szOID_RSA_MD2}
  1424. szOID_RSA_MD4 = '1.2.840.113549.2.4';
  1425. {$EXTERNALSYM szOID_RSA_MD4}
  1426. szOID_RSA_MD5 = '1.2.840.113549.2.5';
  1427. {$EXTERNALSYM szOID_RSA_MD5}
  1428. szOID_RSA_RC2CBC = '1.2.840.113549.3.2';
  1429. {$EXTERNALSYM szOID_RSA_RC2CBC}
  1430. szOID_RSA_RC4 = '1.2.840.113549.3.4';
  1431. {$EXTERNALSYM szOID_RSA_RC4}
  1432. szOID_RSA_DES_EDE3_CBC = '1.2.840.113549.3.7';
  1433. {$EXTERNALSYM szOID_RSA_DES_EDE3_CBC}
  1434. szOID_RSA_RC5_CBCPad = '1.2.840.113549.3.9';
  1435. {$EXTERNALSYM szOID_RSA_RC5_CBCPad}
  1436. szOID_ANSI_X942 = '1.2.840.10046';
  1437. {$EXTERNALSYM szOID_ANSI_X942}
  1438. szOID_ANSI_X942_DH = '1.2.840.10046.2.1';
  1439. {$EXTERNALSYM szOID_ANSI_X942_DH}
  1440. szOID_X957 = '1.2.840.10040';
  1441. {$EXTERNALSYM szOID_X957}
  1442. szOID_X957_DSA = '1.2.840.10040.4.1';
  1443. {$EXTERNALSYM szOID_X957_DSA}
  1444. szOID_X957_SHA1DSA = '1.2.840.10040.4.3';
  1445. {$EXTERNALSYM szOID_X957_SHA1DSA}
  1446. // ITU-T UsefulDefinitions
  1447. szOID_DS = '2.5';
  1448. {$EXTERNALSYM szOID_DS}
  1449. szOID_DSALG = '2.5.8';
  1450. {$EXTERNALSYM szOID_DSALG}
  1451. szOID_DSALG_CRPT = '2.5.8.1';
  1452. {$EXTERNALSYM szOID_DSALG_CRPT}
  1453. szOID_DSALG_HASH = '2.5.8.2';
  1454. {$EXTERNALSYM szOID_DSALG_HASH}
  1455. szOID_DSALG_SIGN = '2.5.8.3';
  1456. {$EXTERNALSYM szOID_DSALG_SIGN}
  1457. szOID_DSALG_RSA = '2.5.8.1.1';
  1458. {$EXTERNALSYM szOID_DSALG_RSA}
  1459. // NIST OSE Implementors' Workshop (OIW)
  1460. // http://nemo.ncsl.nist.gov/oiw/agreements/stable/OSI/12s_9506.w51
  1461. // http://nemo.ncsl.nist.gov/oiw/agreements/working/OSI/12w_9503.w51
  1462. szOID_OIW = '1.3.14';
  1463. {$EXTERNALSYM szOID_OIW}
  1464. // NIST OSE Implementors' Workshop (OIW) Security SIG algorithm identifiers
  1465. szOID_OIWSEC = '1.3.14.3.2';
  1466. {$EXTERNALSYM szOID_OIWSEC}
  1467. szOID_OIWSEC_md4RSA = '1.3.14.3.2.2';
  1468. {$EXTERNALSYM szOID_OIWSEC_md4RSA}
  1469. szOID_OIWSEC_md5RSA = '1.3.14.3.2.3';
  1470. {$EXTERNALSYM szOID_OIWSEC_md5RSA}
  1471. szOID_OIWSEC_md4RSA2 = '1.3.14.3.2.4';
  1472. {$EXTERNALSYM szOID_OIWSEC_md4RSA2}
  1473. szOID_OIWSEC_desECB = '1.3.14.3.2.6';
  1474. {$EXTERNALSYM szOID_OIWSEC_desECB}
  1475. szOID_OIWSEC_desCBC = '1.3.14.3.2.7';
  1476. {$EXTERNALSYM szOID_OIWSEC_desCBC}
  1477. szOID_OIWSEC_desOFB = '1.3.14.3.2.8';
  1478. {$EXTERNALSYM szOID_OIWSEC_desOFB}
  1479. szOID_OIWSEC_desCFB = '1.3.14.3.2.9';
  1480. {$EXTERNALSYM szOID_OIWSEC_desCFB}
  1481. szOID_OIWSEC_desMAC = '1.3.14.3.2.10';
  1482. {$EXTERNALSYM szOID_OIWSEC_desMAC}
  1483. szOID_OIWSEC_rsaSign = '1.3.14.3.2.11';
  1484. {$EXTERNALSYM szOID_OIWSEC_rsaSign}
  1485. szOID_OIWSEC_dsa = '1.3.14.3.2.12';
  1486. {$EXTERNALSYM szOID_OIWSEC_dsa}
  1487. szOID_OIWSEC_shaDSA = '1.3.14.3.2.13';
  1488. {$EXTERNALSYM szOID_OIWSEC_shaDSA}
  1489. szOID_OIWSEC_mdc2RSA = '1.3.14.3.2.14';
  1490. {$EXTERNALSYM szOID_OIWSEC_mdc2RSA}
  1491. szOID_OIWSEC_shaRSA = '1.3.14.3.2.15';
  1492. {$EXTERNALSYM szOID_OIWSEC_shaRSA}
  1493. szOID_OIWSEC_dhCommMod = '1.3.14.3.2.16';
  1494. {$EXTERNALSYM szOID_OIWSEC_dhCommMod}
  1495. szOID_OIWSEC_desEDE = '1.3.14.3.2.17';
  1496. {$EXTERNALSYM szOID_OIWSEC_desEDE}
  1497. szOID_OIWSEC_sha = '1.3.14.3.2.18';
  1498. {$EXTERNALSYM szOID_OIWSEC_sha}
  1499. szOID_OIWSEC_mdc2 = '1.3.14.3.2.19';
  1500. {$EXTERNALSYM szOID_OIWSEC_mdc2}
  1501. szOID_OIWSEC_dsaComm = '1.3.14.3.2.20';
  1502. {$EXTERNALSYM szOID_OIWSEC_dsaComm}
  1503. szOID_OIWSEC_dsaCommSHA = '1.3.14.3.2.21';
  1504. {$EXTERNALSYM szOID_OIWSEC_dsaCommSHA}
  1505. szOID_OIWSEC_rsaXchg = '1.3.14.3.2.22';
  1506. {$EXTERNALSYM szOID_OIWSEC_rsaXchg}
  1507. szOID_OIWSEC_keyHashSeal = '1.3.14.3.2.23';
  1508. {$EXTERNALSYM szOID_OIWSEC_keyHashSeal}
  1509. szOID_OIWSEC_md2RSASign = '1.3.14.3.2.24';
  1510. {$EXTERNALSYM szOID_OIWSEC_md2RSASign}
  1511. szOID_OIWSEC_md5RSASign = '1.3.14.3.2.25';
  1512. {$EXTERNALSYM szOID_OIWSEC_md5RSASign}
  1513. szOID_OIWSEC_sha1 = '1.3.14.3.2.26';
  1514. {$EXTERNALSYM szOID_OIWSEC_sha1}
  1515. szOID_OIWSEC_dsaSHA1 = '1.3.14.3.2.27';
  1516. {$EXTERNALSYM szOID_OIWSEC_dsaSHA1}
  1517. szOID_OIWSEC_dsaCommSHA1 = '1.3.14.3.2.28';
  1518. {$EXTERNALSYM szOID_OIWSEC_dsaCommSHA1}
  1519. szOID_OIWSEC_sha1RSASign = '1.3.14.3.2.29';
  1520. {$EXTERNALSYM szOID_OIWSEC_sha1RSASign}
  1521. // NIST OSE Implementors' Workshop (OIW) Directory SIG algorithm identifiers
  1522. szOID_OIWDIR = '1.3.14.7.2';
  1523. {$EXTERNALSYM szOID_OIWDIR}
  1524. szOID_OIWDIR_CRPT = '1.3.14.7.2.1';
  1525. {$EXTERNALSYM szOID_OIWDIR_CRPT}
  1526. szOID_OIWDIR_HASH = '1.3.14.7.2.2';
  1527. {$EXTERNALSYM szOID_OIWDIR_HASH}
  1528. szOID_OIWDIR_SIGN = '1.3.14.7.2.3';
  1529. {$EXTERNALSYM szOID_OIWDIR_SIGN}
  1530. szOID_OIWDIR_md2 = '1.3.14.7.2.2.1';
  1531. {$EXTERNALSYM szOID_OIWDIR_md2}
  1532. szOID_OIWDIR_md2RSA = '1.3.14.7.2.3.1';
  1533. {$EXTERNALSYM szOID_OIWDIR_md2RSA}
  1534. // INFOSEC Algorithms
  1535. // joint-iso-ccitt(2) country(16) us(840) organization(1) us-government(101) dod(2) id-infosec(1)
  1536. szOID_INFOSEC = '2.16.840.1.101.2.1';
  1537. {$EXTERNALSYM szOID_INFOSEC}
  1538. szOID_INFOSEC_sdnsSignature = '2.16.840.1.101.2.1.1.1';
  1539. {$EXTERNALSYM szOID_INFOSEC_sdnsSignature}
  1540. szOID_INFOSEC_mosaicSignature = '2.16.840.1.101.2.1.1.2';
  1541. {$EXTERNALSYM szOID_INFOSEC_mosaicSignature}
  1542. szOID_INFOSEC_sdnsConfidentiality = '2.16.840.1.101.2.1.1.3';
  1543. {$EXTERNALSYM szOID_INFOSEC_sdnsConfidentiality}
  1544. szOID_INFOSEC_mosaicConfidentiality = '2.16.840.1.101.2.1.1.4';
  1545. {$EXTERNALSYM szOID_INFOSEC_mosaicConfidentiality}
  1546. szOID_INFOSEC_sdnsIntegrity = '2.16.840.1.101.2.1.1.5';
  1547. {$EXTERNALSYM szOID_INFOSEC_sdnsIntegrity}
  1548. szOID_INFOSEC_mosaicIntegrity = '2.16.840.1.101.2.1.1.6';
  1549. {$EXTERNALSYM szOID_INFOSEC_mosaicIntegrity}
  1550. szOID_INFOSEC_sdnsTokenProtection = '2.16.840.1.101.2.1.1.7';
  1551. {$EXTERNALSYM szOID_INFOSEC_sdnsTokenProtection}
  1552. szOID_INFOSEC_mosaicTokenProtection = '2.16.840.1.101.2.1.1.8';
  1553. {$EXTERNALSYM szOID_INFOSEC_mosaicTokenProtection}
  1554. szOID_INFOSEC_sdnsKeyManagement = '2.16.840.1.101.2.1.1.9';
  1555. {$EXTERNALSYM szOID_INFOSEC_sdnsKeyManagement}
  1556. szOID_INFOSEC_mosaicKeyManagement = '2.16.840.1.101.2.1.1.10';
  1557. {$EXTERNALSYM szOID_INFOSEC_mosaicKeyManagement}
  1558. szOID_INFOSEC_sdnsKMandSig = '2.16.840.1.101.2.1.1.11';
  1559. {$EXTERNALSYM szOID_INFOSEC_sdnsKMandSig}
  1560. szOID_INFOSEC_mosaicKMandSig = '2.16.840.1.101.2.1.1.12';
  1561. {$EXTERNALSYM szOID_INFOSEC_mosaicKMandSig}
  1562. szOID_INFOSEC_SuiteASignature = '2.16.840.1.101.2.1.1.13';
  1563. {$EXTERNALSYM szOID_INFOSEC_SuiteASignature}
  1564. szOID_INFOSEC_SuiteAConfidentiality = '2.16.840.1.101.2.1.1.14';
  1565. {$EXTERNALSYM szOID_INFOSEC_SuiteAConfidentiality}
  1566. szOID_INFOSEC_SuiteAIntegrity = '2.16.840.1.101.2.1.1.15';
  1567. {$EXTERNALSYM szOID_INFOSEC_SuiteAIntegrity}
  1568. szOID_INFOSEC_SuiteATokenProtection = '2.16.840.1.101.2.1.1.16';
  1569. {$EXTERNALSYM szOID_INFOSEC_SuiteATokenProtection}
  1570. szOID_INFOSEC_SuiteAKeyManagement = '2.16.840.1.101.2.1.1.17';
  1571. {$EXTERNALSYM szOID_INFOSEC_SuiteAKeyManagement}
  1572. szOID_INFOSEC_SuiteAKMandSig = '2.16.840.1.101.2.1.1.18';
  1573. {$EXTERNALSYM szOID_INFOSEC_SuiteAKMandSig}
  1574. szOID_INFOSEC_mosaicUpdatedSig = '2.16.840.1.101.2.1.1.19';
  1575. {$EXTERNALSYM szOID_INFOSEC_mosaicUpdatedSig}
  1576. szOID_INFOSEC_mosaicKMandUpdSig = '2.16.840.1.101.2.1.1.20';
  1577. {$EXTERNALSYM szOID_INFOSEC_mosaicKMandUpdSig}
  1578. szOID_INFOSEC_mosaicUpdatedInteg = '2.16.840.1.101.2.1.1.21';
  1579. {$EXTERNALSYM szOID_INFOSEC_mosaicUpdatedInteg}
  1580. type
  1581. PCRYPT_OBJID_TABLE = ^CRYPT_OBJID_TABLE;
  1582. {$EXTERNALSYM PCRYPT_OBJID_TABLE}
  1583. _CRYPT_OBJID_TABLE = record
  1584. dwAlgId: DWORD;
  1585. pszObjId: LPCSTR;
  1586. end;
  1587. {$EXTERNALSYM _CRYPT_OBJID_TABLE}
  1588. CRYPT_OBJID_TABLE = _CRYPT_OBJID_TABLE;
  1589. {$EXTERNALSYM CRYPT_OBJID_TABLE}
  1590. TCryptObjIdTable = CRYPT_OBJID_TABLE;
  1591. PCryptObjIdTable = PCRYPT_OBJID_TABLE;
  1592. //+-------------------------------------------------------------------------
  1593. // PKCS #1 HashInfo (DigestInfo)
  1594. //--------------------------------------------------------------------------
  1595. PCRYPT_HASH_INFO = ^CRYPT_HASH_INFO;
  1596. {$EXTERNALSYM PCRYPT_HASH_INFO}
  1597. _CRYPT_HASH_INFO = record
  1598. HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  1599. Hash: CRYPT_HASH_BLOB;
  1600. end;
  1601. {$EXTERNALSYM _CRYPT_HASH_INFO}
  1602. CRYPT_HASH_INFO = _CRYPT_HASH_INFO;
  1603. {$EXTERNALSYM CRYPT_HASH_INFO}
  1604. TCryptHashInfo = CRYPT_HASH_INFO;
  1605. PCryptHashInfo = PCRYPT_HASH_INFO;
  1606. //+-------------------------------------------------------------------------
  1607. // Type used for an extension to an encoded content
  1608. //
  1609. // Where the Value's CRYPT_OBJID_BLOB is in its encoded representation.
  1610. //--------------------------------------------------------------------------
  1611. PCERT_EXTENSION = ^CERT_EXTENSION;
  1612. {$EXTERNALSYM PCERT_EXTENSION}
  1613. _CERT_EXTENSION = record
  1614. pszObjId: LPSTR;
  1615. fCritical: BOOL;
  1616. Value: CRYPT_OBJID_BLOB;
  1617. end;
  1618. {$EXTERNALSYM _CERT_EXTENSION}
  1619. CERT_EXTENSION = _CERT_EXTENSION;
  1620. {$EXTERNALSYM CERT_EXTENSION}
  1621. TCertExtension = CERT_EXTENSION;
  1622. PCertExtension = PCERT_EXTENSION;
  1623. //+-------------------------------------------------------------------------
  1624. // AttributeTypeValue
  1625. //
  1626. // Where the Value's CRYPT_OBJID_BLOB is in its encoded representation.
  1627. //--------------------------------------------------------------------------
  1628. PCRYPT_ATTRIBUTE_TYPE_VALUE = ^CRYPT_ATTRIBUTE_TYPE_VALUE;
  1629. {$EXTERNALSYM PCRYPT_ATTRIBUTE_TYPE_VALUE}
  1630. _CRYPT_ATTRIBUTE_TYPE_VALUE = record
  1631. pszObjId: LPSTR;
  1632. Value: CRYPT_OBJID_BLOB;
  1633. end;
  1634. {$EXTERNALSYM _CRYPT_ATTRIBUTE_TYPE_VALUE}
  1635. CRYPT_ATTRIBUTE_TYPE_VALUE = _CRYPT_ATTRIBUTE_TYPE_VALUE;
  1636. {$EXTERNALSYM CRYPT_ATTRIBUTE_TYPE_VALUE}
  1637. TCryptAttributeTypeValue = CRYPT_ATTRIBUTE_TYPE_VALUE;
  1638. PCryptAttributeTypeValue = PCRYPT_ATTRIBUTE_TYPE_VALUE;
  1639. //+-------------------------------------------------------------------------
  1640. // Attributes
  1641. //
  1642. // Where the Value's PATTR_BLOBs are in their encoded representation.
  1643. //--------------------------------------------------------------------------
  1644. PCRYPT_ATTRIBUTE = ^CRYPT_ATTRIBUTE;
  1645. {$EXTERNALSYM PCRYPT_ATTRIBUTE}
  1646. _CRYPT_ATTRIBUTE = record
  1647. pszObjId: LPSTR;
  1648. cValue: DWORD;
  1649. rgValue: PCRYPT_ATTR_BLOB;
  1650. end;
  1651. {$EXTERNALSYM _CRYPT_ATTRIBUTE}
  1652. CRYPT_ATTRIBUTE = _CRYPT_ATTRIBUTE;
  1653. {$EXTERNALSYM CRYPT_ATTRIBUTE}
  1654. TCryptAttribute = CRYPT_ATTRIBUTE;
  1655. PCryptAttribute = PCRYPT_ATTRIBUTE;
  1656. PCRYPT_ATTRIBUTES = ^CRYPT_ATTRIBUTES;
  1657. {$EXTERNALSYM PCRYPT_ATTRIBUTES}
  1658. _CRYPT_ATTRIBUTES = record
  1659. cAttr: DWORD;
  1660. rgAttr: PCRYPT_ATTRIBUTE;
  1661. end;
  1662. {$EXTERNALSYM _CRYPT_ATTRIBUTES}
  1663. CRYPT_ATTRIBUTES = _CRYPT_ATTRIBUTES;
  1664. {$EXTERNALSYM CRYPT_ATTRIBUTES}
  1665. TCryptAttributes = CRYPT_ATTRIBUTES;
  1666. PCryptAttributes = PCRYPT_ATTRIBUTES;
  1667. //+-------------------------------------------------------------------------
  1668. // Attributes making up a Relative Distinguished Name (CERT_RDN)
  1669. //
  1670. // The interpretation of the Value depends on the dwValueType.
  1671. // See below for a list of the types.
  1672. //--------------------------------------------------------------------------
  1673. PCERT_RDN_ATTR = ^CERT_RDN_ATTR;
  1674. {$EXTERNALSYM PCERT_RDN_ATTR}
  1675. _CERT_RDN_ATTR = record
  1676. pszObjId: LPSTR;
  1677. dwValueType: DWORD;
  1678. Value: CERT_RDN_VALUE_BLOB;
  1679. end;
  1680. {$EXTERNALSYM _CERT_RDN_ATTR}
  1681. CERT_RDN_ATTR = _CERT_RDN_ATTR;
  1682. {$EXTERNALSYM CERT_RDN_ATTR}
  1683. TCertRdnAttr = CERT_RDN_ATTR;
  1684. PCertRdnAttr = PCERT_RDN_ATTR;
  1685. //+-------------------------------------------------------------------------
  1686. // CERT_RDN attribute Object Identifiers
  1687. //--------------------------------------------------------------------------
  1688. // Labeling attribute types:
  1689. const
  1690. szOID_COMMON_NAME = '2.5.4.3'; // case-ignore string
  1691. {$EXTERNALSYM szOID_COMMON_NAME}
  1692. szOID_SUR_NAME = '2.5.4.4'; // case-ignore string
  1693. {$EXTERNALSYM szOID_SUR_NAME}
  1694. szOID_DEVICE_SERIAL_NUMBER = '2.5.4.5'; // printable string
  1695. {$EXTERNALSYM szOID_DEVICE_SERIAL_NUMBER}
  1696. // Geographic attribute types:
  1697. szOID_COUNTRY_NAME = '2.5.4.6'; // printable 2char string
  1698. {$EXTERNALSYM szOID_COUNTRY_NAME}
  1699. szOID_LOCALITY_NAME = '2.5.4.7'; // case-ignore string
  1700. {$EXTERNALSYM szOID_LOCALITY_NAME}
  1701. szOID_STATE_OR_PROVINCE_NAME = '2.5.4.8'; // case-ignore string
  1702. {$EXTERNALSYM szOID_STATE_OR_PROVINCE_NAME}
  1703. szOID_STREET_ADDRESS = '2.5.4.9'; // case-ignore string
  1704. {$EXTERNALSYM szOID_STREET_ADDRESS}
  1705. // Organizational attribute types:
  1706. szOID_ORGANIZATION_NAME = '2.5.4.10'; // case-ignore string
  1707. {$EXTERNALSYM szOID_ORGANIZATION_NAME}
  1708. szOID_ORGANIZATIONAL_UNIT_NAME = '2.5.4.11'; // case-ignore string
  1709. {$EXTERNALSYM szOID_ORGANIZATIONAL_UNIT_NAME}
  1710. szOID_TITLE = '2.5.4.12'; // case-ignore string
  1711. {$EXTERNALSYM szOID_TITLE}
  1712. // Explanatory attribute types:
  1713. szOID_DESCRIPTION = '2.5.4.13'; // case-ignore string
  1714. {$EXTERNALSYM szOID_DESCRIPTION}
  1715. szOID_SEARCH_GUIDE = '2.5.4.14';
  1716. {$EXTERNALSYM szOID_SEARCH_GUIDE}
  1717. szOID_BUSINESS_CATEGORY = '2.5.4.15'; // case-ignore string
  1718. {$EXTERNALSYM szOID_BUSINESS_CATEGORY}
  1719. // Postal addressing attribute types:
  1720. szOID_POSTAL_ADDRESS = '2.5.4.16';
  1721. {$EXTERNALSYM szOID_POSTAL_ADDRESS}
  1722. szOID_POSTAL_CODE = '2.5.4.17'; // case-ignore string
  1723. {$EXTERNALSYM szOID_POSTAL_CODE}
  1724. szOID_POST_OFFICE_BOX = '2.5.4.18'; // case-ignore string
  1725. {$EXTERNALSYM szOID_POST_OFFICE_BOX}
  1726. szOID_PHYSICAL_DELIVERY_OFFICE_NAME = '2.5.4.19'; // case-ignore string
  1727. {$EXTERNALSYM szOID_PHYSICAL_DELIVERY_OFFICE_NAME}
  1728. // Telecommunications addressing attribute types:
  1729. szOID_TELEPHONE_NUMBER = '2.5.4.20'; // telephone number
  1730. {$EXTERNALSYM szOID_TELEPHONE_NUMBER}
  1731. szOID_TELEX_NUMBER = '2.5.4.21';
  1732. {$EXTERNALSYM szOID_TELEX_NUMBER}
  1733. szOID_TELETEXT_TERMINAL_IDENTIFIER = '2.5.4.22';
  1734. {$EXTERNALSYM szOID_TELETEXT_TERMINAL_IDENTIFIER}
  1735. szOID_FACSIMILE_TELEPHONE_NUMBER = '2.5.4.23';
  1736. {$EXTERNALSYM szOID_FACSIMILE_TELEPHONE_NUMBER}
  1737. szOID_X21_ADDRESS = '2.5.4.24'; // numeric string
  1738. {$EXTERNALSYM szOID_X21_ADDRESS}
  1739. szOID_INTERNATIONAL_ISDN_NUMBER = '2.5.4.25'; // numeric string
  1740. {$EXTERNALSYM szOID_INTERNATIONAL_ISDN_NUMBER}
  1741. szOID_REGISTERED_ADDRESS = '2.5.4.26';
  1742. {$EXTERNALSYM szOID_REGISTERED_ADDRESS}
  1743. szOID_DESTINATION_INDICATOR = '2.5.4.27'; // printable string
  1744. {$EXTERNALSYM szOID_DESTINATION_INDICATOR}
  1745. // Preference attribute types:
  1746. szOID_PREFERRED_DELIVERY_METHOD = '2.5.4.28';
  1747. {$EXTERNALSYM szOID_PREFERRED_DELIVERY_METHOD}
  1748. // OSI application attribute types:
  1749. szOID_PRESENTATION_ADDRESS = '2.5.4.29';
  1750. {$EXTERNALSYM szOID_PRESENTATION_ADDRESS}
  1751. szOID_SUPPORTED_APPLICATION_CONTEXT = '2.5.4.30';
  1752. {$EXTERNALSYM szOID_SUPPORTED_APPLICATION_CONTEXT}
  1753. // Relational application attribute types:
  1754. szOID_MEMBER = '2.5.4.31';
  1755. {$EXTERNALSYM szOID_MEMBER}
  1756. szOID_OWNER = '2.5.4.32';
  1757. {$EXTERNALSYM szOID_OWNER}
  1758. szOID_ROLE_OCCUPANT = '2.5.4.33';
  1759. {$EXTERNALSYM szOID_ROLE_OCCUPANT}
  1760. szOID_SEE_ALSO = '2.5.4.34';
  1761. {$EXTERNALSYM szOID_SEE_ALSO}
  1762. // Security attribute types:
  1763. szOID_USER_PASSWORD = '2.5.4.35';
  1764. {$EXTERNALSYM szOID_USER_PASSWORD}
  1765. szOID_USER_CERTIFICATE = '2.5.4.36';
  1766. {$EXTERNALSYM szOID_USER_CERTIFICATE}
  1767. szOID_CA_CERTIFICATE = '2.5.4.37';
  1768. {$EXTERNALSYM szOID_CA_CERTIFICATE}
  1769. szOID_AUTHORITY_REVOCATION_LIST = '2.5.4.38';
  1770. {$EXTERNALSYM szOID_AUTHORITY_REVOCATION_LIST}
  1771. szOID_CERTIFICATE_REVOCATION_LIST = '2.5.4.39';
  1772. {$EXTERNALSYM szOID_CERTIFICATE_REVOCATION_LIST}
  1773. szOID_CROSS_CERTIFICATE_PAIR = '2.5.4.40';
  1774. {$EXTERNALSYM szOID_CROSS_CERTIFICATE_PAIR}
  1775. // Undocumented attribute types???
  1776. //#define szOID_??? "2.5.4.41"
  1777. szOID_GIVEN_NAME = '2.5.4.42'; // case-ignore string
  1778. {$EXTERNALSYM szOID_GIVEN_NAME}
  1779. szOID_INITIALS = '2.5.4.43'; // case-ignore string
  1780. {$EXTERNALSYM szOID_INITIALS}
  1781. // The DN Qualifier attribute type specifies disambiguating information to add
  1782. // to the relative distinguished name of an entry. It is intended to be used
  1783. // for entries held in multiple DSAs which would otherwise have the same name,
  1784. // and that its value be the same in a given DSA for all entries to which
  1785. // the information has been added.
  1786. szOID_DN_QUALIFIER = '2.5.4.46';
  1787. {$EXTERNALSYM szOID_DN_QUALIFIER}
  1788. // Pilot user attribute types:
  1789. szOID_DOMAIN_COMPONENT = '0.9.2342.19200300.100.1.25'; // IA5, UTF8 string
  1790. {$EXTERNALSYM szOID_DOMAIN_COMPONENT}
  1791. // used for PKCS 12 attributes
  1792. szOID_PKCS_12_FRIENDLY_NAME_ATTR = '1.2.840.113549.1.9.20';
  1793. {$EXTERNALSYM szOID_PKCS_12_FRIENDLY_NAME_ATTR}
  1794. szOID_PKCS_12_LOCAL_KEY_ID = '1.2.840.113549.1.9.21';
  1795. {$EXTERNALSYM szOID_PKCS_12_LOCAL_KEY_ID}
  1796. szOID_PKCS_12_KEY_PROVIDER_NAME_ATTR = '1.3.6.1.4.1.311.17.1';
  1797. {$EXTERNALSYM szOID_PKCS_12_KEY_PROVIDER_NAME_ATTR}
  1798. szOID_LOCAL_MACHINE_KEYSET = '1.3.6.1.4.1.311.17.2';
  1799. {$EXTERNALSYM szOID_LOCAL_MACHINE_KEYSET}
  1800. //+-------------------------------------------------------------------------
  1801. // Microsoft CERT_RDN attribute Object Identifiers
  1802. //--------------------------------------------------------------------------
  1803. // Special RDN containing the KEY_ID. Its value type is CERT_RDN_OCTET_STRING.
  1804. szOID_KEYID_RDN = '1.3.6.1.4.1.311.10.7.1';
  1805. {$EXTERNALSYM szOID_KEYID_RDN}
  1806. //+-------------------------------------------------------------------------
  1807. // CERT_RDN Attribute Value Types
  1808. //
  1809. // For RDN_ENCODED_BLOB, the Value's CERT_RDN_VALUE_BLOB is in its encoded
  1810. // representation. Otherwise, its an array of bytes.
  1811. //
  1812. // For all CERT_RDN types, Value.cbData is always the number of bytes, not
  1813. // necessarily the number of elements in the string. For instance,
  1814. // RDN_UNIVERSAL_STRING is an array of ints (cbData == intCnt * 4) and
  1815. // RDN_BMP_STRING is an array of unsigned shorts (cbData == ushortCnt * 2).
  1816. //
  1817. // A RDN_UTF8_STRING is an array of UNICODE characters (cbData == charCnt *2).
  1818. // These UNICODE characters are encoded as UTF8 8 bit characters.
  1819. //
  1820. // For CertDecodeName, two 0 bytes are always appended to the end of the
  1821. // string (ensures a CHAR or WCHAR string is null terminated).
  1822. // These added 0 bytes are't included in the BLOB.cbData.
  1823. //--------------------------------------------------------------------------
  1824. CERT_RDN_ANY_TYPE = 0;
  1825. {$EXTERNALSYM CERT_RDN_ANY_TYPE}
  1826. CERT_RDN_ENCODED_BLOB = 1;
  1827. {$EXTERNALSYM CERT_RDN_ENCODED_BLOB}
  1828. CERT_RDN_OCTET_STRING = 2;
  1829. {$EXTERNALSYM CERT_RDN_OCTET_STRING}
  1830. CERT_RDN_NUMERIC_STRING = 3;
  1831. {$EXTERNALSYM CERT_RDN_NUMERIC_STRING}
  1832. CERT_RDN_PRINTABLE_STRING = 4;
  1833. {$EXTERNALSYM CERT_RDN_PRINTABLE_STRING}
  1834. CERT_RDN_TELETEX_STRING = 5;
  1835. {$EXTERNALSYM CERT_RDN_TELETEX_STRING}
  1836. CERT_RDN_T61_STRING = 5;
  1837. {$EXTERNALSYM CERT_RDN_T61_STRING}
  1838. CERT_RDN_VIDEOTEX_STRING = 6;
  1839. {$EXTERNALSYM CERT_RDN_VIDEOTEX_STRING}
  1840. CERT_RDN_IA5_STRING = 7;
  1841. {$EXTERNALSYM CERT_RDN_IA5_STRING}
  1842. CERT_RDN_GRAPHIC_STRING = 8;
  1843. {$EXTERNALSYM CERT_RDN_GRAPHIC_STRING}
  1844. CERT_RDN_VISIBLE_STRING = 9;
  1845. {$EXTERNALSYM CERT_RDN_VISIBLE_STRING}
  1846. CERT_RDN_ISO646_STRING = 9;
  1847. {$EXTERNALSYM CERT_RDN_ISO646_STRING}
  1848. CERT_RDN_GENERAL_STRING = 10;
  1849. {$EXTERNALSYM CERT_RDN_GENERAL_STRING}
  1850. CERT_RDN_UNIVERSAL_STRING = 11;
  1851. {$EXTERNALSYM CERT_RDN_UNIVERSAL_STRING}
  1852. CERT_RDN_INT4_STRING = 11;
  1853. {$EXTERNALSYM CERT_RDN_INT4_STRING}
  1854. CERT_RDN_BMP_STRING = 12;
  1855. {$EXTERNALSYM CERT_RDN_BMP_STRING}
  1856. CERT_RDN_UNICODE_STRING = 12;
  1857. {$EXTERNALSYM CERT_RDN_UNICODE_STRING}
  1858. CERT_RDN_UTF8_STRING = 13;
  1859. {$EXTERNALSYM CERT_RDN_UTF8_STRING}
  1860. CERT_RDN_TYPE_MASK = $000000FF;
  1861. {$EXTERNALSYM CERT_RDN_TYPE_MASK}
  1862. CERT_RDN_FLAGS_MASK = DWORD($FF000000);
  1863. {$EXTERNALSYM CERT_RDN_FLAGS_MASK}
  1864. //+-------------------------------------------------------------------------
  1865. // Flags that can be or'ed with the above Value Type when encoding/decoding
  1866. //--------------------------------------------------------------------------
  1867. // For encoding: when set, CERT_RDN_T61_STRING is selected instead of
  1868. // CERT_RDN_UNICODE_STRING if all the unicode characters are <= 0xFF
  1869. CERT_RDN_ENABLE_T61_UNICODE_FLAG = DWORD($80000000);
  1870. {$EXTERNALSYM CERT_RDN_ENABLE_T61_UNICODE_FLAG}
  1871. // For encoding: when set, CERT_RDN_UTF8_STRING is selected instead of
  1872. // CERT_RDN_UNICODE_STRING.
  1873. CERT_RDN_ENABLE_UTF8_UNICODE_FLAG = $20000000;
  1874. {$EXTERNALSYM CERT_RDN_ENABLE_UTF8_UNICODE_FLAG}
  1875. // For encoding: when set, the characters aren't checked to see if they
  1876. // are valid for the Value Type.
  1877. CERT_RDN_DISABLE_CHECK_TYPE_FLAG = $40000000;
  1878. {$EXTERNALSYM CERT_RDN_DISABLE_CHECK_TYPE_FLAG}
  1879. // For decoding: by default, CERT_RDN_T61_STRING values are initially decoded
  1880. // as UTF8. If the UTF8 decoding fails, then, decoded as 8 bit characters.
  1881. // Setting this flag skips the initial attempt to decode as UTF8.
  1882. CERT_RDN_DISABLE_IE4_UTF8_FLAG = $01000000;
  1883. {$EXTERNALSYM CERT_RDN_DISABLE_IE4_UTF8_FLAG}
  1884. // Macro to check that the dwValueType is a character string and not an
  1885. // encoded blob or octet string
  1886. function IS_CERT_RDN_CHAR_STRING(X: DWORD): Boolean;
  1887. {$EXTERNALSYM IS_CERT_RDN_CHAR_STRING}
  1888. //+-------------------------------------------------------------------------
  1889. // A CERT_RDN consists of an array of the above attributes
  1890. //--------------------------------------------------------------------------
  1891. type
  1892. PCERT_RDN = ^CERT_RDN;
  1893. {$EXTERNALSYM PCERT_RDN}
  1894. _CERT_RDN = record
  1895. cRDNAttr: DWORD;
  1896. rgRDNAttr: PCERT_RDN_ATTR;
  1897. end;
  1898. {$EXTERNALSYM _CERT_RDN}
  1899. CERT_RDN = _CERT_RDN;
  1900. {$EXTERNALSYM CERT_RDN}
  1901. TCertRdn = CERT_RDN;
  1902. PCertRdn = PCERT_RDN;
  1903. //+-------------------------------------------------------------------------
  1904. // Information stored in a subject's or issuer's name. The information
  1905. // is represented as an array of the above RDNs.
  1906. //--------------------------------------------------------------------------
  1907. PCERT_NAME_INFO = ^CERT_NAME_INFO;
  1908. {$EXTERNALSYM PCERT_NAME_INFO}
  1909. _CERT_NAME_INFO = record
  1910. cRDN: DWORD;
  1911. rgRDN: PCERT_RDN;
  1912. end;
  1913. {$EXTERNALSYM _CERT_NAME_INFO}
  1914. CERT_NAME_INFO = _CERT_NAME_INFO;
  1915. {$EXTERNALSYM CERT_NAME_INFO}
  1916. TCertNameInfo = CERT_NAME_INFO;
  1917. PCertNameInfo = PCERT_NAME_INFO;
  1918. //+-------------------------------------------------------------------------
  1919. // Name attribute value without the Object Identifier
  1920. //
  1921. // The interpretation of the Value depends on the dwValueType.
  1922. // See above for a list of the types.
  1923. //--------------------------------------------------------------------------
  1924. PCERT_NAME_VALUE = ^CERT_NAME_VALUE;
  1925. {$EXTERNALSYM PCERT_NAME_VALUE}
  1926. _CERT_NAME_VALUE = record
  1927. dwValueType: DWORD;
  1928. Value: CERT_RDN_VALUE_BLOB;
  1929. end;
  1930. {$EXTERNALSYM _CERT_NAME_VALUE}
  1931. CERT_NAME_VALUE = _CERT_NAME_VALUE;
  1932. {$EXTERNALSYM CERT_NAME_VALUE}
  1933. TCertNameValue = CERT_NAME_VALUE;
  1934. PCertNameValue = PCERT_NAME_VALUE;
  1935. //+-------------------------------------------------------------------------
  1936. // Public Key Info
  1937. //
  1938. // The PublicKey is the encoded representation of the information as it is
  1939. // stored in the bit string
  1940. //--------------------------------------------------------------------------
  1941. PCERT_PUBLIC_KEY_INFO = ^CERT_PUBLIC_KEY_INFO;
  1942. {$EXTERNALSYM PCERT_PUBLIC_KEY_INFO}
  1943. _CERT_PUBLIC_KEY_INFO = record
  1944. Algorithm: CRYPT_ALGORITHM_IDENTIFIER;
  1945. PublicKey: CRYPT_BIT_BLOB;
  1946. end;
  1947. {$EXTERNALSYM _CERT_PUBLIC_KEY_INFO}
  1948. CERT_PUBLIC_KEY_INFO = _CERT_PUBLIC_KEY_INFO;
  1949. {$EXTERNALSYM CERT_PUBLIC_KEY_INFO}
  1950. TCertPublicKeyInfo = CERT_PUBLIC_KEY_INFO;
  1951. PCertPublicKeyInfo = PCERT_PUBLIC_KEY_INFO;
  1952. const
  1953. CERT_RSA_PUBLIC_KEY_OBJID = szOID_RSA_RSA;
  1954. {$EXTERNALSYM CERT_RSA_PUBLIC_KEY_OBJID}
  1955. CERT_DEFAULT_OID_PUBLIC_KEY_SIGN = szOID_RSA_RSA;
  1956. {$EXTERNALSYM CERT_DEFAULT_OID_PUBLIC_KEY_SIGN}
  1957. CERT_DEFAULT_OID_PUBLIC_KEY_XCHG = szOID_RSA_RSA;
  1958. {$EXTERNALSYM CERT_DEFAULT_OID_PUBLIC_KEY_XCHG}
  1959. //+-------------------------------------------------------------------------
  1960. // structure that contains all the information in a PKCS#8 PrivateKeyInfo
  1961. //--------------------------------------------------------------------------
  1962. type
  1963. PCRYPT_PRIVATE_KEY_INFO = ^CRYPT_PRIVATE_KEY_INFO;
  1964. {$EXTERNALSYM PCRYPT_PRIVATE_KEY_INFO}
  1965. _CRYPT_PRIVATE_KEY_INFO = record
  1966. Version: DWORD;
  1967. Algorithm: CRYPT_ALGORITHM_IDENTIFIER;
  1968. PrivateKey: CRYPT_DER_BLOB;
  1969. pAttributes: PCRYPT_ATTRIBUTES;
  1970. end;
  1971. {$EXTERNALSYM _CRYPT_PRIVATE_KEY_INFO}
  1972. CRYPT_PRIVATE_KEY_INFO = _CRYPT_PRIVATE_KEY_INFO;
  1973. {$EXTERNALSYM CRYPT_PRIVATE_KEY_INFO}
  1974. TCryptPrivateKeyInfo = CRYPT_PRIVATE_KEY_INFO;
  1975. PCryptPrivateKeyInfo = PCRYPT_PRIVATE_KEY_INFO;
  1976. //+-------------------------------------------------------------------------
  1977. // structure that contains all the information in a PKCS#8
  1978. // EncryptedPrivateKeyInfo
  1979. //--------------------------------------------------------------------------
  1980. PCRYPT_ENCRYPTED_PRIVATE_KEY_INFO = ^CRYPT_ENCRYPTED_PRIVATE_KEY_INFO;
  1981. {$EXTERNALSYM PCRYPT_ENCRYPTED_PRIVATE_KEY_INFO}
  1982. _CRYPT_ENCRYPTED_PRIVATE_KEY_INFO = record
  1983. EncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  1984. EncryptedPrivateKey: CRYPT_DATA_BLOB;
  1985. end;
  1986. {$EXTERNALSYM _CRYPT_ENCRYPTED_PRIVATE_KEY_INFO}
  1987. CRYPT_ENCRYPTED_PRIVATE_KEY_INFO = _CRYPT_ENCRYPTED_PRIVATE_KEY_INFO;
  1988. {$EXTERNALSYM CRYPT_ENCRYPTED_PRIVATE_KEY_INFO}
  1989. TCryptEncryptedPrivateKeyInfo = CRYPT_ENCRYPTED_PRIVATE_KEY_INFO;
  1990. PCryptEncryptedPrivateKeyInfo = PCRYPT_ENCRYPTED_PRIVATE_KEY_INFO;
  1991. //+-------------------------------------------------------------------------
  1992. // this callback is given when an EncryptedProvateKeyInfo structure is
  1993. // encountered during ImportPKCS8. the caller is then expected to decrypt
  1994. // the private key and hand back the decrypted contents.
  1995. //
  1996. // the parameters are:
  1997. // Algorithm - the algorithm used to encrypt the PrivateKeyInfo
  1998. // EncryptedPrivateKey - the encrypted private key blob
  1999. // pClearTextKey - a buffer to receive the clear text
  2000. // cbClearTextKey - the number of bytes of the pClearTextKey buffer
  2001. // note the if this is zero then this should be
  2002. // filled in with the size required to decrypt the
  2003. // key into, and pClearTextKey should be ignored
  2004. // pVoidDecryptFunc - this is the pVoid that was passed into the call
  2005. // and is preserved and passed back as context
  2006. //+-------------------------------------------------------------------------
  2007. type
  2008. PCRYPT_DECRYPT_PRIVATE_KEY_FUNC = function(Algorithm: CRYPT_ALGORITHM_IDENTIFIER;
  2009. EncryptedPrivateKey: CRYPT_DATA_BLOB; pbClearTextKey: LPBYTE;
  2010. pcbClearTextKey: LPDWORD; pVoidDecryptFunc: LPVOID): BOOL; stdcall;
  2011. {$EXTERNALSYM PCRYPT_DECRYPT_PRIVATE_KEY_FUNC}
  2012. PCryptDecryptPrivateKeyFunc = PCRYPT_DECRYPT_PRIVATE_KEY_FUNC;
  2013. //+-------------------------------------------------------------------------
  2014. // this callback is given when creating a PKCS8 EncryptedPrivateKeyInfo.
  2015. // The caller is then expected to encrypt the private key and hand back
  2016. // the encrypted contents.
  2017. //
  2018. // the parameters are:
  2019. // Algorithm - the algorithm used to encrypt the PrivateKeyInfo
  2020. // pClearTextPrivateKey - the cleartext private key to be encrypted
  2021. // pbEncryptedKey - the output encrypted private key blob
  2022. // cbEncryptedKey - the number of bytes of the pbEncryptedKey buffer
  2023. // note the if this is zero then this should be
  2024. // filled in with the size required to encrypt the
  2025. // key into, and pbEncryptedKey should be ignored
  2026. // pVoidEncryptFunc - this is the pVoid that was passed into the call
  2027. // and is preserved and passed back as context
  2028. //+-------------------------------------------------------------------------
  2029. type
  2030. PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC = function(pAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER;
  2031. pClearTextPrivateKey: PCRYPT_DATA_BLOB; pbEncryptedKey: LPBYTE;
  2032. pcbEncryptedKey: LPDWORD; pVoidEncryptFunc: LPVOID): BOOL; stdcall;
  2033. {$EXTERNALSYM PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC}
  2034. PCryptEncryptPrivateKeyFunc = PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC;
  2035. //+-------------------------------------------------------------------------
  2036. // this callback is given from the context of a ImportPKCS8 calls. the caller
  2037. // is then expected to hand back an HCRYPTPROV to receive the key being imported
  2038. //
  2039. // the parameters are:
  2040. // pPrivateKeyInfo - pointer to a CRYPT_PRIVATE_KEY_INFO structure which
  2041. // describes the key being imported
  2042. // EncryptedPrivateKey - the encrypted private key blob
  2043. // phCryptProv - a pointer to a HCRRYPTPROV to be filled in
  2044. // pVoidResolveFunc - this is the pVoidResolveFunc passed in by the caller in the
  2045. // CRYPT_PRIVATE_KEY_BLOB_AND_PARAMS struct
  2046. //+-------------------------------------------------------------------------
  2047. type
  2048. PCRYPT_RESOLVE_HCRYPTPROV_FUNC = function(pPrivateKeyInfo: PCRYPT_PRIVATE_KEY_INFO;
  2049. phCryptProv: PHCRYPTPROV; pVoidResolveFunc: LPVOID): BOOL; stdcall;
  2050. {$EXTERNALSYM PCRYPT_RESOLVE_HCRYPTPROV_FUNC}
  2051. PCryptResolveHCryptProvFunc = PCRYPT_RESOLVE_HCRYPTPROV_FUNC;
  2052. //+-------------------------------------------------------------------------
  2053. // this struct contains a PKCS8 private key and two pointers to callback
  2054. // functions, with a corresponding pVoids. the first callback is used to give
  2055. // the caller the opportunity to specify where the key is imported to. the callback
  2056. // passes the caller the algoroithm OID and key size to use in making the decision.
  2057. // the other callback is used to decrypt the private key if the PKCS8 contains an
  2058. // EncryptedPrivateKeyInfo. both pVoids are preserved and passed back to the caller
  2059. // in the respective callback
  2060. //+-------------------------------------------------------------------------
  2061. PCRYPT_PKCS8_IMPORT_PARAMS = ^CRYPT_PKCS8_IMPORT_PARAMS;
  2062. {$EXTERNALSYM PCRYPT_PKCS8_IMPORT_PARAMS}
  2063. _CRYPT_PKCS8_IMPORT_PARAMS = record
  2064. PrivateKey: CRYPT_DIGEST_BLOB; // PKCS8 blob
  2065. pResolvehCryptProvFunc: PCRYPT_RESOLVE_HCRYPTPROV_FUNC; // optional
  2066. pVoidResolveFunc: LPVOID; // optional
  2067. pDecryptPrivateKeyFunc: PCRYPT_DECRYPT_PRIVATE_KEY_FUNC;
  2068. pVoidDecryptFunc: LPVOID;
  2069. end;
  2070. {$EXTERNALSYM _CRYPT_PKCS8_IMPORT_PARAMS}
  2071. CRYPT_PKCS8_IMPORT_PARAMS = _CRYPT_PKCS8_IMPORT_PARAMS;
  2072. {$EXTERNALSYM CRYPT_PKCS8_IMPORT_PARAMS}
  2073. TCryptPkcs8ImportParams = CRYPT_PKCS8_IMPORT_PARAMS;
  2074. PCryptPkcs8ImportParams = PCRYPT_PKCS8_IMPORT_PARAMS;
  2075. CRYPT_PRIVATE_KEY_BLOB_AND_PARAMS = CRYPT_PKCS8_IMPORT_PARAMS;
  2076. {$EXTERNALSYM CRYPT_PRIVATE_KEY_BLOB_AND_PARAMS}
  2077. PCRYPT_PRIVATE_KEY_BLOB_AND_PARAMS = PCRYPT_PKCS8_IMPORT_PARAMS;
  2078. {$EXTERNALSYM PCRYPT_PRIVATE_KEY_BLOB_AND_PARAMS}
  2079. //+-------------------------------------------------------------------------
  2080. // this struct contains information identifying a private key and a pointer
  2081. // to a callback function, with a corresponding pVoid. The callback is used
  2082. // to encrypt the private key. If the pEncryptPrivateKeyFunc is NULL, the
  2083. // key will not be encrypted and an EncryptedPrivateKeyInfo will not be generated.
  2084. // The pVoid is preserved and passed back to the caller in the respective callback
  2085. //+-------------------------------------------------------------------------
  2086. PCRYPT_PKCS8_EXPORT_PARAMS = ^CRYPT_PKCS8_EXPORT_PARAMS;
  2087. {$EXTERNALSYM PCRYPT_PKCS8_EXPORT_PARAMS}
  2088. _CRYPT_PKCS8_EXPORT_PARAMS = record
  2089. hCryptProv: HCRYPTPROV;
  2090. dwKeySpec: DWORD;
  2091. pszPrivateKeyObjId: LPSTR;
  2092. pEncryptPrivateKeyFunc: PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC;
  2093. pVoidEncryptFunc: LPVOID;
  2094. end;
  2095. {$EXTERNALSYM _CRYPT_PKCS8_EXPORT_PARAMS}
  2096. CRYPT_PKCS8_EXPORT_PARAMS = _CRYPT_PKCS8_EXPORT_PARAMS;
  2097. {$EXTERNALSYM CRYPT_PKCS8_EXPORT_PARAMS}
  2098. TCryptPkcs8ExportParams = CRYPT_PKCS8_EXPORT_PARAMS;
  2099. PCryptPkcs8ExportParams = PCRYPT_PKCS8_EXPORT_PARAMS;
  2100. //+-------------------------------------------------------------------------
  2101. // Information stored in a certificate
  2102. //
  2103. // The Issuer, Subject, Algorithm, PublicKey and Extension BLOBs are the
  2104. // encoded representation of the information.
  2105. //--------------------------------------------------------------------------
  2106. PCERT_INFO = ^CERT_INFO;
  2107. {$EXTERNALSYM PCERT_INFO}
  2108. _CERT_INFO = record
  2109. dwVersion: DWORD;
  2110. SerialNumber: CRYPT_INTEGER_BLOB;
  2111. SignatureAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  2112. Issuer: CERT_NAME_BLOB;
  2113. NotBefore: FILETIME;
  2114. NotAfter: FILETIME;
  2115. Subject: CERT_NAME_BLOB;
  2116. SubjectPublicKeyInfo: CERT_PUBLIC_KEY_INFO;
  2117. IssuerUniqueId: CRYPT_BIT_BLOB;
  2118. SubjectUniqueId: CRYPT_BIT_BLOB;
  2119. cExtension: DWORD;
  2120. rgExtension: PCERT_EXTENSION;
  2121. end;
  2122. {$EXTERNALSYM _CERT_INFO}
  2123. CERT_INFO = _CERT_INFO;
  2124. {$EXTERNALSYM CERT_INFO}
  2125. TCertInfo = CERT_INFO;
  2126. PCertInfo = PCERT_INFO;
  2127. //+-------------------------------------------------------------------------
  2128. // Certificate versions
  2129. //--------------------------------------------------------------------------
  2130. const
  2131. CERT_V1 = 0;
  2132. {$EXTERNALSYM CERT_V1}
  2133. CERT_V2 = 1;
  2134. {$EXTERNALSYM CERT_V2}
  2135. CERT_V3 = 2;
  2136. {$EXTERNALSYM CERT_V3}
  2137. //+-------------------------------------------------------------------------
  2138. // Certificate Information Flags
  2139. //--------------------------------------------------------------------------
  2140. CERT_INFO_VERSION_FLAG = 1;
  2141. {$EXTERNALSYM CERT_INFO_VERSION_FLAG}
  2142. CERT_INFO_SERIAL_NUMBER_FLAG = 2;
  2143. {$EXTERNALSYM CERT_INFO_SERIAL_NUMBER_FLAG}
  2144. CERT_INFO_SIGNATURE_ALGORITHM_FLAG = 3;
  2145. {$EXTERNALSYM CERT_INFO_SIGNATURE_ALGORITHM_FLAG}
  2146. CERT_INFO_ISSUER_FLAG = 4;
  2147. {$EXTERNALSYM CERT_INFO_ISSUER_FLAG}
  2148. CERT_INFO_NOT_BEFORE_FLAG = 5;
  2149. {$EXTERNALSYM CERT_INFO_NOT_BEFORE_FLAG}
  2150. CERT_INFO_NOT_AFTER_FLAG = 6;
  2151. {$EXTERNALSYM CERT_INFO_NOT_AFTER_FLAG}
  2152. CERT_INFO_SUBJECT_FLAG = 7;
  2153. {$EXTERNALSYM CERT_INFO_SUBJECT_FLAG}
  2154. CERT_INFO_SUBJECT_PUBLIC_KEY_INFO_FLAG = 8;
  2155. {$EXTERNALSYM CERT_INFO_SUBJECT_PUBLIC_KEY_INFO_FLAG}
  2156. CERT_INFO_ISSUER_UNIQUE_ID_FLAG = 9;
  2157. {$EXTERNALSYM CERT_INFO_ISSUER_UNIQUE_ID_FLAG}
  2158. CERT_INFO_SUBJECT_UNIQUE_ID_FLAG = 10;
  2159. {$EXTERNALSYM CERT_INFO_SUBJECT_UNIQUE_ID_FLAG}
  2160. CERT_INFO_EXTENSION_FLAG = 11;
  2161. {$EXTERNALSYM CERT_INFO_EXTENSION_FLAG}
  2162. //+-------------------------------------------------------------------------
  2163. // An entry in a CRL
  2164. //
  2165. // The Extension BLOBs are the encoded representation of the information.
  2166. //--------------------------------------------------------------------------
  2167. type
  2168. PCRL_ENTRY = ^CRL_ENTRY;
  2169. {$EXTERNALSYM PCRL_ENTRY}
  2170. _CRL_ENTRY = record
  2171. SerialNumber: CRYPT_INTEGER_BLOB;
  2172. RevocationDate: FILETIME;
  2173. cExtension: DWORD;
  2174. rgExtension: PCERT_EXTENSION;
  2175. end;
  2176. {$EXTERNALSYM _CRL_ENTRY}
  2177. CRL_ENTRY = _CRL_ENTRY;
  2178. {$EXTERNALSYM CRL_ENTRY}
  2179. TCrlEntry = CRL_ENTRY;
  2180. PCrlEntry = PCRL_ENTRY;
  2181. //+-------------------------------------------------------------------------
  2182. // Information stored in a CRL
  2183. //
  2184. // The Issuer, Algorithm and Extension BLOBs are the encoded
  2185. // representation of the information.
  2186. //--------------------------------------------------------------------------
  2187. PCRL_INFO = ^CRL_INFO;
  2188. {$EXTERNALSYM PCRL_INFO}
  2189. _CRL_INFO = record
  2190. dwVersion: DWORD;
  2191. SignatureAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  2192. Issuer: CERT_NAME_BLOB;
  2193. ThisUpdate: FILETIME;
  2194. NextUpdate: FILETIME;
  2195. cCRLEntry: DWORD;
  2196. rgCRLEntry: PCRL_ENTRY;
  2197. cExtension: DWORD;
  2198. rgExtension: PCERT_EXTENSION;
  2199. end;
  2200. {$EXTERNALSYM _CRL_INFO}
  2201. CRL_INFO = _CRL_INFO;
  2202. {$EXTERNALSYM CRL_INFO}
  2203. TCrlInfo = CRL_INFO;
  2204. PCrlInfo = PCRL_INFO;
  2205. //+-------------------------------------------------------------------------
  2206. // CRL versions
  2207. //--------------------------------------------------------------------------
  2208. const
  2209. CRL_V1 = 0;
  2210. {$EXTERNALSYM CRL_V1}
  2211. CRL_V2 = 1;
  2212. {$EXTERNALSYM CRL_V2}
  2213. //+-------------------------------------------------------------------------
  2214. // Information stored in a certificate request
  2215. //
  2216. // The Subject, Algorithm, PublicKey and Attribute BLOBs are the encoded
  2217. // representation of the information.
  2218. //--------------------------------------------------------------------------
  2219. type
  2220. PCERT_REQUEST_INFO = ^CERT_REQUEST_INFO;
  2221. {$EXTERNALSYM PCERT_REQUEST_INFO}
  2222. _CERT_REQUEST_INFO = record
  2223. dwVersion: DWORD;
  2224. Subject: CERT_NAME_BLOB;
  2225. SubjectPublicKeyInfo: CERT_PUBLIC_KEY_INFO;
  2226. cAttribute: DWORD;
  2227. rgAttribute: PCRYPT_ATTRIBUTE;
  2228. end;
  2229. {$EXTERNALSYM _CERT_REQUEST_INFO}
  2230. CERT_REQUEST_INFO = _CERT_REQUEST_INFO;
  2231. {$EXTERNALSYM CERT_REQUEST_INFO}
  2232. TCertRequestInfo = CERT_REQUEST_INFO;
  2233. PCertRequestInfo = PCERT_REQUEST_INFO;
  2234. //+-------------------------------------------------------------------------
  2235. // Certificate Request versions
  2236. //--------------------------------------------------------------------------
  2237. const
  2238. CERT_REQUEST_V1 = 0;
  2239. {$EXTERNALSYM CERT_REQUEST_V1}
  2240. //+-------------------------------------------------------------------------
  2241. // Information stored in Netscape's Keygen request
  2242. //--------------------------------------------------------------------------
  2243. type
  2244. PCERT_KEYGEN_REQUEST_INFO = ^CERT_KEYGEN_REQUEST_INFO;
  2245. {$EXTERNALSYM PCERT_KEYGEN_REQUEST_INFO}
  2246. _CERT_KEYGEN_REQUEST_INFO = record
  2247. dwVersion: DWORD;
  2248. SubjectPublicKeyInfo: CERT_PUBLIC_KEY_INFO;
  2249. pwszChallengeString: LPWSTR; // encoded as IA5
  2250. end;
  2251. {$EXTERNALSYM _CERT_KEYGEN_REQUEST_INFO}
  2252. CERT_KEYGEN_REQUEST_INFO = _CERT_KEYGEN_REQUEST_INFO;
  2253. {$EXTERNALSYM CERT_KEYGEN_REQUEST_INFO}
  2254. TCertKeygenRequestInfo = CERT_KEYGEN_REQUEST_INFO;
  2255. PCertKeygenRequestInfo = PCERT_KEYGEN_REQUEST_INFO;
  2256. const
  2257. CERT_KEYGEN_REQUEST_V1 = 0;
  2258. {$EXTERNALSYM CERT_KEYGEN_REQUEST_V1}
  2259. //+-------------------------------------------------------------------------
  2260. // Certificate, CRL, Certificate Request or Keygen Request Signed Content
  2261. //
  2262. // The "to be signed" encoded content plus its signature. The ToBeSigned
  2263. // is the encoded CERT_INFO, CRL_INFO, CERT_REQUEST_INFO or
  2264. // CERT_KEYGEN_REQUEST_INFO.
  2265. //--------------------------------------------------------------------------
  2266. type
  2267. PCERT_SIGNED_CONTENT_INFO = ^CERT_SIGNED_CONTENT_INFO;
  2268. {$EXTERNALSYM PCERT_SIGNED_CONTENT_INFO}
  2269. _CERT_SIGNED_CONTENT_INFO = record
  2270. ToBeSigned: CRYPT_DER_BLOB;
  2271. SignatureAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  2272. Signature: CRYPT_BIT_BLOB;
  2273. end;
  2274. {$EXTERNALSYM _CERT_SIGNED_CONTENT_INFO}
  2275. CERT_SIGNED_CONTENT_INFO = _CERT_SIGNED_CONTENT_INFO;
  2276. {$EXTERNALSYM CERT_SIGNED_CONTENT_INFO}
  2277. TCertSignedContentInfo = CERT_SIGNED_CONTENT_INFO;
  2278. PCertSignedContentInfo = PCERT_SIGNED_CONTENT_INFO;
  2279. //+-------------------------------------------------------------------------
  2280. // Certificate Trust List (CTL)
  2281. //--------------------------------------------------------------------------
  2282. //+-------------------------------------------------------------------------
  2283. // CTL Usage. Also used for EnhancedKeyUsage extension.
  2284. //--------------------------------------------------------------------------
  2285. PCTL_USAGE = ^CTL_USAGE;
  2286. {$EXTERNALSYM PCTL_USAGE}
  2287. _CTL_USAGE = record
  2288. cUsageIdentifier: DWORD;
  2289. rgpszUsageIdentifier: LPSTR; // array of pszObjId
  2290. end;
  2291. {$EXTERNALSYM _CTL_USAGE}
  2292. CTL_USAGE = _CTL_USAGE;
  2293. {$EXTERNALSYM CTL_USAGE}
  2294. TCtlUsage = CTL_USAGE;
  2295. PCtlUsage = PCTL_USAGE;
  2296. CERT_ENHKEY_USAGE = CTL_USAGE;
  2297. {$EXTERNALSYM CERT_ENHKEY_USAGE}
  2298. PCERT_ENHKEY_USAGE = PCTL_USAGE;
  2299. {$EXTERNALSYM PCERT_ENHKEY_USAGE}
  2300. //+-------------------------------------------------------------------------
  2301. // An entry in a CTL
  2302. //--------------------------------------------------------------------------
  2303. PCTL_ENTRY = ^CTL_ENTRY;
  2304. {$EXTERNALSYM PCTL_ENTRY}
  2305. _CTL_ENTRY = record
  2306. SubjectIdentifier: CRYPT_DATA_BLOB; // For example, its hash
  2307. cAttribute: DWORD;
  2308. rgAttribute: PCRYPT_ATTRIBUTE; // OPTIONAL
  2309. end;
  2310. {$EXTERNALSYM _CTL_ENTRY}
  2311. CTL_ENTRY = _CTL_ENTRY;
  2312. {$EXTERNALSYM CTL_ENTRY}
  2313. TCtlEntry = CTL_ENTRY;
  2314. PCtlEntry = PCTL_ENTRY;
  2315. //+-------------------------------------------------------------------------
  2316. // Information stored in a CTL
  2317. //--------------------------------------------------------------------------
  2318. PCTL_INFO = ^CTL_INFO;
  2319. {$EXTERNALSYM PCTL_INFO}
  2320. _CTL_INFO = record
  2321. dwVersion: DWORD;
  2322. SubjectUsage: CTL_USAGE;
  2323. ListIdentifier: CRYPT_DATA_BLOB; // OPTIONAL
  2324. SequenceNumber: CRYPT_INTEGER_BLOB; // OPTIONAL
  2325. ThisUpdate: FILETIME;
  2326. NextUpdate: FILETIME; // OPTIONAL
  2327. SubjectAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  2328. cCTLEntry: DWORD;
  2329. rgCTLEntry: PCTL_ENTRY; // OPTIONAL
  2330. cExtension: DWORD;
  2331. rgExtension: PCERT_EXTENSION; // OPTIONAL
  2332. end;
  2333. {$EXTERNALSYM _CTL_INFO}
  2334. CTL_INFO = _CTL_INFO;
  2335. {$EXTERNALSYM CTL_INFO}
  2336. TCtlInfo = CTL_INFO;
  2337. PCtlInfo = PCTL_INFO;
  2338. //+-------------------------------------------------------------------------
  2339. // CTL versions
  2340. //--------------------------------------------------------------------------
  2341. const
  2342. CTL_V1 = 0;
  2343. {$EXTERNALSYM CTL_V1}
  2344. //+-------------------------------------------------------------------------
  2345. // TimeStamp Request
  2346. //
  2347. // The pszTimeStamp is the OID for the Time type requested
  2348. // The pszContentType is the Content Type OID for the content, usually DATA
  2349. // The Content is a un-decoded blob
  2350. //--------------------------------------------------------------------------
  2351. type
  2352. PCRYPT_TIME_STAMP_REQUEST_INFO = ^CRYPT_TIME_STAMP_REQUEST_INFO;
  2353. {$EXTERNALSYM PCRYPT_TIME_STAMP_REQUEST_INFO}
  2354. _CRYPT_TIME_STAMP_REQUEST_INFO = record
  2355. pszTimeStampAlgorithm: LPSTR; // pszObjId
  2356. pszContentType: LPSTR; // pszObjId
  2357. Content: CRYPT_OBJID_BLOB;
  2358. cAttribute: DWORD;
  2359. rgAttribute: PCRYPT_ATTRIBUTE;
  2360. end;
  2361. {$EXTERNALSYM _CRYPT_TIME_STAMP_REQUEST_INFO}
  2362. CRYPT_TIME_STAMP_REQUEST_INFO = _CRYPT_TIME_STAMP_REQUEST_INFO;
  2363. {$EXTERNALSYM CRYPT_TIME_STAMP_REQUEST_INFO}
  2364. TCryptTimeStampRequestInfo = CRYPT_TIME_STAMP_REQUEST_INFO;
  2365. PCryptTimeStampRequestInfo = PCRYPT_TIME_STAMP_REQUEST_INFO;
  2366. //+-------------------------------------------------------------------------
  2367. // Name Value Attribute
  2368. //--------------------------------------------------------------------------
  2369. PCRYPT_ENROLLMENT_NAME_VALUE_PAIR = ^CRYPT_ENROLLMENT_NAME_VALUE_PAIR;
  2370. {$EXTERNALSYM PCRYPT_ENROLLMENT_NAME_VALUE_PAIR}
  2371. _CRYPT_ENROLLMENT_NAME_VALUE_PAIR = record
  2372. pwszName: LPWSTR;
  2373. pwszValue: LPWSTR;
  2374. end;
  2375. {$EXTERNALSYM _CRYPT_ENROLLMENT_NAME_VALUE_PAIR}
  2376. CRYPT_ENROLLMENT_NAME_VALUE_PAIR = _CRYPT_ENROLLMENT_NAME_VALUE_PAIR;
  2377. {$EXTERNALSYM CRYPT_ENROLLMENT_NAME_VALUE_PAIR}
  2378. TCryptEnrollmentNameValuePair = CRYPT_ENROLLMENT_NAME_VALUE_PAIR;
  2379. PCryptEnrollmentNameValuePair = PCRYPT_ENROLLMENT_NAME_VALUE_PAIR;
  2380. //+-------------------------------------------------------------------------
  2381. // CSP Provider
  2382. //--------------------------------------------------------------------------
  2383. PCRYPT_CSP_PROVIDER = ^CRYPT_CSP_PROVIDER;
  2384. {$EXTERNALSYM PCRYPT_CSP_PROVIDER}
  2385. _CRYPT_CSP_PROVIDER = record
  2386. dwKeySpec: DWORD;
  2387. pwszProviderName: LPWSTR;
  2388. Signature: CRYPT_BIT_BLOB;
  2389. end;
  2390. {$EXTERNALSYM _CRYPT_CSP_PROVIDER}
  2391. CRYPT_CSP_PROVIDER = _CRYPT_CSP_PROVIDER;
  2392. {$EXTERNALSYM CRYPT_CSP_PROVIDER}
  2393. TCryptCspProvider = CRYPT_CSP_PROVIDER;
  2394. PCryptCspProvider = PCRYPT_CSP_PROVIDER;
  2395. //+-------------------------------------------------------------------------
  2396. // Certificate and Message encoding types
  2397. //
  2398. // The encoding type is a DWORD containing both the certificate and message
  2399. // encoding types. The certificate encoding type is stored in the LOWORD.
  2400. // The message encoding type is stored in the HIWORD. Some functions or
  2401. // structure fields require only one of the encoding types. The following
  2402. // naming convention is used to indicate which encoding type(s) are
  2403. // required:
  2404. // dwEncodingType (both encoding types are required)
  2405. // dwMsgAndCertEncodingType (both encoding types are required)
  2406. // dwMsgEncodingType (only msg encoding type is required)
  2407. // dwCertEncodingType (only cert encoding type is required)
  2408. //
  2409. // Its always acceptable to specify both.
  2410. //--------------------------------------------------------------------------
  2411. const
  2412. CERT_ENCODING_TYPE_MASK = $0000FFFF;
  2413. {$EXTERNALSYM CERT_ENCODING_TYPE_MASK}
  2414. CMSG_ENCODING_TYPE_MASK = DWORD($FFFF0000);
  2415. {$EXTERNALSYM CMSG_ENCODING_TYPE_MASK}
  2416. function GET_CERT_ENCODING_TYPE(X: DWORD): DWORD;
  2417. {$EXTERNALSYM GET_CERT_ENCODING_TYPE}
  2418. function GET_CMSG_ENCODING_TYPE(X: DWORD): DWORD;
  2419. {$EXTERNALSYM GET_CMSG_ENCODING_TYPE}
  2420. const
  2421. CRYPT_ASN_ENCODING = $00000001;
  2422. {$EXTERNALSYM CRYPT_ASN_ENCODING}
  2423. CRYPT_NDR_ENCODING = $00000002;
  2424. {$EXTERNALSYM CRYPT_NDR_ENCODING}
  2425. X509_ASN_ENCODING = $00000001;
  2426. {$EXTERNALSYM X509_ASN_ENCODING}
  2427. X509_NDR_ENCODING = $00000002;
  2428. {$EXTERNALSYM X509_NDR_ENCODING}
  2429. PKCS_7_ASN_ENCODING = $00010000;
  2430. {$EXTERNALSYM PKCS_7_ASN_ENCODING}
  2431. PKCS_7_NDR_ENCODING = $00020000;
  2432. {$EXTERNALSYM PKCS_7_NDR_ENCODING}
  2433. //+-------------------------------------------------------------------------
  2434. // format the specified data structure according to the certificate
  2435. // encoding type.
  2436. //
  2437. // The default behavior of CryptFormatObject is to return single line
  2438. // display of the encoded data, that is, each subfield will be concatenated with
  2439. // a ", " on one line. If user prefers to display the data in multiple line,
  2440. // set the flag CRYPT_FORMAT_STR_MULTI_LINE, that is, each subfield will be displayed
  2441. // on a seperate line.
  2442. //
  2443. // If there is no formatting routine installed or registered
  2444. // for the lpszStructType, the hex dump of the encoded BLOB will be returned.
  2445. // User can set the flag CRYPT_FORMAT_STR_NO_HEX to disable the hex dump.
  2446. //--------------------------------------------------------------------------
  2447. function CryptFormatObject(dwCertEncodingType, dwFormatType, dwFormatStrType: DWORD;
  2448. pFormatStruct: Pointer; lpszStructType: LPCSTR; pbEncoded: LPBYTE;
  2449. cbEncoded: DWORD; pbFormat: Pointer; var pcbFormat: DWORD): BOOL; stdcall;
  2450. {$EXTERNALSYM CryptFormatObject}
  2451. //-------------------------------------------------------------------------
  2452. // constants for dwFormatStrType of function CryptFormatObject
  2453. //-------------------------------------------------------------------------
  2454. const
  2455. CRYPT_FORMAT_STR_MULTI_LINE = $0001;
  2456. {$EXTERNALSYM CRYPT_FORMAT_STR_MULTI_LINE}
  2457. CRYPT_FORMAT_STR_NO_HEX = $0010;
  2458. {$EXTERNALSYM CRYPT_FORMAT_STR_NO_HEX}
  2459. //-------------------------------------------------------------------------
  2460. // constants for dwFormatType of function CryptFormatObject
  2461. // when format X509_NAME or X509_UNICODE_NAME
  2462. //-------------------------------------------------------------------------
  2463. // Just get the simple string
  2464. CRYPT_FORMAT_SIMPLE = $0001;
  2465. {$EXTERNALSYM CRYPT_FORMAT_SIMPLE}
  2466. //Put an attribute name infront of the attribute
  2467. //such as "O=Microsoft,DN=xiaohs"
  2468. CRYPT_FORMAT_X509 = $0002;
  2469. {$EXTERNALSYM CRYPT_FORMAT_X509}
  2470. //Put an OID infront of the simple string, such as
  2471. //"2.5.4.22=Microsoft,2.5.4.3=xiaohs"
  2472. CRYPT_FORMAT_OID = $0004;
  2473. {$EXTERNALSYM CRYPT_FORMAT_OID}
  2474. //Put a ";" between each RDN. The default is ","
  2475. CRYPT_FORMAT_RDN_SEMICOLON = $0100;
  2476. {$EXTERNALSYM CRYPT_FORMAT_RDN_SEMICOLON}
  2477. //Put a "\n" between each RDN.
  2478. CRYPT_FORMAT_RDN_CRLF = $0200;
  2479. {$EXTERNALSYM CRYPT_FORMAT_RDN_CRLF}
  2480. //Unquote the DN value, which is quoated by default va the following
  2481. //rules: if the DN contains leading or trailing
  2482. //white space or one of the following characters: ",", "+", "=",
  2483. //""", "\n", "<", ">", "#" or ";". The quoting character is ".
  2484. //If the DN Value contains a " it is double quoted ("").
  2485. CRYPT_FORMAT_RDN_UNQUOTE = $0400;
  2486. {$EXTERNALSYM CRYPT_FORMAT_RDN_UNQUOTE}
  2487. //reverse the order of the RDNs before converting to the string
  2488. CRYPT_FORMAT_RDN_REVERSE = $0800;
  2489. {$EXTERNALSYM CRYPT_FORMAT_RDN_REVERSE}
  2490. //-------------------------------------------------------------------------
  2491. // contants dwFormatType of function CryptFormatObject when format a DN.:
  2492. //
  2493. // The following three values are defined in the section above:
  2494. // CRYPT_FORMAT_SIMPLE: Just a simple string
  2495. // such as "Microsoft+xiaohs+NT"
  2496. // CRYPT_FORMAT_X509 Put an attribute name infront of the attribute
  2497. // such as "O=Microsoft+xiaohs+NT"
  2498. //
  2499. // CRYPT_FORMAT_OID Put an OID infront of the simple string,
  2500. // such as "2.5.4.22=Microsoft+xiaohs+NT"
  2501. //
  2502. // Additional values are defined as following:
  2503. //----------------------------------------------------------------------------
  2504. //Put a "," between each value. Default is "+"
  2505. CRYPT_FORMAT_COMMA = $1000;
  2506. {$EXTERNALSYM CRYPT_FORMAT_COMMA}
  2507. //Put a ";" between each value
  2508. CRYPT_FORMAT_SEMICOLON = CRYPT_FORMAT_RDN_SEMICOLON;
  2509. {$EXTERNALSYM CRYPT_FORMAT_SEMICOLON}
  2510. //Put a "\n" between each value
  2511. CRYPT_FORMAT_CRLF = CRYPT_FORMAT_RDN_CRLF;
  2512. {$EXTERNALSYM CRYPT_FORMAT_CRLF}
  2513. //+-------------------------------------------------------------------------
  2514. // Encode / decode the specified data structure according to the certificate
  2515. // encoding type.
  2516. //
  2517. // See below for a list of the predefined data structures.
  2518. //--------------------------------------------------------------------------
  2519. type
  2520. PFN_CRYPT_ALLOC = function(cbSize: size_t): LPVOID; stdcall;
  2521. {$EXTERNALSYM PFN_CRYPT_ALLOC}
  2522. PFN_CRYPT_FREE = procedure(pv: LPVOID); stdcall;
  2523. {$EXTERNALSYM PFN_CRYPT_FREE}
  2524. PCRYPT_ENCODE_PARA = ^CRYPT_ENCODE_PARA;
  2525. {$EXTERNALSYM PCRYPT_ENCODE_PARA}
  2526. _CRYPT_ENCODE_PARA = record
  2527. cbSize: DWORD;
  2528. pfnAlloc: PFN_CRYPT_ALLOC; // OPTIONAL
  2529. pfnFree: PFN_CRYPT_FREE; // OPTIONAL
  2530. end;
  2531. {$EXTERNALSYM _CRYPT_ENCODE_PARA}
  2532. CRYPT_ENCODE_PARA = _CRYPT_ENCODE_PARA;
  2533. {$EXTERNALSYM CRYPT_ENCODE_PARA}
  2534. TCryptEncodePara = CRYPT_ENCODE_PARA;
  2535. PCryptEncodePara = PCRYPT_ENCODE_PARA;
  2536. function CryptEncodeObjectEx(dwCertEncodingType: DWORD; lpszStructType: LPCSTR;
  2537. pvStructInfo: Pointer; dwFlags: DWORD; pEncodePara: PCRYPT_ENCODE_PARA;
  2538. pvEncoded: Pointer; var pcbEncoded: DWORD): BOOL; stdcall;
  2539. {$EXTERNALSYM CryptEncodeObjectEx}
  2540. function CryptEncodeObject(dwCertEncodingType: DWORD; lpszStructType: LPCSTR;
  2541. pvStructInfo: Pointer; pbEncoded: LPBYTE; var pcbEncoded: DWORD): BOOL; stdcall;
  2542. {$EXTERNALSYM CryptEncodeObject}
  2543. // By default the signature bytes are reversed. The following flag can
  2544. // be set to inhibit the byte reversal.
  2545. //
  2546. // This flag is applicable to
  2547. // X509_CERT_TO_BE_SIGNED
  2548. const
  2549. CRYPT_ENCODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG = $8;
  2550. {$EXTERNALSYM CRYPT_ENCODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG}
  2551. // When the following flag is set the called encode function allocates
  2552. // memory for the encoded bytes. A pointer to the allocated bytes
  2553. // is returned in pvEncoded. If pEncodePara or pEncodePara->pfnAlloc is
  2554. // NULL, then, LocalAlloc is called for the allocation and LocalFree must
  2555. // be called to do the free. Otherwise, pEncodePara->pfnAlloc is called
  2556. // for the allocation.
  2557. //
  2558. // *pcbEncoded is ignored on input and updated with the length of the
  2559. // allocated, encoded bytes.
  2560. //
  2561. // If pfnAlloc is set, then, pfnFree should also be set.
  2562. CRYPT_ENCODE_ALLOC_FLAG = $8000;
  2563. {$EXTERNALSYM CRYPT_ENCODE_ALLOC_FLAG}
  2564. // The following flag is applicable when encoding X509_UNICODE_NAME.
  2565. // When set, CERT_RDN_T61_STRING is selected instead of
  2566. // CERT_RDN_UNICODE_STRING if all the unicode characters are <= 0xFF
  2567. CRYPT_UNICODE_NAME_ENCODE_ENABLE_T61_UNICODE_FLAG = CERT_RDN_ENABLE_T61_UNICODE_FLAG;
  2568. {$EXTERNALSYM CRYPT_UNICODE_NAME_ENCODE_ENABLE_T61_UNICODE_FLAG}
  2569. // The following flag is applicable when encoding X509_UNICODE_NAME.
  2570. // When set, CERT_RDN_UTF8_STRING is selected instead of
  2571. // CERT_RDN_UNICODE_STRING.
  2572. CRYPT_UNICODE_NAME_ENCODE_ENABLE_UTF8_UNICODE_FLAG = CERT_RDN_ENABLE_UTF8_UNICODE_FLAG;
  2573. {$EXTERNALSYM CRYPT_UNICODE_NAME_ENCODE_ENABLE_UTF8_UNICODE_FLAG}
  2574. // The following flag is applicable when encoding X509_UNICODE_NAME,
  2575. // X509_UNICODE_NAME_VALUE or X509_UNICODE_ANY_STRING.
  2576. // When set, the characters aren't checked to see if they
  2577. // are valid for the specified Value Type.
  2578. CRYPT_UNICODE_NAME_ENCODE_DISABLE_CHECK_TYPE_FLAG = CERT_RDN_DISABLE_CHECK_TYPE_FLAG;
  2579. {$EXTERNALSYM CRYPT_UNICODE_NAME_ENCODE_DISABLE_CHECK_TYPE_FLAG}
  2580. // The following flag is applicable when encoding the PKCS_SORTED_CTL. This
  2581. // flag should be set if the identifier for the TrustedSubjects is a hash,
  2582. // such as, MD5 or SHA1.
  2583. CRYPT_SORTED_CTL_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG = $10000;
  2584. {$EXTERNALSYM CRYPT_SORTED_CTL_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG}
  2585. type
  2586. PCRYPT_DECODE_PARA = ^CRYPT_DECODE_PARA;
  2587. {$EXTERNALSYM PCRYPT_DECODE_PARA}
  2588. _CRYPT_DECODE_PARA = record
  2589. cbSize: DWORD;
  2590. pfnAlloc: PFN_CRYPT_ALLOC; // OPTIONAL
  2591. pfnFree: PFN_CRYPT_FREE; // OPTIONAL
  2592. end;
  2593. {$EXTERNALSYM _CRYPT_DECODE_PARA}
  2594. CRYPT_DECODE_PARA = _CRYPT_DECODE_PARA;
  2595. {$EXTERNALSYM CRYPT_DECODE_PARA}
  2596. TCryptDecodePara = CRYPT_DECODE_PARA;
  2597. PCryptDecodePara = PCRYPT_DECODE_PARA;
  2598. function CryptDecodeObjectEx(dwCertEncodingType: DWORD; lpszStructType: LPCSTR;
  2599. pbEncoded: Pointer; cbEncoded, dwFlags: DWORD; pDecodePara: PCRYPT_DECODE_PARA;
  2600. pvStructInfo: Pointer; var pcbStructInfo: DWORD): BOOL; stdcall;
  2601. {$EXTERNALSYM CryptDecodeObjectEx}
  2602. function CryptDecodeObject(dwCertEncodingType: DWORD; lpszStructType: LPCSTR;
  2603. pbEncoded: LPBYTE; cbEncoded, dwFlags: DWORD; pvStructInfo: Pointer;
  2604. var pcbStructInfo: DWORD): BOOL; stdcall;
  2605. {$EXTERNALSYM CryptDecodeObject}
  2606. // When the following flag is set the nocopy optimization is enabled.
  2607. // This optimization where appropriate, updates the pvStructInfo fields
  2608. // to point to content residing within pbEncoded instead of making a copy
  2609. // of and appending to pvStructInfo.
  2610. //
  2611. // Note, when set, pbEncoded can't be freed until pvStructInfo is freed.
  2612. const
  2613. CRYPT_DECODE_NOCOPY_FLAG = $1;
  2614. {$EXTERNALSYM CRYPT_DECODE_NOCOPY_FLAG}
  2615. // For CryptDecodeObject(), by default the pbEncoded is the "to be signed"
  2616. // plus its signature. Set the following flag, if pbEncoded points to only
  2617. // the "to be signed".
  2618. //
  2619. // This flag is applicable to
  2620. // X509_CERT_TO_BE_SIGNED
  2621. // X509_CERT_CRL_TO_BE_SIGNED
  2622. // X509_CERT_REQUEST_TO_BE_SIGNED
  2623. // X509_KEYGEN_REQUEST_TO_BE_SIGNED
  2624. CRYPT_DECODE_TO_BE_SIGNED_FLAG = $2;
  2625. {$EXTERNALSYM CRYPT_DECODE_TO_BE_SIGNED_FLAG}
  2626. // When the following flag is set, the OID strings are allocated in
  2627. // crypt32.dll and shared instead of being copied into the returned
  2628. // data structure. This flag may be set if crypt32.dll isn't unloaded
  2629. // before the caller is unloaded.
  2630. CRYPT_DECODE_SHARE_OID_STRING_FLAG = $4;
  2631. {$EXTERNALSYM CRYPT_DECODE_SHARE_OID_STRING_FLAG}
  2632. // By default the signature bytes are reversed. The following flag can
  2633. // be set to inhibit the byte reversal.
  2634. //
  2635. // This flag is applicable to
  2636. // X509_CERT_TO_BE_SIGNED
  2637. CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG = $8;
  2638. {$EXTERNALSYM CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG}
  2639. // When the following flag is set the called decode function allocates
  2640. // memory for the decoded structure. A pointer to the allocated structure
  2641. // is returned in pvStructInfo. If pDecodePara or pDecodePara->pfnAlloc is
  2642. // NULL, then, LocalAlloc is called for the allocation and LocalFree must
  2643. // be called to do the free. Otherwise, pDecodePara->pfnAlloc is called
  2644. // for the allocation.
  2645. //
  2646. // *pcbStructInfo is ignored on input and updated with the length of the
  2647. // allocated, decoded structure.
  2648. //
  2649. // This flag may also be set in the CryptDecodeObject API. Since
  2650. // CryptDecodeObject doesn't take a pDecodePara, LocalAlloc is always
  2651. // called for the allocation which must be freed by calling LocalFree.
  2652. CRYPT_DECODE_ALLOC_FLAG = $8000;
  2653. {$EXTERNALSYM CRYPT_DECODE_ALLOC_FLAG}
  2654. // The following flag is applicable when decoding X509_UNICODE_NAME,
  2655. // X509_UNICODE_NAME_VALUE or X509_UNICODE_ANY_STRING.
  2656. // By default, CERT_RDN_T61_STRING values are initially decoded
  2657. // as UTF8. If the UTF8 decoding fails, then, decoded as 8 bit characters.
  2658. // Setting this flag skips the initial attempt to decode as UTF8.
  2659. CRYPT_UNICODE_NAME_DECODE_DISABLE_IE4_UTF8_FLAG = CERT_RDN_DISABLE_IE4_UTF8_FLAG;
  2660. {$EXTERNALSYM CRYPT_UNICODE_NAME_DECODE_DISABLE_IE4_UTF8_FLAG}
  2661. //+-------------------------------------------------------------------------
  2662. // Predefined X509 certificate data structures that can be encoded / decoded.
  2663. //--------------------------------------------------------------------------
  2664. CRYPT_ENCODE_DECODE_NONE = 0;
  2665. {$EXTERNALSYM CRYPT_ENCODE_DECODE_NONE}
  2666. X509_CERT = LPCSTR(1);
  2667. {$EXTERNALSYM X509_CERT}
  2668. X509_CERT_TO_BE_SIGNED = LPCSTR(2);
  2669. {$EXTERNALSYM X509_CERT_TO_BE_SIGNED}
  2670. X509_CERT_CRL_TO_BE_SIGNED = LPCSTR(3);
  2671. {$EXTERNALSYM X509_CERT_CRL_TO_BE_SIGNED}
  2672. X509_CERT_REQUEST_TO_BE_SIGNED = LPCSTR(4);
  2673. {$EXTERNALSYM X509_CERT_REQUEST_TO_BE_SIGNED}
  2674. X509_EXTENSIONS = LPCSTR(5);
  2675. {$EXTERNALSYM X509_EXTENSIONS}
  2676. X509_NAME_VALUE = LPCSTR(6);
  2677. {$EXTERNALSYM X509_NAME_VALUE}
  2678. X509_NAME = LPCSTR(7);
  2679. {$EXTERNALSYM X509_NAME}
  2680. X509_PUBLIC_KEY_INFO = LPCSTR(8);
  2681. {$EXTERNALSYM X509_PUBLIC_KEY_INFO}
  2682. //+-------------------------------------------------------------------------
  2683. // Predefined X509 certificate extension data structures that can be
  2684. // encoded / decoded.
  2685. //--------------------------------------------------------------------------
  2686. X509_AUTHORITY_KEY_ID = LPCSTR(9);
  2687. {$EXTERNALSYM X509_AUTHORITY_KEY_ID}
  2688. X509_KEY_ATTRIBUTES = LPCSTR(10);
  2689. {$EXTERNALSYM X509_KEY_ATTRIBUTES}
  2690. X509_KEY_USAGE_RESTRICTION = LPCSTR(11);
  2691. {$EXTERNALSYM X509_KEY_USAGE_RESTRICTION}
  2692. X509_ALTERNATE_NAME = LPCSTR(12);
  2693. {$EXTERNALSYM X509_ALTERNATE_NAME}
  2694. X509_BASIC_CONSTRAINTS = LPCSTR(13);
  2695. {$EXTERNALSYM X509_BASIC_CONSTRAINTS}
  2696. X509_KEY_USAGE = LPCSTR(14);
  2697. {$EXTERNALSYM X509_KEY_USAGE}
  2698. X509_BASIC_CONSTRAINTS2 = LPCSTR(15);
  2699. {$EXTERNALSYM X509_BASIC_CONSTRAINTS2}
  2700. X509_CERT_POLICIES = LPCSTR(16);
  2701. {$EXTERNALSYM X509_CERT_POLICIES}
  2702. //+-------------------------------------------------------------------------
  2703. // Additional predefined data structures that can be encoded / decoded.
  2704. //--------------------------------------------------------------------------
  2705. PKCS_UTC_TIME = LPCSTR(17);
  2706. {$EXTERNALSYM PKCS_UTC_TIME}
  2707. PKCS_TIME_REQUEST = LPCSTR(18);
  2708. {$EXTERNALSYM PKCS_TIME_REQUEST}
  2709. RSA_CSP_PUBLICKEYBLOB = LPCSTR(19);
  2710. {$EXTERNALSYM RSA_CSP_PUBLICKEYBLOB}
  2711. X509_UNICODE_NAME = LPCSTR(20);
  2712. {$EXTERNALSYM X509_UNICODE_NAME}
  2713. X509_KEYGEN_REQUEST_TO_BE_SIGNED = LPCSTR(21);
  2714. {$EXTERNALSYM X509_KEYGEN_REQUEST_TO_BE_SIGNED}
  2715. PKCS_ATTRIBUTE = LPCSTR(22);
  2716. {$EXTERNALSYM PKCS_ATTRIBUTE}
  2717. PKCS_CONTENT_INFO_SEQUENCE_OF_ANY = LPCSTR(23);
  2718. {$EXTERNALSYM PKCS_CONTENT_INFO_SEQUENCE_OF_ANY}
  2719. //+-------------------------------------------------------------------------
  2720. // Predefined primitive data structures that can be encoded / decoded.
  2721. //--------------------------------------------------------------------------
  2722. X509_UNICODE_NAME_VALUE = LPCSTR(24);
  2723. {$EXTERNALSYM X509_UNICODE_NAME_VALUE}
  2724. X509_ANY_STRING = X509_NAME_VALUE;
  2725. {$EXTERNALSYM X509_ANY_STRING}
  2726. X509_UNICODE_ANY_STRING = X509_UNICODE_NAME_VALUE;
  2727. {$EXTERNALSYM X509_UNICODE_ANY_STRING}
  2728. X509_OCTET_STRING = LPCSTR(25);
  2729. {$EXTERNALSYM X509_OCTET_STRING}
  2730. X509_BITS = LPCSTR(26);
  2731. {$EXTERNALSYM X509_BITS}
  2732. X509_INTEGER = LPCSTR(27);
  2733. {$EXTERNALSYM X509_INTEGER}
  2734. X509_MULTI_BYTE_INTEGER = LPCSTR(28);
  2735. {$EXTERNALSYM X509_MULTI_BYTE_INTEGER}
  2736. X509_ENUMERATED = LPCSTR(29);
  2737. {$EXTERNALSYM X509_ENUMERATED}
  2738. X509_CHOICE_OF_TIME = LPCSTR(30);
  2739. {$EXTERNALSYM X509_CHOICE_OF_TIME}
  2740. //+-------------------------------------------------------------------------
  2741. // More predefined X509 certificate extension data structures that can be
  2742. // encoded / decoded.
  2743. //--------------------------------------------------------------------------
  2744. X509_AUTHORITY_KEY_ID2 = LPCSTR(31);
  2745. {$EXTERNALSYM X509_AUTHORITY_KEY_ID2}
  2746. X509_AUTHORITY_INFO_ACCESS = LPCSTR(32);
  2747. {$EXTERNALSYM X509_AUTHORITY_INFO_ACCESS}
  2748. X509_CRL_REASON_CODE = X509_ENUMERATED;
  2749. {$EXTERNALSYM X509_CRL_REASON_CODE}
  2750. PKCS_CONTENT_INFO = LPCSTR(33);
  2751. {$EXTERNALSYM PKCS_CONTENT_INFO}
  2752. X509_SEQUENCE_OF_ANY = LPCSTR(34);
  2753. {$EXTERNALSYM X509_SEQUENCE_OF_ANY}
  2754. X509_CRL_DIST_POINTS = LPCSTR(35);
  2755. {$EXTERNALSYM X509_CRL_DIST_POINTS}
  2756. X509_ENHANCED_KEY_USAGE = LPCSTR(36);
  2757. {$EXTERNALSYM X509_ENHANCED_KEY_USAGE}
  2758. PKCS_CTL = LPCSTR(37);
  2759. {$EXTERNALSYM PKCS_CTL}
  2760. X509_MULTI_BYTE_UINT = LPCSTR(38);
  2761. {$EXTERNALSYM X509_MULTI_BYTE_UINT}
  2762. X509_DSS_PUBLICKEY = X509_MULTI_BYTE_UINT;
  2763. {$EXTERNALSYM X509_DSS_PUBLICKEY}
  2764. X509_DSS_PARAMETERS = LPCSTR(39);
  2765. {$EXTERNALSYM X509_DSS_PARAMETERS}
  2766. X509_DSS_SIGNATURE = LPCSTR(40);
  2767. {$EXTERNALSYM X509_DSS_SIGNATURE}
  2768. PKCS_RC2_CBC_PARAMETERS = LPCSTR(41);
  2769. {$EXTERNALSYM PKCS_RC2_CBC_PARAMETERS}
  2770. PKCS_SMIME_CAPABILITIES = LPCSTR(42);
  2771. {$EXTERNALSYM PKCS_SMIME_CAPABILITIES}
  2772. //+-------------------------------------------------------------------------
  2773. // data structures for private keys
  2774. //--------------------------------------------------------------------------
  2775. PKCS_RSA_PRIVATE_KEY = LPCSTR(43);
  2776. {$EXTERNALSYM PKCS_RSA_PRIVATE_KEY}
  2777. PKCS_PRIVATE_KEY_INFO = LPCSTR(44);
  2778. {$EXTERNALSYM PKCS_PRIVATE_KEY_INFO}
  2779. PKCS_ENCRYPTED_PRIVATE_KEY_INFO = LPCSTR(45);
  2780. {$EXTERNALSYM PKCS_ENCRYPTED_PRIVATE_KEY_INFO}
  2781. //+-------------------------------------------------------------------------
  2782. // certificate policy qualifier
  2783. //--------------------------------------------------------------------------
  2784. X509_PKIX_POLICY_QUALIFIER_USERNOTICE = LPCSTR(46);
  2785. {$EXTERNALSYM X509_PKIX_POLICY_QUALIFIER_USERNOTICE}
  2786. //+-------------------------------------------------------------------------
  2787. // Diffie-Hellman Key Exchange
  2788. //--------------------------------------------------------------------------
  2789. X509_DH_PUBLICKEY = X509_MULTI_BYTE_UINT;
  2790. {$EXTERNALSYM X509_DH_PUBLICKEY}
  2791. X509_DH_PARAMETERS = LPCSTR(47);
  2792. {$EXTERNALSYM X509_DH_PARAMETERS}
  2793. PKCS_ATTRIBUTES = LPCSTR(48);
  2794. {$EXTERNALSYM PKCS_ATTRIBUTES}
  2795. PKCS_SORTED_CTL = LPCSTR(49);
  2796. {$EXTERNALSYM PKCS_SORTED_CTL}
  2797. //+-------------------------------------------------------------------------
  2798. // X942 Diffie-Hellman
  2799. //--------------------------------------------------------------------------
  2800. X942_DH_PARAMETERS = LPCSTR(50);
  2801. {$EXTERNALSYM X942_DH_PARAMETERS}
  2802. //+-------------------------------------------------------------------------
  2803. // The following is the same as X509_BITS, except before encoding,
  2804. // the bit length is decremented to exclude trailing zero bits.
  2805. //--------------------------------------------------------------------------
  2806. X509_BITS_WITHOUT_TRAILING_ZEROES = LPCSTR(51);
  2807. {$EXTERNALSYM X509_BITS_WITHOUT_TRAILING_ZEROES}
  2808. //+-------------------------------------------------------------------------
  2809. // X942 Diffie-Hellman Other Info
  2810. //--------------------------------------------------------------------------
  2811. X942_OTHER_INFO = LPCSTR(52);
  2812. {$EXTERNALSYM X942_OTHER_INFO}
  2813. //+-------------------------------------------------------------------------
  2814. // Predefined PKCS #7 data structures that can be encoded / decoded.
  2815. //--------------------------------------------------------------------------
  2816. PKCS7_SIGNER_INFO = LPCSTR(500);
  2817. {$EXTERNALSYM PKCS7_SIGNER_INFO}
  2818. //+-------------------------------------------------------------------------
  2819. // Predefined PKCS #7 data structures that can be encoded / decoded.
  2820. //--------------------------------------------------------------------------
  2821. CMS_SIGNER_INFO = LPCSTR(501);
  2822. {$EXTERNALSYM CMS_SIGNER_INFO}
  2823. //+-------------------------------------------------------------------------
  2824. // Predefined Software Publishing Credential (SPC) data structures that
  2825. // can be encoded / decoded.
  2826. //
  2827. // Predefined values: 2000 .. 2999
  2828. //
  2829. // See spc.h for value and data structure definitions.
  2830. //--------------------------------------------------------------------------
  2831. //+-------------------------------------------------------------------------
  2832. // Extension Object Identifiers
  2833. //--------------------------------------------------------------------------
  2834. szOID_AUTHORITY_KEY_IDENTIFIER = '2.5.29.1';
  2835. {$EXTERNALSYM szOID_AUTHORITY_KEY_IDENTIFIER}
  2836. szOID_KEY_ATTRIBUTES = '2.5.29.2';
  2837. {$EXTERNALSYM szOID_KEY_ATTRIBUTES}
  2838. szOID_CERT_POLICIES_95 = '2.5.29.3';
  2839. {$EXTERNALSYM szOID_CERT_POLICIES_95}
  2840. szOID_KEY_USAGE_RESTRICTION = '2.5.29.4';
  2841. {$EXTERNALSYM szOID_KEY_USAGE_RESTRICTION}
  2842. szOID_SUBJECT_ALT_NAME = '2.5.29.7';
  2843. {$EXTERNALSYM szOID_SUBJECT_ALT_NAME}
  2844. szOID_ISSUER_ALT_NAME = '2.5.29.8';
  2845. {$EXTERNALSYM szOID_ISSUER_ALT_NAME}
  2846. szOID_BASIC_CONSTRAINTS = '2.5.29.10';
  2847. {$EXTERNALSYM szOID_BASIC_CONSTRAINTS}
  2848. szOID_KEY_USAGE = '2.5.29.15';
  2849. {$EXTERNALSYM szOID_KEY_USAGE}
  2850. szOID_PRIVATEKEY_USAGE_PERIOD = '2.5.29.16';
  2851. {$EXTERNALSYM szOID_PRIVATEKEY_USAGE_PERIOD}
  2852. szOID_BASIC_CONSTRAINTS2 = '2.5.29.19';
  2853. {$EXTERNALSYM szOID_BASIC_CONSTRAINTS2}
  2854. szOID_CERT_POLICIES = '2.5.29.32';
  2855. {$EXTERNALSYM szOID_CERT_POLICIES}
  2856. szOID_AUTHORITY_KEY_IDENTIFIER2 = '2.5.29.35';
  2857. {$EXTERNALSYM szOID_AUTHORITY_KEY_IDENTIFIER2}
  2858. szOID_SUBJECT_KEY_IDENTIFIER = '2.5.29.14';
  2859. {$EXTERNALSYM szOID_SUBJECT_KEY_IDENTIFIER}
  2860. szOID_SUBJECT_ALT_NAME2 = '2.5.29.17';
  2861. {$EXTERNALSYM szOID_SUBJECT_ALT_NAME2}
  2862. szOID_ISSUER_ALT_NAME2 = '2.5.29.18';
  2863. {$EXTERNALSYM szOID_ISSUER_ALT_NAME2}
  2864. szOID_CRL_REASON_CODE = '2.5.29.21';
  2865. {$EXTERNALSYM szOID_CRL_REASON_CODE}
  2866. szOID_CRL_DIST_POINTS = '2.5.29.31';
  2867. {$EXTERNALSYM szOID_CRL_DIST_POINTS}
  2868. szOID_ENHANCED_KEY_USAGE = '2.5.29.37';
  2869. {$EXTERNALSYM szOID_ENHANCED_KEY_USAGE}
  2870. // Microsoft PKCS10 Attributes
  2871. szOID_RENEWAL_CERTIFICATE = '1.3.6.1.4.1.311.13.1';
  2872. {$EXTERNALSYM szOID_RENEWAL_CERTIFICATE}
  2873. szOID_ENROLLMENT_NAME_VALUE_PAIR = '1.3.6.1.4.1.311.13.2.1';
  2874. {$EXTERNALSYM szOID_ENROLLMENT_NAME_VALUE_PAIR}
  2875. szOID_ENROLLMENT_CSP_PROVIDER = '1.3.6.1.4.1.311.13.2.2';
  2876. {$EXTERNALSYM szOID_ENROLLMENT_CSP_PROVIDER}
  2877. szOID_OS_VERSION = '1.3.6.1.4.1.311.13.2.3';
  2878. {$EXTERNALSYM szOID_OS_VERSION}
  2879. //
  2880. // Extension contain certificate type
  2881. szOID_ENROLLMENT_AGENT = '1.3.6.1.4.1.311.20.2.1';
  2882. {$EXTERNALSYM szOID_ENROLLMENT_AGENT}
  2883. // Internet Public Key Infrastructure (PKIX)
  2884. szOID_PKIX = '1.3.6.1.5.5.7';
  2885. {$EXTERNALSYM szOID_PKIX}
  2886. szOID_PKIX_PE = '1.3.6.1.5.5.7.1';
  2887. {$EXTERNALSYM szOID_PKIX_PE}
  2888. szOID_AUTHORITY_INFO_ACCESS = '1.3.6.1.5.5.7.1.1';
  2889. {$EXTERNALSYM szOID_AUTHORITY_INFO_ACCESS}
  2890. // Microsoft extensions or attributes
  2891. szOID_CERT_EXTENSIONS = '1.3.6.1.4.1.311.2.1.14';
  2892. {$EXTERNALSYM szOID_CERT_EXTENSIONS}
  2893. szOID_NEXT_UPDATE_LOCATION = '1.3.6.1.4.1.311.10.2';
  2894. {$EXTERNALSYM szOID_NEXT_UPDATE_LOCATION}
  2895. // Microsoft PKCS #7 ContentType Object Identifiers
  2896. szOID_CTL = '1.3.6.1.4.1.311.10.1';
  2897. {$EXTERNALSYM szOID_CTL}
  2898. // Microsoft Sorted CTL Extension Object Identifier
  2899. szOID_SORTED_CTL = '1.3.6.1.4.1.311.10.1.1';
  2900. {$EXTERNALSYM szOID_SORTED_CTL}
  2901. // serialized serial numbers for PRS
  2902. szOID_SERIALIZED = '1.3.6.1.4.1.311.10.3.3.1';
  2903. {$EXTERNALSYM szOID_SERIALIZED}
  2904. // UPN principal name in SubjectAltName
  2905. szOID_NT_PRINCIPAL_NAME = '1.3.6.1.4.1.311.20.2.3';
  2906. {$EXTERNALSYM szOID_NT_PRINCIPAL_NAME}
  2907. // Windows product update unauthenticated attribute
  2908. szOID_PRODUCT_UPDATE = '1.3.6.1.4.1.311.31.1';
  2909. {$EXTERNALSYM szOID_PRODUCT_UPDATE}
  2910. //+-------------------------------------------------------------------------
  2911. // Object Identifiers for use with Auto Enrollment
  2912. //--------------------------------------------------------------------------
  2913. szOID_AUTO_ENROLL_CTL_USAGE = '1.3.6.1.4.1.311.20.1';
  2914. {$EXTERNALSYM szOID_AUTO_ENROLL_CTL_USAGE}
  2915. // Extension contain certificate type
  2916. szOID_ENROLL_CERTTYPE_EXTENSION = '1.3.6.1.4.1.311.20.2';
  2917. {$EXTERNALSYM szOID_ENROLL_CERTTYPE_EXTENSION}
  2918. szOID_CERT_MANIFOLD = '1.3.6.1.4.1.311.20.3';
  2919. {$EXTERNALSYM szOID_CERT_MANIFOLD}
  2920. //+-------------------------------------------------------------------------
  2921. // Object Identifiers for use with the MS Certificate Server
  2922. //--------------------------------------------------------------------------
  2923. szOID_CERTSRV_CA_VERSION = '1.3.6.1.4.1.311.21.1';
  2924. {$EXTERNALSYM szOID_CERTSRV_CA_VERSION}
  2925. //+-------------------------------------------------------------------------
  2926. // Object Identifiers for use with the MS Directory Service
  2927. //--------------------------------------------------------------------------
  2928. szOID_NTDS_REPLICATION = '1.3.6.1.4.1.311.25.1';
  2929. {$EXTERNALSYM szOID_NTDS_REPLICATION}
  2930. //+-------------------------------------------------------------------------
  2931. // Extension Object Identifiers (currently not implemented)
  2932. //--------------------------------------------------------------------------
  2933. szOID_POLICY_MAPPINGS = '2.5.29.5';
  2934. {$EXTERNALSYM szOID_POLICY_MAPPINGS}
  2935. szOID_SUBJECT_DIR_ATTRS = '2.5.29.9';
  2936. {$EXTERNALSYM szOID_SUBJECT_DIR_ATTRS}
  2937. //+-------------------------------------------------------------------------
  2938. // Enhanced Key Usage (Purpose) Object Identifiers
  2939. //--------------------------------------------------------------------------
  2940. szOID_PKIX_KP = '1.3.6.1.5.5.7.3';
  2941. {$EXTERNALSYM szOID_PKIX_KP}
  2942. // Consistent key usage bits: DIGITAL_SIGNATURE, KEY_ENCIPHERMENT
  2943. // or KEY_AGREEMENT
  2944. szOID_PKIX_KP_SERVER_AUTH = '1.3.6.1.5.5.7.3.1';
  2945. {$EXTERNALSYM szOID_PKIX_KP_SERVER_AUTH}
  2946. // Consistent key usage bits: DIGITAL_SIGNATURE
  2947. szOID_PKIX_KP_CLIENT_AUTH = '1.3.6.1.5.5.7.3.2';
  2948. {$EXTERNALSYM szOID_PKIX_KP_CLIENT_AUTH}
  2949. // Consistent key usage bits: DIGITAL_SIGNATURE
  2950. szOID_PKIX_KP_CODE_SIGNING = '1.3.6.1.5.5.7.3.3';
  2951. {$EXTERNALSYM szOID_PKIX_KP_CODE_SIGNING}
  2952. // Consistent key usage bits: DIGITAL_SIGNATURE, NON_REPUDIATION and/or
  2953. // (KEY_ENCIPHERMENT or KEY_AGREEMENT)
  2954. szOID_PKIX_KP_EMAIL_PROTECTION = '1.3.6.1.5.5.7.3.4';
  2955. {$EXTERNALSYM szOID_PKIX_KP_EMAIL_PROTECTION}
  2956. // Consistent key usage bits: DIGITAL_SIGNATURE and/or
  2957. // (KEY_ENCIPHERMENT or KEY_AGREEMENT)
  2958. szOID_PKIX_KP_IPSEC_END_SYSTEM = '1.3.6.1.5.5.7.3.5';
  2959. {$EXTERNALSYM szOID_PKIX_KP_IPSEC_END_SYSTEM}
  2960. // Consistent key usage bits: DIGITAL_SIGNATURE and/or
  2961. // (KEY_ENCIPHERMENT or KEY_AGREEMENT)
  2962. szOID_PKIX_KP_IPSEC_TUNNEL = '1.3.6.1.5.5.7.3.6';
  2963. {$EXTERNALSYM szOID_PKIX_KP_IPSEC_TUNNEL}
  2964. // Consistent key usage bits: DIGITAL_SIGNATURE and/or
  2965. // (KEY_ENCIPHERMENT or KEY_AGREEMENT)
  2966. szOID_PKIX_KP_IPSEC_USER = '1.3.6.1.5.5.7.3.7';
  2967. {$EXTERNALSYM szOID_PKIX_KP_IPSEC_USER}
  2968. // Consistent key usage bits: DIGITAL_SIGNATURE or NON_REPUDIATION
  2969. szOID_PKIX_KP_TIMESTAMP_SIGNING = '1.3.6.1.5.5.7.3.8';
  2970. {$EXTERNALSYM szOID_PKIX_KP_TIMESTAMP_SIGNING}
  2971. //+-------------------------------------------------------------------------
  2972. // Microsoft Enhanced Key Usage (Purpose) Object Identifiers
  2973. //+-------------------------------------------------------------------------
  2974. // Signer of CTLs
  2975. szOID_KP_CTL_USAGE_SIGNING = '1.3.6.1.4.1.311.10.3.1';
  2976. {$EXTERNALSYM szOID_KP_CTL_USAGE_SIGNING}
  2977. // Signer of TimeStamps
  2978. szOID_KP_TIME_STAMP_SIGNING = '1.3.6.1.4.1.311.10.3.2';
  2979. {$EXTERNALSYM szOID_KP_TIME_STAMP_SIGNING}
  2980. szOID_SERVER_GATED_CRYPTO = '1.3.6.1.4.1.311.10.3.3';
  2981. {$EXTERNALSYM szOID_SERVER_GATED_CRYPTO}
  2982. szOID_SGC_NETSCAPE = '2.16.840.1.113730.4.1';
  2983. {$EXTERNALSYM szOID_SGC_NETSCAPE}
  2984. szOID_KP_EFS = '1.3.6.1.4.1.311.10.3.4';
  2985. {$EXTERNALSYM szOID_KP_EFS}
  2986. // Can use Windows Hardware Compatible (WHQL)
  2987. szOID_WHQL_CRYPTO = '1.3.6.1.4.1.311.10.3.5';
  2988. {$EXTERNALSYM szOID_WHQL_CRYPTO}
  2989. // Signed by the NT5 build lab
  2990. szOID_NT5_CRYPTO = '1.3.6.1.4.1.311.10.3.6';
  2991. {$EXTERNALSYM szOID_NT5_CRYPTO}
  2992. // Signed by and OEM of WHQL
  2993. szOID_OEM_WHQL_CRYPTO = '1.3.6.1.4.1.311.10.3.7';
  2994. {$EXTERNALSYM szOID_OEM_WHQL_CRYPTO}
  2995. // Signed by the Embedded NT
  2996. szOID_EMBEDDED_NT_CRYPTO = '1.3.6.1.4.1.311.10.3.8';
  2997. {$EXTERNALSYM szOID_EMBEDDED_NT_CRYPTO}
  2998. szOID_DRM = '1.3.6.1.4.1.311.10.5.1';
  2999. {$EXTERNALSYM szOID_DRM}
  3000. szOID_LICENSES = '1.3.6.1.4.1.311.10.6.1';
  3001. {$EXTERNALSYM szOID_LICENSES}
  3002. szOID_LICENSE_SERVER = '1.3.6.1.4.1.311.10.6.2';
  3003. {$EXTERNALSYM szOID_LICENSE_SERVER}
  3004. szOID_KP_SMARTCARD_LOGON = '1.3.6.1.4.1.311.20.2.2';
  3005. {$EXTERNALSYM szOID_KP_SMARTCARD_LOGON}
  3006. //+-------------------------------------------------------------------------
  3007. // Microsoft Attribute Object Identifiers
  3008. //+-------------------------------------------------------------------------
  3009. szOID_YESNO_TRUST_ATTR = '1.3.6.1.4.1.311.10.4.1';
  3010. {$EXTERNALSYM szOID_YESNO_TRUST_ATTR}
  3011. //+-------------------------------------------------------------------------
  3012. // Qualifiers that may be part of the szOID_CERT_POLICIES and
  3013. // szOID_CERT_POLICIES95 extensions
  3014. //+-------------------------------------------------------------------------
  3015. szOID_PKIX_POLICY_QUALIFIER_CPS = '1.3.6.1.5.5.7.2.1';
  3016. {$EXTERNALSYM szOID_PKIX_POLICY_QUALIFIER_CPS}
  3017. szOID_PKIX_POLICY_QUALIFIER_USERNOTICE = '1.3.6.1.5.5.7.2.2';
  3018. {$EXTERNALSYM szOID_PKIX_POLICY_QUALIFIER_USERNOTICE}
  3019. // OID for old qualifer
  3020. szOID_CERT_POLICIES_95_QUALIFIER1 = '2.16.840.1.113733.1.7.1.1';
  3021. {$EXTERNALSYM szOID_CERT_POLICIES_95_QUALIFIER1}
  3022. //+-------------------------------------------------------------------------
  3023. // X509_CERT
  3024. //
  3025. // The "to be signed" encoded content plus its signature. The ToBeSigned
  3026. // content is the CryptEncodeObject() output for one of the following:
  3027. // X509_CERT_TO_BE_SIGNED, X509_CERT_CRL_TO_BE_SIGNED or
  3028. // X509_CERT_REQUEST_TO_BE_SIGNED.
  3029. //
  3030. // pvStructInfo points to CERT_SIGNED_CONTENT_INFO.
  3031. //--------------------------------------------------------------------------
  3032. //+-------------------------------------------------------------------------
  3033. // X509_CERT_TO_BE_SIGNED
  3034. //
  3035. // pvStructInfo points to CERT_INFO.
  3036. //
  3037. // For CryptDecodeObject(), the pbEncoded is the "to be signed" plus its
  3038. // signature (output of a X509_CERT CryptEncodeObject()).
  3039. //
  3040. // For CryptEncodeObject(), the pbEncoded is just the "to be signed".
  3041. //--------------------------------------------------------------------------
  3042. //+-------------------------------------------------------------------------
  3043. // X509_CERT_CRL_TO_BE_SIGNED
  3044. //
  3045. // pvStructInfo points to CRL_INFO.
  3046. //
  3047. // For CryptDecodeObject(), the pbEncoded is the "to be signed" plus its
  3048. // signature (output of a X509_CERT CryptEncodeObject()).
  3049. //
  3050. // For CryptEncodeObject(), the pbEncoded is just the "to be signed".
  3051. //--------------------------------------------------------------------------
  3052. //+-------------------------------------------------------------------------
  3053. // X509_CERT_REQUEST_TO_BE_SIGNED
  3054. //
  3055. // pvStructInfo points to CERT_REQUEST_INFO.
  3056. //
  3057. // For CryptDecodeObject(), the pbEncoded is the "to be signed" plus its
  3058. // signature (output of a X509_CERT CryptEncodeObject()).
  3059. //
  3060. // For CryptEncodeObject(), the pbEncoded is just the "to be signed".
  3061. //--------------------------------------------------------------------------
  3062. //+-------------------------------------------------------------------------
  3063. // X509_EXTENSIONS
  3064. // szOID_CERT_EXTENSIONS
  3065. //
  3066. // pvStructInfo points to following CERT_EXTENSIONS.
  3067. //--------------------------------------------------------------------------
  3068. type
  3069. PCERT_EXTENSIONS = ^CERT_EXTENSIONS;
  3070. {$EXTERNALSYM PCERT_EXTENSIONS}
  3071. _CERT_EXTENSIONS = record
  3072. cExtension: DWORD;
  3073. rgExtension: PCERT_EXTENSION;
  3074. end;
  3075. {$EXTERNALSYM _CERT_EXTENSIONS}
  3076. CERT_EXTENSIONS = _CERT_EXTENSIONS;
  3077. {$EXTERNALSYM CERT_EXTENSIONS}
  3078. TCertExtensions = CERT_EXTENSIONS;
  3079. PCertExtensions = PCERT_EXTENSIONS;
  3080. //+-------------------------------------------------------------------------
  3081. // X509_NAME_VALUE
  3082. // X509_ANY_STRING
  3083. //
  3084. // pvStructInfo points to CERT_NAME_VALUE.
  3085. //--------------------------------------------------------------------------
  3086. //+-------------------------------------------------------------------------
  3087. // X509_UNICODE_NAME_VALUE
  3088. // X509_UNICODE_ANY_STRING
  3089. //
  3090. // pvStructInfo points to CERT_NAME_VALUE.
  3091. //
  3092. // The name values are unicode strings.
  3093. //
  3094. // For CryptEncodeObject:
  3095. // Value.pbData points to the unicode string.
  3096. // If Value.cbData = 0, then, the unicode string is NULL terminated.
  3097. // Otherwise, Value.cbData is the unicode string byte count. The byte count
  3098. // is twice the character count.
  3099. //
  3100. // If the unicode string contains an invalid character for the specified
  3101. // dwValueType, then, *pcbEncoded is updated with the unicode character
  3102. // index of the first invalid character. LastError is set to:
  3103. // CRYPT_E_INVALID_NUMERIC_STRING, CRYPT_E_INVALID_PRINTABLE_STRING or
  3104. // CRYPT_E_INVALID_IA5_STRING.
  3105. //
  3106. // To disable the above check, either set CERT_RDN_DISABLE_CHECK_TYPE_FLAG
  3107. // in dwValueType or set CRYPT_UNICODE_NAME_ENCODE_DISABLE_CHECK_TYPE_FLAG
  3108. // in dwFlags passed to CryptEncodeObjectEx.
  3109. //
  3110. // The unicode string is converted before being encoded according to
  3111. // the specified dwValueType. If dwValueType is set to 0, LastError
  3112. // is set to E_INVALIDARG.
  3113. //
  3114. // If the dwValueType isn't one of the character strings (its a
  3115. // CERT_RDN_ENCODED_BLOB or CERT_RDN_OCTET_STRING), then, CryptEncodeObject
  3116. // will return FALSE with LastError set to CRYPT_E_NOT_CHAR_STRING.
  3117. //
  3118. // For CryptDecodeObject:
  3119. // Value.pbData points to a NULL terminated unicode string. Value.cbData
  3120. // contains the byte count of the unicode string excluding the NULL
  3121. // terminator. dwValueType contains the type used in the encoded object.
  3122. // Its not forced to CERT_RDN_UNICODE_STRING. The encoded value is
  3123. // converted to the unicode string according to the dwValueType.
  3124. //
  3125. // If the encoded object isn't one of the character string types, then,
  3126. // CryptDecodeObject will return FALSE with LastError set to
  3127. // CRYPT_E_NOT_CHAR_STRING. For a non character string, decode using
  3128. // X509_NAME_VALUE or X509_ANY_STRING.
  3129. //
  3130. // By default, CERT_RDN_T61_STRING values are initially decoded
  3131. // as UTF8. If the UTF8 decoding fails, then, decoded as 8 bit characters.
  3132. // Set CRYPT_UNICODE_NAME_DECODE_DISABLE_IE4_UTF8_FLAG in dwFlags
  3133. // passed to either CryptDecodeObject or CryptDecodeObjectEx to
  3134. // skip the initial attempt to decode as UTF8.
  3135. //--------------------------------------------------------------------------
  3136. //+-------------------------------------------------------------------------
  3137. // X509_NAME
  3138. //
  3139. // pvStructInfo points to CERT_NAME_INFO.
  3140. //--------------------------------------------------------------------------
  3141. //+-------------------------------------------------------------------------
  3142. // X509_UNICODE_NAME
  3143. //
  3144. // pvStructInfo points to CERT_NAME_INFO.
  3145. //
  3146. // The RDN attribute values are unicode strings except for the dwValueTypes of
  3147. // CERT_RDN_ENCODED_BLOB or CERT_RDN_OCTET_STRING. These dwValueTypes are
  3148. // the same as for a X509_NAME. Their values aren't converted to/from unicode.
  3149. //
  3150. // For CryptEncodeObject:
  3151. // Value.pbData points to the unicode string.
  3152. // If Value.cbData = 0, then, the unicode string is NULL terminated.
  3153. // Otherwise, Value.cbData is the unicode string byte count. The byte count
  3154. // is twice the character count.
  3155. //
  3156. // If dwValueType = 0 (CERT_RDN_ANY_TYPE), the pszObjId is used to find
  3157. // an acceptable dwValueType. If the unicode string contains an
  3158. // invalid character for the found or specified dwValueType, then,
  3159. // *pcbEncoded is updated with the error location of the invalid character.
  3160. // See below for details. LastError is set to:
  3161. // CRYPT_E_INVALID_NUMERIC_STRING, CRYPT_E_INVALID_PRINTABLE_STRING or
  3162. // CRYPT_E_INVALID_IA5_STRING.
  3163. //
  3164. // To disable the above check, either set CERT_RDN_DISABLE_CHECK_TYPE_FLAG
  3165. // in dwValueType or set CRYPT_UNICODE_NAME_ENCODE_DISABLE_CHECK_TYPE_FLAG
  3166. // in dwFlags passed to CryptEncodeObjectEx.
  3167. //
  3168. // Set CERT_RDN_UNICODE_STRING in dwValueType or set
  3169. // CRYPT_UNICODE_NAME_ENCODE_ENABLE_T61_UNICODE_FLAG in dwFlags passed
  3170. // to CryptEncodeObjectEx to select CERT_RDN_T61_STRING instead of
  3171. // CERT_RDN_UNICODE_STRING if all the unicode characters are <= 0xFF.
  3172. //
  3173. // Set CERT_RDN_ENABLE_UTF8_UNICODE_STRING in dwValueType or set
  3174. // CRYPT_UNICODE_NAME_ENCODE_ENABLE_UTF8_UNICODE_FLAG in dwFlags passed
  3175. // to CryptEncodeObjectEx to select CERT_RDN_UTF8_STRING instead of
  3176. // CERT_RDN_UNICODE_STRING.
  3177. //
  3178. // The unicode string is converted before being encoded according to
  3179. // the specified or ObjId matching dwValueType.
  3180. //
  3181. // For CryptDecodeObject:
  3182. // Value.pbData points to a NULL terminated unicode string. Value.cbData
  3183. // contains the byte count of the unicode string excluding the NULL
  3184. // terminator. dwValueType contains the type used in the encoded object.
  3185. // Its not forced to CERT_RDN_UNICODE_STRING. The encoded value is
  3186. // converted to the unicode string according to the dwValueType.
  3187. //
  3188. // If the dwValueType of the encoded value isn't a character string
  3189. // type, then, it isn't converted to UNICODE. Use the
  3190. // IS_CERT_RDN_CHAR_STRING() macro on the dwValueType to check
  3191. // that Value.pbData points to a converted unicode string.
  3192. //
  3193. // By default, CERT_RDN_T61_STRING values are initially decoded
  3194. // as UTF8. If the UTF8 decoding fails, then, decoded as 8 bit characters.
  3195. // Set CRYPT_UNICODE_NAME_DECODE_DISABLE_IE4_UTF8_FLAG in dwFlags
  3196. // passed to either CryptDecodeObject or CryptDecodeObjectEx to
  3197. // skip the initial attempt to decode as UTF8.
  3198. //--------------------------------------------------------------------------
  3199. //+-------------------------------------------------------------------------
  3200. // Unicode Name Value Error Location Definitions
  3201. //
  3202. // Error location is returned in *pcbEncoded by
  3203. // CryptEncodeObject(X509_UNICODE_NAME)
  3204. //
  3205. // Error location consists of:
  3206. // RDN_INDEX - 10 bits << 22
  3207. // ATTR_INDEX - 6 bits << 16
  3208. // VALUE_INDEX - 16 bits (unicode character index)
  3209. //--------------------------------------------------------------------------
  3210. const
  3211. CERT_UNICODE_RDN_ERR_INDEX_MASK = $3FF;
  3212. {$EXTERNALSYM CERT_UNICODE_RDN_ERR_INDEX_MASK}
  3213. CERT_UNICODE_RDN_ERR_INDEX_SHIFT = 22;
  3214. {$EXTERNALSYM CERT_UNICODE_RDN_ERR_INDEX_SHIFT}
  3215. CERT_UNICODE_ATTR_ERR_INDEX_MASK = $003F;
  3216. {$EXTERNALSYM CERT_UNICODE_ATTR_ERR_INDEX_MASK}
  3217. CERT_UNICODE_ATTR_ERR_INDEX_SHIFT = 16;
  3218. {$EXTERNALSYM CERT_UNICODE_ATTR_ERR_INDEX_SHIFT}
  3219. CERT_UNICODE_VALUE_ERR_INDEX_MASK = $0000FFFF;
  3220. {$EXTERNALSYM CERT_UNICODE_VALUE_ERR_INDEX_MASK}
  3221. CERT_UNICODE_VALUE_ERR_INDEX_SHIFT = 0;
  3222. {$EXTERNALSYM CERT_UNICODE_VALUE_ERR_INDEX_SHIFT}
  3223. function GET_CERT_UNICODE_RDN_ERR_INDEX(X: DWORD): DWORD;
  3224. {$EXTERNALSYM GET_CERT_UNICODE_RDN_ERR_INDEX}
  3225. function GET_CERT_UNICODE_ATTR_ERR_INDEX(X: DWORD): DWORD;
  3226. {$EXTERNALSYM GET_CERT_UNICODE_ATTR_ERR_INDEX}
  3227. function GET_CERT_UNICODE_VALUE_ERR_INDEX(X: DWORD): DWORD;
  3228. {$EXTERNALSYM GET_CERT_UNICODE_VALUE_ERR_INDEX}
  3229. //+-------------------------------------------------------------------------
  3230. // X509_PUBLIC_KEY_INFO
  3231. //
  3232. // pvStructInfo points to CERT_PUBLIC_KEY_INFO.
  3233. //--------------------------------------------------------------------------
  3234. //+-------------------------------------------------------------------------
  3235. // X509_AUTHORITY_KEY_ID
  3236. // szOID_AUTHORITY_KEY_IDENTIFIER
  3237. //
  3238. // pvStructInfo points to following CERT_AUTHORITY_KEY_ID_INFO.
  3239. //--------------------------------------------------------------------------
  3240. type
  3241. PCERT_AUTHORITY_KEY_ID_INFO = ^CERT_AUTHORITY_KEY_ID_INFO;
  3242. {$EXTERNALSYM PCERT_AUTHORITY_KEY_ID_INFO}
  3243. _CERT_AUTHORITY_KEY_ID_INFO = record
  3244. KeyId: CRYPT_DATA_BLOB;
  3245. CertIssuer: CERT_NAME_BLOB;
  3246. CertSerialNumber: CRYPT_INTEGER_BLOB;
  3247. end;
  3248. {$EXTERNALSYM _CERT_AUTHORITY_KEY_ID_INFO}
  3249. CERT_AUTHORITY_KEY_ID_INFO = _CERT_AUTHORITY_KEY_ID_INFO;
  3250. {$EXTERNALSYM CERT_AUTHORITY_KEY_ID_INFO}
  3251. TCertAuthorityKeyIdInfo = CERT_AUTHORITY_KEY_ID_INFO;
  3252. PCertAuthorityKeyIdInfo = PCERT_AUTHORITY_KEY_ID_INFO;
  3253. //+-------------------------------------------------------------------------
  3254. // X509_KEY_ATTRIBUTES
  3255. // szOID_KEY_ATTRIBUTES
  3256. //
  3257. // pvStructInfo points to following CERT_KEY_ATTRIBUTES_INFO.
  3258. //--------------------------------------------------------------------------
  3259. PCERT_PRIVATE_KEY_VALIDITY = ^CERT_PRIVATE_KEY_VALIDITY;
  3260. {$EXTERNALSYM PCERT_PRIVATE_KEY_VALIDITY}
  3261. _CERT_PRIVATE_KEY_VALIDITY = record
  3262. NotBefore: FILETIME;
  3263. NotAfter: FILETIME;
  3264. end;
  3265. {$EXTERNALSYM _CERT_PRIVATE_KEY_VALIDITY}
  3266. CERT_PRIVATE_KEY_VALIDITY = _CERT_PRIVATE_KEY_VALIDITY;
  3267. {$EXTERNALSYM CERT_PRIVATE_KEY_VALIDITY}
  3268. TCertPrivateKeyValidity = CERT_PRIVATE_KEY_VALIDITY;
  3269. PCertPrivateKeyValidity = PCERT_PRIVATE_KEY_VALIDITY;
  3270. PCERT_KEY_ATTRIBUTES_INFO = ^CERT_KEY_ATTRIBUTES_INFO;
  3271. {$EXTERNALSYM PCERT_KEY_ATTRIBUTES_INFO}
  3272. _CERT_KEY_ATTRIBUTES_INFO = record
  3273. KeyId: CRYPT_DATA_BLOB;
  3274. IntendedKeyUsage: CRYPT_BIT_BLOB;
  3275. pPrivateKeyUsagePeriod: PCERT_PRIVATE_KEY_VALIDITY; // OPTIONAL
  3276. end;
  3277. {$EXTERNALSYM _CERT_KEY_ATTRIBUTES_INFO}
  3278. CERT_KEY_ATTRIBUTES_INFO = _CERT_KEY_ATTRIBUTES_INFO;
  3279. {$EXTERNALSYM CERT_KEY_ATTRIBUTES_INFO}
  3280. TCertKeyAttributesInfo = CERT_KEY_ATTRIBUTES_INFO;
  3281. PCertKeyAttributesInfo = PCERT_KEY_ATTRIBUTES_INFO;
  3282. // Byte[0]
  3283. const
  3284. CERT_DIGITAL_SIGNATURE_KEY_USAGE = $80;
  3285. {$EXTERNALSYM CERT_DIGITAL_SIGNATURE_KEY_USAGE}
  3286. CERT_NON_REPUDIATION_KEY_USAGE = $40;
  3287. {$EXTERNALSYM CERT_NON_REPUDIATION_KEY_USAGE}
  3288. CERT_KEY_ENCIPHERMENT_KEY_USAGE = $20;
  3289. {$EXTERNALSYM CERT_KEY_ENCIPHERMENT_KEY_USAGE}
  3290. CERT_DATA_ENCIPHERMENT_KEY_USAGE = $10;
  3291. {$EXTERNALSYM CERT_DATA_ENCIPHERMENT_KEY_USAGE}
  3292. CERT_KEY_AGREEMENT_KEY_USAGE = $08;
  3293. {$EXTERNALSYM CERT_KEY_AGREEMENT_KEY_USAGE}
  3294. CERT_KEY_CERT_SIGN_KEY_USAGE = $04;
  3295. {$EXTERNALSYM CERT_KEY_CERT_SIGN_KEY_USAGE}
  3296. CERT_OFFLINE_CRL_SIGN_KEY_USAGE = $02;
  3297. {$EXTERNALSYM CERT_OFFLINE_CRL_SIGN_KEY_USAGE}
  3298. CERT_CRL_SIGN_KEY_USAGE = $02;
  3299. {$EXTERNALSYM CERT_CRL_SIGN_KEY_USAGE}
  3300. CERT_ENCIPHER_ONLY_KEY_USAGE = $01;
  3301. {$EXTERNALSYM CERT_ENCIPHER_ONLY_KEY_USAGE}
  3302. // Byte[1]
  3303. CERT_DECIPHER_ONLY_KEY_USAGE = $80;
  3304. {$EXTERNALSYM CERT_DECIPHER_ONLY_KEY_USAGE}
  3305. //+-------------------------------------------------------------------------
  3306. // X509_KEY_USAGE_RESTRICTION
  3307. // szOID_KEY_USAGE_RESTRICTION
  3308. //
  3309. // pvStructInfo points to following CERT_KEY_USAGE_RESTRICTION_INFO.
  3310. //--------------------------------------------------------------------------
  3311. type
  3312. PCERT_POLICY_ID = ^CERT_POLICY_ID;
  3313. {$EXTERNALSYM PCERT_POLICY_ID}
  3314. _CERT_POLICY_ID = record
  3315. cCertPolicyElementId: DWORD;
  3316. rgpszCertPolicyElementId: LPSTR; // pszObjId
  3317. end;
  3318. {$EXTERNALSYM _CERT_POLICY_ID}
  3319. CERT_POLICY_ID = _CERT_POLICY_ID;
  3320. {$EXTERNALSYM CERT_POLICY_ID}
  3321. TCertPolicyId = CERT_POLICY_ID;
  3322. PCertPolicyId = PCERT_POLICY_ID;
  3323. PCERT_KEY_USAGE_RESTRICTION_INFO = ^CERT_KEY_USAGE_RESTRICTION_INFO;
  3324. {$EXTERNALSYM PCERT_KEY_USAGE_RESTRICTION_INFO}
  3325. _CERT_KEY_USAGE_RESTRICTION_INFO = record
  3326. cCertPolicyId: DWORD;
  3327. rgCertPolicyId: PCERT_POLICY_ID;
  3328. RestrictedKeyUsage: CRYPT_BIT_BLOB;
  3329. end;
  3330. {$EXTERNALSYM _CERT_KEY_USAGE_RESTRICTION_INFO}
  3331. CERT_KEY_USAGE_RESTRICTION_INFO = _CERT_KEY_USAGE_RESTRICTION_INFO;
  3332. {$EXTERNALSYM CERT_KEY_USAGE_RESTRICTION_INFO}
  3333. TCertKeyUsageRestrictionInfo = CERT_KEY_USAGE_RESTRICTION_INFO;
  3334. PCertKeyUsageRestrictionInfo = PCERT_KEY_USAGE_RESTRICTION_INFO;
  3335. // See CERT_KEY_ATTRIBUTES_INFO for definition of the RestrictedKeyUsage bits
  3336. //+-------------------------------------------------------------------------
  3337. // X509_ALTERNATE_NAME
  3338. // szOID_SUBJECT_ALT_NAME
  3339. // szOID_ISSUER_ALT_NAME
  3340. // szOID_SUBJECT_ALT_NAME2
  3341. // szOID_ISSUER_ALT_NAME2
  3342. //
  3343. // pvStructInfo points to following CERT_ALT_NAME_INFO.
  3344. //--------------------------------------------------------------------------
  3345. PCERT_OTHER_NAME = ^CERT_OTHER_NAME;
  3346. {$EXTERNALSYM PCERT_OTHER_NAME}
  3347. _CERT_OTHER_NAME = record
  3348. pszObjId: LPSTR;
  3349. Value: CRYPT_OBJID_BLOB;
  3350. end;
  3351. {$EXTERNALSYM _CERT_OTHER_NAME}
  3352. CERT_OTHER_NAME = _CERT_OTHER_NAME;
  3353. {$EXTERNALSYM CERT_OTHER_NAME}
  3354. TCertOtherName = CERT_OTHER_NAME;
  3355. PCertOtherName = PCERT_OTHER_NAME;
  3356. PCERT_ALT_NAME_ENTRY = ^CERT_ALT_NAME_ENTRY;
  3357. {$EXTERNALSYM PCERT_ALT_NAME_ENTRY}
  3358. _CERT_ALT_NAME_ENTRY = record
  3359. dwAltNameChoice: DWORD;
  3360. //union {
  3361. case Integer of
  3362. 0: (pOtherName: PCERT_OTHER_NAME); // 1
  3363. 1: (pwszRfc822Name: LPWSTR); // 2 (encoded IA5)
  3364. 2: (pwszDNSName: LPWSTR); // 3 (encoded IA5)
  3365. 3: ();// Not implemented x400Address; // 4
  3366. 4: (DirectoryName: CERT_NAME_BLOB); // 5
  3367. 5: ();// Not implemented pEdiPartyName; // 6
  3368. 6: (pwszURL: LPWSTR); // 7 (encoded IA5)
  3369. 7: (IPAddress: CRYPT_DATA_BLOB); // 8 (Octet String)
  3370. 8: (pszRegisteredID: LPSTR); // 9 (Object Identifer)
  3371. end;
  3372. {$EXTERNALSYM _CERT_ALT_NAME_ENTRY}
  3373. CERT_ALT_NAME_ENTRY = _CERT_ALT_NAME_ENTRY;
  3374. {$EXTERNALSYM CERT_ALT_NAME_ENTRY}
  3375. TCertAltNameEntry = CERT_ALT_NAME_ENTRY;
  3376. PCertAltNameEntry = PCERT_ALT_NAME_ENTRY;
  3377. const
  3378. CERT_ALT_NAME_OTHER_NAME = 1;
  3379. {$EXTERNALSYM CERT_ALT_NAME_OTHER_NAME}
  3380. CERT_ALT_NAME_RFC822_NAME = 2;
  3381. {$EXTERNALSYM CERT_ALT_NAME_RFC822_NAME}
  3382. CERT_ALT_NAME_DNS_NAME = 3;
  3383. {$EXTERNALSYM CERT_ALT_NAME_DNS_NAME}
  3384. CERT_ALT_NAME_X400_ADDRESS = 4;
  3385. {$EXTERNALSYM CERT_ALT_NAME_X400_ADDRESS}
  3386. CERT_ALT_NAME_DIRECTORY_NAME = 5;
  3387. {$EXTERNALSYM CERT_ALT_NAME_DIRECTORY_NAME}
  3388. CERT_ALT_NAME_EDI_PARTY_NAME = 6;
  3389. {$EXTERNALSYM CERT_ALT_NAME_EDI_PARTY_NAME}
  3390. CERT_ALT_NAME_URL = 7;
  3391. {$EXTERNALSYM CERT_ALT_NAME_URL}
  3392. CERT_ALT_NAME_IP_ADDRESS = 8;
  3393. {$EXTERNALSYM CERT_ALT_NAME_IP_ADDRESS}
  3394. CERT_ALT_NAME_REGISTERED_ID = 9;
  3395. {$EXTERNALSYM CERT_ALT_NAME_REGISTERED_ID}
  3396. type
  3397. PCERT_ALT_NAME_INFO = ^CERT_ALT_NAME_INFO;
  3398. {$EXTERNALSYM PCERT_ALT_NAME_INFO}
  3399. _CERT_ALT_NAME_INFO = record
  3400. cAltEntry: DWORD;
  3401. rgAltEntry: PCERT_ALT_NAME_ENTRY;
  3402. end;
  3403. {$EXTERNALSYM _CERT_ALT_NAME_INFO}
  3404. CERT_ALT_NAME_INFO = _CERT_ALT_NAME_INFO;
  3405. {$EXTERNALSYM CERT_ALT_NAME_INFO}
  3406. TCertAltNameInfo = CERT_ALT_NAME_INFO;
  3407. PCertAltNameInfo = PCERT_ALT_NAME_INFO;
  3408. //+-------------------------------------------------------------------------
  3409. // Alternate name IA5 Error Location Definitions for
  3410. // CRYPT_E_INVALID_IA5_STRING.
  3411. //
  3412. // Error location is returned in *pcbEncoded by
  3413. // CryptEncodeObject(X509_ALTERNATE_NAME)
  3414. //
  3415. // Error location consists of:
  3416. // ENTRY_INDEX - 8 bits << 16
  3417. // VALUE_INDEX - 16 bits (unicode character index)
  3418. //--------------------------------------------------------------------------
  3419. const
  3420. CERT_ALT_NAME_ENTRY_ERR_INDEX_MASK = $FF;
  3421. {$EXTERNALSYM CERT_ALT_NAME_ENTRY_ERR_INDEX_MASK}
  3422. CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT = 16;
  3423. {$EXTERNALSYM CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT}
  3424. CERT_ALT_NAME_VALUE_ERR_INDEX_MASK = $0000FFFF;
  3425. {$EXTERNALSYM CERT_ALT_NAME_VALUE_ERR_INDEX_MASK}
  3426. CERT_ALT_NAME_VALUE_ERR_INDEX_SHIFT = 0;
  3427. {$EXTERNALSYM CERT_ALT_NAME_VALUE_ERR_INDEX_SHIFT}
  3428. function GET_CERT_ALT_NAME_ENTRY_ERR_INDEX(X: DWORD): DWORD;
  3429. {$EXTERNALSYM GET_CERT_ALT_NAME_ENTRY_ERR_INDEX}
  3430. function GET_CERT_ALT_NAME_VALUE_ERR_INDEX(X: DWORD): DWORD;
  3431. {$EXTERNALSYM GET_CERT_ALT_NAME_VALUE_ERR_INDEX}
  3432. //+-------------------------------------------------------------------------
  3433. // X509_BASIC_CONSTRAINTS
  3434. // szOID_BASIC_CONSTRAINTS
  3435. //
  3436. // pvStructInfo points to following CERT_BASIC_CONSTRAINTS_INFO.
  3437. //--------------------------------------------------------------------------
  3438. type
  3439. PCERT_BASIC_CONSTRAINTS_INFO = ^CERT_BASIC_CONSTRAINTS_INFO;
  3440. {$EXTERNALSYM PCERT_BASIC_CONSTRAINTS_INFO}
  3441. _CERT_BASIC_CONSTRAINTS_INFO = record
  3442. SubjectType: CRYPT_BIT_BLOB;
  3443. fPathLenConstraint: BOOL;
  3444. dwPathLenConstraint: DWORD;
  3445. cSubtreesConstraint: DWORD;
  3446. rgSubtreesConstraint: PCERT_NAME_BLOB;
  3447. end;
  3448. {$EXTERNALSYM _CERT_BASIC_CONSTRAINTS_INFO}
  3449. CERT_BASIC_CONSTRAINTS_INFO = _CERT_BASIC_CONSTRAINTS_INFO;
  3450. {$EXTERNALSYM CERT_BASIC_CONSTRAINTS_INFO}
  3451. TCertBasicConstraintsInfo = CERT_BASIC_CONSTRAINTS_INFO;
  3452. PCertBasicConstraintsInfo = PCERT_BASIC_CONSTRAINTS_INFO;
  3453. const
  3454. CERT_CA_SUBJECT_FLAG = $80;
  3455. {$EXTERNALSYM CERT_CA_SUBJECT_FLAG}
  3456. CERT_END_ENTITY_SUBJECT_FLAG = $40;
  3457. {$EXTERNALSYM CERT_END_ENTITY_SUBJECT_FLAG}
  3458. //+-------------------------------------------------------------------------
  3459. // X509_BASIC_CONSTRAINTS2
  3460. // szOID_BASIC_CONSTRAINTS2
  3461. //
  3462. // pvStructInfo points to following CERT_BASIC_CONSTRAINTS2_INFO.
  3463. //--------------------------------------------------------------------------
  3464. type
  3465. PCERT_BASIC_CONSTRAINTS2_INFO = ^CERT_BASIC_CONSTRAINTS2_INFO;
  3466. {$EXTERNALSYM PCERT_BASIC_CONSTRAINTS2_INFO}
  3467. _CERT_BASIC_CONSTRAINTS2_INFO = record
  3468. fCA: BOOL;
  3469. fPathLenConstraint: BOOL;
  3470. dwPathLenConstraint: DWORD;
  3471. end;
  3472. {$EXTERNALSYM _CERT_BASIC_CONSTRAINTS2_INFO}
  3473. CERT_BASIC_CONSTRAINTS2_INFO = _CERT_BASIC_CONSTRAINTS2_INFO;
  3474. {$EXTERNALSYM CERT_BASIC_CONSTRAINTS2_INFO}
  3475. TCertBasicConstraints2Info = CERT_BASIC_CONSTRAINTS2_INFO;
  3476. PCertBasicConstraints2Info = PCERT_BASIC_CONSTRAINTS2_INFO;
  3477. //+-------------------------------------------------------------------------
  3478. // X509_KEY_USAGE
  3479. // szOID_KEY_USAGE
  3480. //
  3481. // pvStructInfo points to a CRYPT_BIT_BLOB. Has same bit definitions as
  3482. // CERT_KEY_ATTRIBUTES_INFO's IntendedKeyUsage.
  3483. //--------------------------------------------------------------------------
  3484. //+-------------------------------------------------------------------------
  3485. // X509_CERT_POLICIES
  3486. // szOID_CERT_POLICIES
  3487. // szOID_CERT_POLICIES_95 NOTE--Only allowed for decoding!!!
  3488. //
  3489. // pvStructInfo points to following CERT_POLICIES_INFO.
  3490. //
  3491. // NOTE: when decoding using szOID_CERT_POLICIES_95 the pszPolicyIdentifier
  3492. // may contain an empty string
  3493. //--------------------------------------------------------------------------
  3494. PCERT_POLICY_QUALIFIER_INFO = ^CERT_POLICY_QUALIFIER_INFO;
  3495. {$EXTERNALSYM PCERT_POLICY_QUALIFIER_INFO}
  3496. _CERT_POLICY_QUALIFIER_INFO = record
  3497. pszPolicyQualifierId: LPSTR; // pszObjId
  3498. Qualifier: CRYPT_OBJID_BLOB; // optional
  3499. end;
  3500. {$EXTERNALSYM _CERT_POLICY_QUALIFIER_INFO}
  3501. CERT_POLICY_QUALIFIER_INFO = _CERT_POLICY_QUALIFIER_INFO;
  3502. {$EXTERNALSYM CERT_POLICY_QUALIFIER_INFO}
  3503. TCertPolicyQualifierInfo = CERT_POLICY_QUALIFIER_INFO;
  3504. PCertPolicyQualifierInfo = PCERT_POLICY_QUALIFIER_INFO;
  3505. PCERT_POLICY_INFO = ^CERT_POLICY_INFO;
  3506. {$EXTERNALSYM PCERT_POLICY_INFO}
  3507. _CERT_POLICY_INFO = record
  3508. pszPolicyIdentifier: LPSTR; // pszObjId
  3509. cPolicyQualifier: DWORD; // optional
  3510. rgPolicyQualifier: PCERT_POLICY_QUALIFIER_INFO;
  3511. end;
  3512. {$EXTERNALSYM _CERT_POLICY_INFO}
  3513. CERT_POLICY_INFO = _CERT_POLICY_INFO;
  3514. {$EXTERNALSYM CERT_POLICY_INFO}
  3515. TCertPolicyInfo = CERT_POLICY_INFO;
  3516. PCertPolicyInfo = PCERT_POLICY_INFO;
  3517. PCERT_POLICIES_INFO = ^CERT_POLICIES_INFO;
  3518. {$EXTERNALSYM PCERT_POLICIES_INFO}
  3519. _CERT_POLICIES_INFO = record
  3520. cPolicyInfo: DWORD;
  3521. rgPolicyInfo: PCERT_POLICY_INFO;
  3522. end;
  3523. {$EXTERNALSYM _CERT_POLICIES_INFO}
  3524. CERT_POLICIES_INFO = _CERT_POLICIES_INFO;
  3525. {$EXTERNALSYM CERT_POLICIES_INFO}
  3526. TCertPoliciesInfo = CERT_POLICIES_INFO;
  3527. PCertPoliciesInfo = PCERT_POLICIES_INFO;
  3528. //+-------------------------------------------------------------------------
  3529. // X509_PKIX_POLICY_QUALIFIER_USERNOTICE
  3530. // szOID_PKIX_POLICY_QUALIFIER_USERNOTICE
  3531. //
  3532. // pvStructInfo points to following CERT_POLICY_QUALIFIER_USER_NOTICE.
  3533. //
  3534. //--------------------------------------------------------------------------
  3535. PCERT_POLICY_QUALIFIER_NOTICE_REFERENCE = ^CERT_POLICY_QUALIFIER_NOTICE_REFERENCE;
  3536. {$EXTERNALSYM PCERT_POLICY_QUALIFIER_NOTICE_REFERENCE}
  3537. _CERT_POLICY_QUALIFIER_NOTICE_REFERENCE = record
  3538. pszOrganization: LPSTR;
  3539. cNoticeNumbers: DWORD;
  3540. rgNoticeNumbers: LPINT;
  3541. end;
  3542. {$EXTERNALSYM _CERT_POLICY_QUALIFIER_NOTICE_REFERENCE}
  3543. CERT_POLICY_QUALIFIER_NOTICE_REFERENCE = _CERT_POLICY_QUALIFIER_NOTICE_REFERENCE;
  3544. {$EXTERNALSYM CERT_POLICY_QUALIFIER_NOTICE_REFERENCE}
  3545. TCertPolicyQualifierNoticeReference = CERT_POLICY_QUALIFIER_NOTICE_REFERENCE;
  3546. PCertPolicyQualifierNoticeReference = PCERT_POLICY_QUALIFIER_NOTICE_REFERENCE;
  3547. PCERT_POLICY_QUALIFIER_USER_NOTICE = ^CERT_POLICY_QUALIFIER_USER_NOTICE;
  3548. {$EXTERNALSYM PCERT_POLICY_QUALIFIER_USER_NOTICE}
  3549. _CERT_POLICY_QUALIFIER_USER_NOTICE = record
  3550. pNoticeReference: PCERT_POLICY_QUALIFIER_NOTICE_REFERENCE; // optional
  3551. pszDisplayText: LPWSTR; // optional
  3552. end;
  3553. {$EXTERNALSYM _CERT_POLICY_QUALIFIER_USER_NOTICE}
  3554. CERT_POLICY_QUALIFIER_USER_NOTICE = _CERT_POLICY_QUALIFIER_USER_NOTICE;
  3555. {$EXTERNALSYM CERT_POLICY_QUALIFIER_USER_NOTICE}
  3556. TCertPolicyQualifierUserNotice = CERT_POLICY_QUALIFIER_USER_NOTICE;
  3557. PCertPolicyQualifierUserNotice = PCERT_POLICY_QUALIFIER_USER_NOTICE;
  3558. //+-------------------------------------------------------------------------
  3559. // szOID_CERT_POLICIES_95_QUALIFIER1 - Decode Only!!!!
  3560. //
  3561. // pvStructInfo points to following CERT_POLICY95_QUALIFIER1.
  3562. //
  3563. //--------------------------------------------------------------------------
  3564. PCPS_URLS = ^CPS_URLS;
  3565. {$EXTERNALSYM PCPS_URLS}
  3566. _CPS_URLS = record
  3567. pszURL: LPWSTR;
  3568. pAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER; // optional
  3569. pDigest: PCRYPT_DATA_BLOB; // optional
  3570. end;
  3571. {$EXTERNALSYM _CPS_URLS}
  3572. CPS_URLS = _CPS_URLS;
  3573. {$EXTERNALSYM CPS_URLS}
  3574. TCpsUrls = CPS_URLS;
  3575. PCpsUrls = PCPS_URLS;
  3576. PCERT_POLICY95_QUALIFIER1 = ^CERT_POLICY95_QUALIFIER1;
  3577. {$EXTERNALSYM PCERT_POLICY95_QUALIFIER1}
  3578. _CERT_POLICY95_QUALIFIER1 = record
  3579. pszPracticesReference: LPWSTR; // optional
  3580. pszNoticeIdentifier: LPSTR; // optional
  3581. pszNSINoticeIdentifier: LPSTR; // optional
  3582. cCPSURLs: DWORD;
  3583. rgCPSURLs: PCPS_URLS; // optional
  3584. end;
  3585. {$EXTERNALSYM _CERT_POLICY95_QUALIFIER1}
  3586. CERT_POLICY95_QUALIFIER1 = _CERT_POLICY95_QUALIFIER1;
  3587. {$EXTERNALSYM CERT_POLICY95_QUALIFIER1}
  3588. TCertPolicy95Qualifier1 = CERT_POLICY95_QUALIFIER1;
  3589. PCertPolicy95Qualifier1 = PCERT_POLICY95_QUALIFIER1;
  3590. //+-------------------------------------------------------------------------
  3591. // RSA_CSP_PUBLICKEYBLOB
  3592. //
  3593. // pvStructInfo points to a PUBLICKEYSTRUC immediately followed by a
  3594. // RSAPUBKEY and the modulus bytes.
  3595. //
  3596. // CryptExportKey outputs the above StructInfo for a dwBlobType of
  3597. // PUBLICKEYBLOB. CryptImportKey expects the above StructInfo when
  3598. // importing a public key.
  3599. //
  3600. // For dwCertEncodingType = X509_ASN_ENCODING, the RSA_CSP_PUBLICKEYBLOB is
  3601. // encoded as a PKCS #1 RSAPublicKey consisting of a SEQUENCE of a
  3602. // modulus INTEGER and a publicExponent INTEGER. The modulus is encoded
  3603. // as being a unsigned integer. When decoded, if the modulus was encoded
  3604. // as unsigned integer with a leading 0 byte, the 0 byte is removed before
  3605. // converting to the CSP modulus bytes.
  3606. //
  3607. // For decode, the aiKeyAlg field of PUBLICKEYSTRUC is always set to
  3608. // CALG_RSA_KEYX.
  3609. //--------------------------------------------------------------------------
  3610. //+-------------------------------------------------------------------------
  3611. // X509_KEYGEN_REQUEST_TO_BE_SIGNED
  3612. //
  3613. // pvStructInfo points to CERT_KEYGEN_REQUEST_INFO.
  3614. //
  3615. // For CryptDecodeObject(), the pbEncoded is the "to be signed" plus its
  3616. // signature (output of a X509_CERT CryptEncodeObject()).
  3617. //
  3618. // For CryptEncodeObject(), the pbEncoded is just the "to be signed".
  3619. //--------------------------------------------------------------------------
  3620. //+-------------------------------------------------------------------------
  3621. // PKCS_ATTRIBUTE data structure
  3622. //
  3623. // pvStructInfo points to a CRYPT_ATTRIBUTE.
  3624. //--------------------------------------------------------------------------
  3625. //+-------------------------------------------------------------------------
  3626. // PKCS_ATTRIBUTES data structure
  3627. //
  3628. // pvStructInfo points to a CRYPT_ATTRIBUTES.
  3629. //--------------------------------------------------------------------------
  3630. //+-------------------------------------------------------------------------
  3631. // PKCS_CONTENT_INFO_SEQUENCE_OF_ANY data structure
  3632. //
  3633. // pvStructInfo points to following CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY.
  3634. //
  3635. // For X509_ASN_ENCODING: encoded as a PKCS#7 ContentInfo structure wrapping
  3636. // a sequence of ANY. The value of the contentType field is pszObjId,
  3637. // while the content field is the following structure:
  3638. // SequenceOfAny ::= SEQUENCE OF ANY
  3639. //
  3640. // The CRYPT_DER_BLOBs point to the already encoded ANY content.
  3641. //--------------------------------------------------------------------------
  3642. PCRYPT_CONTENT_INFO_SEQUENCE_OF_ANY = ^CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY;
  3643. {$EXTERNALSYM PCRYPT_CONTENT_INFO_SEQUENCE_OF_ANY}
  3644. _CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY = record
  3645. pszObjId: LPSTR;
  3646. cValue: DWORD;
  3647. rgValue: PCRYPT_DER_BLOB;
  3648. end;
  3649. {$EXTERNALSYM _CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY}
  3650. CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY = _CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY;
  3651. {$EXTERNALSYM CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY}
  3652. TCryptContentInfoSequenceOfAny = CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY;
  3653. PCryptContentInfoSequenceOfAny = PCRYPT_CONTENT_INFO_SEQUENCE_OF_ANY;
  3654. //+-------------------------------------------------------------------------
  3655. // PKCS_CONTENT_INFO data structure
  3656. //
  3657. // pvStructInfo points to following CRYPT_CONTENT_INFO.
  3658. //
  3659. // For X509_ASN_ENCODING: encoded as a PKCS#7 ContentInfo structure.
  3660. // The CRYPT_DER_BLOB points to the already encoded ANY content.
  3661. //--------------------------------------------------------------------------
  3662. PCRYPT_CONTENT_INFO = ^CRYPT_CONTENT_INFO;
  3663. {$EXTERNALSYM PCRYPT_CONTENT_INFO}
  3664. _CRYPT_CONTENT_INFO = record
  3665. pszObjId: LPSTR;
  3666. Content: CRYPT_DER_BLOB;
  3667. end;
  3668. {$EXTERNALSYM _CRYPT_CONTENT_INFO}
  3669. CRYPT_CONTENT_INFO = _CRYPT_CONTENT_INFO;
  3670. {$EXTERNALSYM CRYPT_CONTENT_INFO}
  3671. TCryptContentInfo = CRYPT_CONTENT_INFO;
  3672. PCryptContentInfo = PCRYPT_CONTENT_INFO;
  3673. //+-------------------------------------------------------------------------
  3674. // X509_OCTET_STRING data structure
  3675. //
  3676. // pvStructInfo points to a CRYPT_DATA_BLOB.
  3677. //--------------------------------------------------------------------------
  3678. //+-------------------------------------------------------------------------
  3679. // X509_BITS data structure
  3680. //
  3681. // pvStructInfo points to a CRYPT_BIT_BLOB.
  3682. //--------------------------------------------------------------------------
  3683. //+-------------------------------------------------------------------------
  3684. // X509_BITS_WITHOUT_TRAILING_ZEROES data structure
  3685. //
  3686. // pvStructInfo points to a CRYPT_BIT_BLOB.
  3687. //
  3688. // The same as X509_BITS, except before encoding, the bit length is
  3689. // decremented to exclude trailing zero bits.
  3690. //--------------------------------------------------------------------------
  3691. //+-------------------------------------------------------------------------
  3692. // X509_INTEGER data structure
  3693. //
  3694. // pvStructInfo points to an int.
  3695. //--------------------------------------------------------------------------
  3696. //+-------------------------------------------------------------------------
  3697. // X509_MULTI_BYTE_INTEGER data structure
  3698. //
  3699. // pvStructInfo points to a CRYPT_INTEGER_BLOB.
  3700. //--------------------------------------------------------------------------
  3701. //+-------------------------------------------------------------------------
  3702. // X509_ENUMERATED data structure
  3703. //
  3704. // pvStructInfo points to an int containing the enumerated value
  3705. //--------------------------------------------------------------------------
  3706. //+-------------------------------------------------------------------------
  3707. // X509_CHOICE_OF_TIME data structure
  3708. //
  3709. // pvStructInfo points to a FILETIME.
  3710. //--------------------------------------------------------------------------
  3711. //+-------------------------------------------------------------------------
  3712. // X509_SEQUENCE_OF_ANY data structure
  3713. //
  3714. // pvStructInfo points to following CRYPT_SEQUENCE_OF_ANY.
  3715. //
  3716. // The CRYPT_DER_BLOBs point to the already encoded ANY content.
  3717. //--------------------------------------------------------------------------
  3718. PCRYPT_SEQUENCE_OF_ANY = ^CRYPT_SEQUENCE_OF_ANY;
  3719. {$EXTERNALSYM PCRYPT_SEQUENCE_OF_ANY}
  3720. _CRYPT_SEQUENCE_OF_ANY = record
  3721. cValue: DWORD;
  3722. rgValue: PCRYPT_DER_BLOB;
  3723. end;
  3724. {$EXTERNALSYM _CRYPT_SEQUENCE_OF_ANY}
  3725. CRYPT_SEQUENCE_OF_ANY = _CRYPT_SEQUENCE_OF_ANY;
  3726. {$EXTERNALSYM CRYPT_SEQUENCE_OF_ANY}
  3727. TCryptSequenceOfAny = CRYPT_SEQUENCE_OF_ANY;
  3728. PCryptSequenceOfAny = PCRYPT_SEQUENCE_OF_ANY;
  3729. //+-------------------------------------------------------------------------
  3730. // X509_AUTHORITY_KEY_ID2
  3731. // szOID_AUTHORITY_KEY_IDENTIFIER2
  3732. //
  3733. // pvStructInfo points to following CERT_AUTHORITY_KEY_ID2_INFO.
  3734. //
  3735. // For CRYPT_E_INVALID_IA5_STRING, the error location is returned in
  3736. // *pcbEncoded by CryptEncodeObject(X509_AUTHORITY_KEY_ID2)
  3737. //
  3738. // See X509_ALTERNATE_NAME for error location defines.
  3739. //--------------------------------------------------------------------------
  3740. PCERT_AUTHORITY_KEY_ID2_INFO = ^CERT_AUTHORITY_KEY_ID2_INFO;
  3741. {$EXTERNALSYM PCERT_AUTHORITY_KEY_ID2_INFO}
  3742. _CERT_AUTHORITY_KEY_ID2_INFO = record
  3743. KeyId: CRYPT_DATA_BLOB;
  3744. AuthorityCertIssuer: CERT_ALT_NAME_INFO; // Optional, set cAltEntry
  3745. // to 0 to omit.
  3746. AuthorityCertSerialNumber: CRYPT_INTEGER_BLOB;
  3747. end;
  3748. {$EXTERNALSYM _CERT_AUTHORITY_KEY_ID2_INFO}
  3749. CERT_AUTHORITY_KEY_ID2_INFO = _CERT_AUTHORITY_KEY_ID2_INFO;
  3750. {$EXTERNALSYM CERT_AUTHORITY_KEY_ID2_INFO}
  3751. TCertAuthorityKeyId2Info = CERT_AUTHORITY_KEY_ID2_INFO;
  3752. PCertAuthorityKeyId2Info = PCERT_AUTHORITY_KEY_ID2_INFO;
  3753. //+-------------------------------------------------------------------------
  3754. // szOID_SUBJECT_KEY_IDENTIFIER
  3755. //
  3756. // pvStructInfo points to a CRYPT_DATA_BLOB.
  3757. //--------------------------------------------------------------------------
  3758. //+-------------------------------------------------------------------------
  3759. // X509_AUTHORITY_INFO_ACCESS
  3760. // szOID_AUTHORITY_INFO_ACCESS
  3761. //
  3762. // pvStructInfo points to following CERT_AUTHORITY_INFO_ACCESS.
  3763. //
  3764. // For CRYPT_E_INVALID_IA5_STRING, the error location is returned in
  3765. // *pcbEncoded by CryptEncodeObject(X509_AUTHORITY_INFO_ACCESS)
  3766. //
  3767. // Error location consists of:
  3768. // ENTRY_INDEX - 8 bits << 16
  3769. // VALUE_INDEX - 16 bits (unicode character index)
  3770. //
  3771. // See X509_ALTERNATE_NAME for ENTRY_INDEX and VALUE_INDEX error location
  3772. // defines.
  3773. //--------------------------------------------------------------------------
  3774. PCERT_ACCESS_DESCRIPTION = ^CERT_ACCESS_DESCRIPTION;
  3775. {$EXTERNALSYM PCERT_ACCESS_DESCRIPTION}
  3776. _CERT_ACCESS_DESCRIPTION = record
  3777. pszAccessMethod: LPSTR; // pszObjId
  3778. AccessLocation: CERT_ALT_NAME_ENTRY;
  3779. end;
  3780. {$EXTERNALSYM _CERT_ACCESS_DESCRIPTION}
  3781. CERT_ACCESS_DESCRIPTION = _CERT_ACCESS_DESCRIPTION;
  3782. {$EXTERNALSYM CERT_ACCESS_DESCRIPTION}
  3783. TCertAccessDescription = CERT_ACCESS_DESCRIPTION;
  3784. PCertAccessDescription = PCERT_ACCESS_DESCRIPTION;
  3785. PCERT_AUTHORITY_INFO_ACCESS = ^CERT_AUTHORITY_INFO_ACCESS;
  3786. {$EXTERNALSYM PCERT_AUTHORITY_INFO_ACCESS}
  3787. _CERT_AUTHORITY_INFO_ACCESS = record
  3788. cAccDescr: DWORD;
  3789. rgAccDescr: PCERT_ACCESS_DESCRIPTION;
  3790. end;
  3791. {$EXTERNALSYM _CERT_AUTHORITY_INFO_ACCESS}
  3792. CERT_AUTHORITY_INFO_ACCESS = _CERT_AUTHORITY_INFO_ACCESS;
  3793. {$EXTERNALSYM CERT_AUTHORITY_INFO_ACCESS}
  3794. TCertAuthorityInfoAccess = CERT_AUTHORITY_INFO_ACCESS;
  3795. PCertAuthorityInfoAccess = PCERT_AUTHORITY_INFO_ACCESS;
  3796. //+-------------------------------------------------------------------------
  3797. // PKIX Access Description: Access Method Object Identifiers
  3798. //--------------------------------------------------------------------------
  3799. const
  3800. szOID_PKIX_ACC_DESCR = '1.3.6.1.5.5.7.48';
  3801. {$EXTERNALSYM szOID_PKIX_ACC_DESCR}
  3802. szOID_PKIX_OCSP = '1.3.6.1.5.5.7.48.1';
  3803. {$EXTERNALSYM szOID_PKIX_OCSP}
  3804. szOID_PKIX_CA_ISSUERS = '1.3.6.1.5.5.7.48.2';
  3805. {$EXTERNALSYM szOID_PKIX_CA_ISSUERS}
  3806. //+-------------------------------------------------------------------------
  3807. // X509_CRL_REASON_CODE
  3808. // szOID_CRL_REASON_CODE
  3809. //
  3810. // pvStructInfo points to an int which can be set to one of the following
  3811. // enumerated values:
  3812. //--------------------------------------------------------------------------
  3813. CRL_REASON_UNSPECIFIED = 0;
  3814. {$EXTERNALSYM CRL_REASON_UNSPECIFIED}
  3815. CRL_REASON_KEY_COMPROMISE = 1;
  3816. {$EXTERNALSYM CRL_REASON_KEY_COMPROMISE}
  3817. CRL_REASON_CA_COMPROMISE = 2;
  3818. {$EXTERNALSYM CRL_REASON_CA_COMPROMISE}
  3819. CRL_REASON_AFFILIATION_CHANGED = 3;
  3820. {$EXTERNALSYM CRL_REASON_AFFILIATION_CHANGED}
  3821. CRL_REASON_SUPERSEDED = 4;
  3822. {$EXTERNALSYM CRL_REASON_SUPERSEDED}
  3823. CRL_REASON_CESSATION_OF_OPERATION = 5;
  3824. {$EXTERNALSYM CRL_REASON_CESSATION_OF_OPERATION}
  3825. CRL_REASON_CERTIFICATE_HOLD = 6;
  3826. {$EXTERNALSYM CRL_REASON_CERTIFICATE_HOLD}
  3827. CRL_REASON_REMOVE_FROM_CRL = 8;
  3828. {$EXTERNALSYM CRL_REASON_REMOVE_FROM_CRL}
  3829. //+-------------------------------------------------------------------------
  3830. // X509_CRL_DIST_POINTS
  3831. // szOID_CRL_DIST_POINTS
  3832. //
  3833. // pvStructInfo points to following CRL_DIST_POINTS_INFO.
  3834. //
  3835. // For CRYPT_E_INVALID_IA5_STRING, the error location is returned in
  3836. // *pcbEncoded by CryptEncodeObject(X509_CRL_DIST_POINTS)
  3837. //
  3838. // Error location consists of:
  3839. // CRL_ISSUER_BIT - 1 bit << 31 (0 for FullName, 1 for CRLIssuer)
  3840. // POINT_INDEX - 7 bits << 24
  3841. // ENTRY_INDEX - 8 bits << 16
  3842. // VALUE_INDEX - 16 bits (unicode character index)
  3843. //
  3844. // See X509_ALTERNATE_NAME for ENTRY_INDEX and VALUE_INDEX error location
  3845. // defines.
  3846. //--------------------------------------------------------------------------
  3847. type
  3848. PCRL_DIST_POINT_NAME = ^CRL_DIST_POINT_NAME;
  3849. {$EXTERNALSYM PCRL_DIST_POINT_NAME}
  3850. _CRL_DIST_POINT_NAME = record
  3851. dwDistPointNameChoice: DWORD;
  3852. case Integer of
  3853. 0: (FullName: CERT_ALT_NAME_INFO); // 1
  3854. 1: ();// Not implemented IssuerRDN; // 2
  3855. end;
  3856. {$EXTERNALSYM _CRL_DIST_POINT_NAME}
  3857. CRL_DIST_POINT_NAME = _CRL_DIST_POINT_NAME;
  3858. {$EXTERNALSYM CRL_DIST_POINT_NAME}
  3859. TCrlDistPointName = CRL_DIST_POINT_NAME;
  3860. PCrlDistPointName = PCRL_DIST_POINT_NAME;
  3861. const
  3862. CRL_DIST_POINT_NO_NAME = 0;
  3863. {$EXTERNALSYM CRL_DIST_POINT_NO_NAME}
  3864. CRL_DIST_POINT_FULL_NAME = 1;
  3865. {$EXTERNALSYM CRL_DIST_POINT_FULL_NAME}
  3866. CRL_DIST_POINT_ISSUER_RDN_NAME = 2;
  3867. {$EXTERNALSYM CRL_DIST_POINT_ISSUER_RDN_NAME}
  3868. type
  3869. PCRL_DIST_POINT = ^CRL_DIST_POINT;
  3870. {$EXTERNALSYM PCRL_DIST_POINT}
  3871. _CRL_DIST_POINT = record
  3872. DistPointName: CRL_DIST_POINT_NAME; // OPTIONAL
  3873. ReasonFlags: CRYPT_BIT_BLOB; // OPTIONAL
  3874. CRLIssuer: CERT_ALT_NAME_INFO; // OPTIONAL
  3875. end;
  3876. {$EXTERNALSYM _CRL_DIST_POINT}
  3877. CRL_DIST_POINT = _CRL_DIST_POINT;
  3878. {$EXTERNALSYM CRL_DIST_POINT}
  3879. TCrlDistPoint = CRL_DIST_POINT;
  3880. PCrlDistPoint = PCRL_DIST_POINT;
  3881. const
  3882. CRL_REASON_UNUSED_FLAG = $80;
  3883. {$EXTERNALSYM CRL_REASON_UNUSED_FLAG}
  3884. CRL_REASON_KEY_COMPROMISE_FLAG = $40;
  3885. {$EXTERNALSYM CRL_REASON_KEY_COMPROMISE_FLAG}
  3886. CRL_REASON_CA_COMPROMISE_FLAG = $20;
  3887. {$EXTERNALSYM CRL_REASON_CA_COMPROMISE_FLAG}
  3888. CRL_REASON_AFFILIATION_CHANGED_FLAG = $10;
  3889. {$EXTERNALSYM CRL_REASON_AFFILIATION_CHANGED_FLAG}
  3890. CRL_REASON_SUPERSEDED_FLAG = $08;
  3891. {$EXTERNALSYM CRL_REASON_SUPERSEDED_FLAG}
  3892. CRL_REASON_CESSATION_OF_OPERATION_FLAG = $04;
  3893. {$EXTERNALSYM CRL_REASON_CESSATION_OF_OPERATION_FLAG}
  3894. CRL_REASON_CERTIFICATE_HOLD_FLAG = $02;
  3895. {$EXTERNALSYM CRL_REASON_CERTIFICATE_HOLD_FLAG}
  3896. type
  3897. PCRL_DIST_POINTS_INFO = ^CRL_DIST_POINTS_INFO;
  3898. {$EXTERNALSYM PCRL_DIST_POINTS_INFO}
  3899. _CRL_DIST_POINTS_INFO = record
  3900. cDistPoint: DWORD;
  3901. rgDistPoint: PCRL_DIST_POINT;
  3902. end;
  3903. {$EXTERNALSYM _CRL_DIST_POINTS_INFO}
  3904. CRL_DIST_POINTS_INFO = _CRL_DIST_POINTS_INFO;
  3905. {$EXTERNALSYM CRL_DIST_POINTS_INFO}
  3906. TCrlDistPointsInfo = CRL_DIST_POINTS_INFO;
  3907. PCrlDistPointsInfo = PCRL_DIST_POINTS_INFO;
  3908. const
  3909. CRL_DIST_POINT_ERR_INDEX_MASK = $7F;
  3910. {$EXTERNALSYM CRL_DIST_POINT_ERR_INDEX_MASK}
  3911. CRL_DIST_POINT_ERR_INDEX_SHIFT = 24;
  3912. {$EXTERNALSYM CRL_DIST_POINT_ERR_INDEX_SHIFT}
  3913. function GET_CRL_DIST_POINT_ERR_INDEX(X: DWORD): DWORD;
  3914. {$EXTERNALSYM GET_CRL_DIST_POINT_ERR_INDEX}
  3915. const
  3916. CRL_DIST_POINT_ERR_CRL_ISSUER_BIT = DWORD($80000000);
  3917. {$EXTERNALSYM CRL_DIST_POINT_ERR_CRL_ISSUER_BIT}
  3918. function IS_CRL_DIST_POINT_ERR_CRL_ISSUER(X: DWORD): Boolean;
  3919. {$EXTERNALSYM IS_CRL_DIST_POINT_ERR_CRL_ISSUER}
  3920. //+-------------------------------------------------------------------------
  3921. // X509_ENHANCED_KEY_USAGE
  3922. // szOID_ENHANCED_KEY_USAGE
  3923. //
  3924. // pvStructInfo points to a CERT_ENHKEY_USAGE, CTL_USAGE.
  3925. //--------------------------------------------------------------------------
  3926. //+-------------------------------------------------------------------------
  3927. // szOID_NEXT_UPDATE_LOCATION
  3928. //
  3929. // pvStructInfo points to a CERT_ALT_NAME_INFO.
  3930. //--------------------------------------------------------------------------
  3931. //+-------------------------------------------------------------------------
  3932. // PKCS_CTL
  3933. // szOID_CTL
  3934. //
  3935. // pvStructInfo points to a CTL_INFO.
  3936. //--------------------------------------------------------------------------
  3937. //+-------------------------------------------------------------------------
  3938. // PKCS_SORTED_CTL
  3939. //
  3940. // pvStructInfo points to a CTL_INFO.
  3941. //
  3942. // Same as for PKCS_CTL, except, the CTL entries are sorted. The following
  3943. // extension containing the sort information is inserted as the first
  3944. // extension in the encoded CTL.
  3945. //
  3946. // Only supported for Encoding. CRYPT_ENCODE_ALLOC_FLAG flag must be
  3947. // set.
  3948. //--------------------------------------------------------------------------
  3949. //+-------------------------------------------------------------------------
  3950. // Sorted CTL TrustedSubjects extension
  3951. //
  3952. // Array of little endian DWORDs:
  3953. // [0] - Flags
  3954. // [1] - Count of HashBucket entry offsets
  3955. // [2] - Maximum HashBucket entry collision count
  3956. // [3 ..] (Count + 1) HashBucket entry offsets
  3957. //
  3958. // When this extension is present in the CTL,
  3959. // the ASN.1 encoded sequence of TrustedSubjects are HashBucket ordered.
  3960. //
  3961. // The entry offsets point to the start of the first encoded TrustedSubject
  3962. // sequence for the HashBucket. The encoded TrustedSubjects for a HashBucket
  3963. // continue until the encoded offset of the next HashBucket. A HashBucket has
  3964. // no entries if HashBucket[N] == HashBucket[N + 1].
  3965. //
  3966. // The HashBucket offsets are from the start of the ASN.1 encoded CTL_INFO.
  3967. //--------------------------------------------------------------------------
  3968. const
  3969. SORTED_CTL_EXT_FLAGS_OFFSET = 0 * 4;
  3970. {$EXTERNALSYM SORTED_CTL_EXT_FLAGS_OFFSET}
  3971. SORTED_CTL_EXT_COUNT_OFFSET = 1 * 4;
  3972. {$EXTERNALSYM SORTED_CTL_EXT_COUNT_OFFSET}
  3973. SORTED_CTL_EXT_MAX_COLLISION_OFFSET = 2 * 4;
  3974. {$EXTERNALSYM SORTED_CTL_EXT_MAX_COLLISION_OFFSET}
  3975. SORTED_CTL_EXT_HASH_BUCKET_OFFSET = 3 * 4;
  3976. {$EXTERNALSYM SORTED_CTL_EXT_HASH_BUCKET_OFFSET}
  3977. // If the SubjectIdentifiers are a MD5 or SHA1 hash, the following flag is
  3978. // set. When set, the first 4 bytes of the SubjectIdentifier are used as
  3979. // the dwhash. Otherwise, the SubjectIdentifier bytes are hashed into dwHash.
  3980. // In either case the HashBucket index = dwHash % cHashBucket.
  3981. SORTED_CTL_EXT_HASHED_SUBJECT_IDENTIFIER_FLAG = $1;
  3982. {$EXTERNALSYM SORTED_CTL_EXT_HASHED_SUBJECT_IDENTIFIER_FLAG}
  3983. //+-------------------------------------------------------------------------
  3984. // X509_MULTI_BYTE_UINT
  3985. //
  3986. // pvStructInfo points to a CRYPT_UINT_BLOB. Before encoding, inserts a
  3987. // leading 0x00. After decoding, removes a leading 0x00.
  3988. //--------------------------------------------------------------------------
  3989. //+-------------------------------------------------------------------------
  3990. // X509_DSS_PUBLICKEY
  3991. //
  3992. // pvStructInfo points to a CRYPT_UINT_BLOB.
  3993. //--------------------------------------------------------------------------
  3994. //+-------------------------------------------------------------------------
  3995. // X509_DSS_PARAMETERS
  3996. //
  3997. // pvStructInfo points to following CERT_DSS_PARAMETERS data structure.
  3998. //--------------------------------------------------------------------------
  3999. type
  4000. PCERT_DSS_PARAMETERS = ^CERT_DSS_PARAMETERS;
  4001. {$EXTERNALSYM PCERT_DSS_PARAMETERS}
  4002. _CERT_DSS_PARAMETERS = record
  4003. p: CRYPT_UINT_BLOB;
  4004. q: CRYPT_UINT_BLOB;
  4005. g: CRYPT_UINT_BLOB;
  4006. end;
  4007. {$EXTERNALSYM _CERT_DSS_PARAMETERS}
  4008. CERT_DSS_PARAMETERS = _CERT_DSS_PARAMETERS;
  4009. {$EXTERNALSYM CERT_DSS_PARAMETERS}
  4010. TCertDssParameters = CERT_DSS_PARAMETERS;
  4011. PCertDssParameters = PCERT_DSS_PARAMETERS;
  4012. //+-------------------------------------------------------------------------
  4013. // X509_DSS_SIGNATURE
  4014. //
  4015. // pvStructInfo is a BYTE rgbSignature[CERT_DSS_SIGNATURE_LEN]. The
  4016. // bytes are ordered as output by the DSS CSP's CryptSignHash().
  4017. //--------------------------------------------------------------------------
  4018. const
  4019. CERT_DSS_R_LEN = 20;
  4020. {$EXTERNALSYM CERT_DSS_R_LEN}
  4021. CERT_DSS_S_LEN = 20;
  4022. {$EXTERNALSYM CERT_DSS_S_LEN}
  4023. CERT_DSS_SIGNATURE_LEN = CERT_DSS_R_LEN + CERT_DSS_S_LEN;
  4024. {$EXTERNALSYM CERT_DSS_SIGNATURE_LEN}
  4025. // Sequence of 2 unsigned integers (the extra +1 is for a potential leading
  4026. // 0x00 to make the integer unsigned)
  4027. CERT_MAX_ASN_ENCODED_DSS_SIGNATURE_LEN = 2 + 2 * (2 + 20 + 1);
  4028. {$EXTERNALSYM CERT_MAX_ASN_ENCODED_DSS_SIGNATURE_LEN}
  4029. //+-------------------------------------------------------------------------
  4030. // X509_DH_PUBLICKEY
  4031. //
  4032. // pvStructInfo points to a CRYPT_UINT_BLOB.
  4033. //--------------------------------------------------------------------------
  4034. //+-------------------------------------------------------------------------
  4035. // X509_DH_PARAMETERS
  4036. //
  4037. // pvStructInfo points to following CERT_DH_PARAMETERS data structure.
  4038. //--------------------------------------------------------------------------
  4039. type
  4040. PCERT_DH_PARAMETERS = ^CERT_DH_PARAMETERS;
  4041. {$EXTERNALSYM PCERT_DH_PARAMETERS}
  4042. _CERT_DH_PARAMETERS = record
  4043. p: CRYPT_UINT_BLOB;
  4044. g: CRYPT_UINT_BLOB;
  4045. end;
  4046. {$EXTERNALSYM _CERT_DH_PARAMETERS}
  4047. CERT_DH_PARAMETERS = _CERT_DH_PARAMETERS;
  4048. {$EXTERNALSYM CERT_DH_PARAMETERS}
  4049. TCertDhParameters = CERT_DH_PARAMETERS;
  4050. PCertDhParameters = PCERT_DH_PARAMETERS;
  4051. //+-------------------------------------------------------------------------
  4052. // X942_DH_PARAMETERS
  4053. //
  4054. // pvStructInfo points to following CERT_X942_DH_PARAMETERS data structure.
  4055. //
  4056. // If q.cbData == 0, then, the following fields are zero'ed.
  4057. //--------------------------------------------------------------------------
  4058. PCERT_X942_DH_VALIDATION_PARAMS = ^CERT_X942_DH_VALIDATION_PARAMS;
  4059. {$EXTERNALSYM PCERT_X942_DH_VALIDATION_PARAMS}
  4060. _CERT_X942_DH_VALIDATION_PARAMS = record
  4061. seed: CRYPT_BIT_BLOB;
  4062. pgenCounter: DWORD;
  4063. end;
  4064. {$EXTERNALSYM _CERT_X942_DH_VALIDATION_PARAMS}
  4065. CERT_X942_DH_VALIDATION_PARAMS = _CERT_X942_DH_VALIDATION_PARAMS;
  4066. {$EXTERNALSYM CERT_X942_DH_VALIDATION_PARAMS}
  4067. TCertX942DhValidationParams = CERT_X942_DH_VALIDATION_PARAMS;
  4068. PCertX942DhValidationParams = PCERT_X942_DH_VALIDATION_PARAMS;
  4069. PCERT_X942_DH_PARAMETERS = ^CERT_X942_DH_PARAMETERS;
  4070. {$EXTERNALSYM PCERT_X942_DH_PARAMETERS}
  4071. _CERT_X942_DH_PARAMETERS = record
  4072. p: CRYPT_UINT_BLOB; // odd prime, p = jq + 1
  4073. g: CRYPT_UINT_BLOB; // generator, g
  4074. q: CRYPT_UINT_BLOB; // factor of p - 1, OPTIONAL
  4075. j: CRYPT_UINT_BLOB; // subgroup factor, OPTIONAL
  4076. pValidationParams: PCERT_X942_DH_VALIDATION_PARAMS; // OPTIONAL
  4077. end;
  4078. {$EXTERNALSYM _CERT_X942_DH_PARAMETERS}
  4079. CERT_X942_DH_PARAMETERS = _CERT_X942_DH_PARAMETERS;
  4080. {$EXTERNALSYM CERT_X942_DH_PARAMETERS}
  4081. TCertX942DhParameters = CERT_X942_DH_PARAMETERS;
  4082. PCertX942DhParameters = PCERT_X942_DH_PARAMETERS;
  4083. //+-------------------------------------------------------------------------
  4084. // X942_OTHER_INFO
  4085. //
  4086. // pvStructInfo points to following CRYPT_X942_OTHER_INFO data structure.
  4087. //
  4088. // rgbCounter and rgbKeyLength are in Little Endian order.
  4089. //--------------------------------------------------------------------------
  4090. const
  4091. CRYPT_X942_COUNTER_BYTE_LENGTH = 4;
  4092. {$EXTERNALSYM CRYPT_X942_COUNTER_BYTE_LENGTH}
  4093. CRYPT_X942_KEY_LENGTH_BYTE_LENGTH = 4;
  4094. {$EXTERNALSYM CRYPT_X942_KEY_LENGTH_BYTE_LENGTH}
  4095. CRYPT_X942_PUB_INFO_BYTE_LENGTH = 512 div 8;
  4096. {$EXTERNALSYM CRYPT_X942_PUB_INFO_BYTE_LENGTH}
  4097. type
  4098. PCRYPT_X942_OTHER_INFO = ^CRYPT_X942_OTHER_INFO;
  4099. {$EXTERNALSYM PCRYPT_X942_OTHER_INFO}
  4100. _CRYPT_X942_OTHER_INFO = record
  4101. pszContentEncryptionObjId: LPSTR;
  4102. rgbCounter: array [0..CRYPT_X942_COUNTER_BYTE_LENGTH - 1] of BYTE;
  4103. rgbKeyLength: array [0..CRYPT_X942_KEY_LENGTH_BYTE_LENGTH - 1] of BYTE;
  4104. PubInfo: CRYPT_DATA_BLOB; // OPTIONAL
  4105. end;
  4106. {$EXTERNALSYM _CRYPT_X942_OTHER_INFO}
  4107. CRYPT_X942_OTHER_INFO = _CRYPT_X942_OTHER_INFO;
  4108. {$EXTERNALSYM CRYPT_X942_OTHER_INFO}
  4109. TCryptX942OtherInfo = CRYPT_X942_OTHER_INFO;
  4110. PCryptX942OtherInfo = PCRYPT_X942_OTHER_INFO;
  4111. //+-------------------------------------------------------------------------
  4112. // PKCS_RC2_CBC_PARAMETERS
  4113. // szOID_RSA_RC2CBC
  4114. //
  4115. // pvStructInfo points to following CRYPT_RC2_CBC_PARAMETERS data structure.
  4116. //--------------------------------------------------------------------------
  4117. PCRYPT_RC2_CBC_PARAMETERS = ^CRYPT_RC2_CBC_PARAMETERS;
  4118. {$EXTERNALSYM PCRYPT_RC2_CBC_PARAMETERS}
  4119. _CRYPT_RC2_CBC_PARAMETERS = record
  4120. dwVersion: DWORD;
  4121. fIV: BOOL; // set if has following IV
  4122. rgbIV: array [0..7] of BYTE;
  4123. end;
  4124. {$EXTERNALSYM _CRYPT_RC2_CBC_PARAMETERS}
  4125. CRYPT_RC2_CBC_PARAMETERS = _CRYPT_RC2_CBC_PARAMETERS;
  4126. {$EXTERNALSYM CRYPT_RC2_CBC_PARAMETERS}
  4127. TCryptRc2CbcParameters = CRYPT_RC2_CBC_PARAMETERS;
  4128. PCryptRc2CbcParameters = PCRYPT_RC2_CBC_PARAMETERS;
  4129. const
  4130. CRYPT_RC2_40BIT_VERSION = 160;
  4131. {$EXTERNALSYM CRYPT_RC2_40BIT_VERSION}
  4132. CRYPT_RC2_56BIT_VERSION = 52;
  4133. {$EXTERNALSYM CRYPT_RC2_56BIT_VERSION}
  4134. CRYPT_RC2_64BIT_VERSION = 120;
  4135. {$EXTERNALSYM CRYPT_RC2_64BIT_VERSION}
  4136. CRYPT_RC2_128BIT_VERSION = 58;
  4137. {$EXTERNALSYM CRYPT_RC2_128BIT_VERSION}
  4138. //+-------------------------------------------------------------------------
  4139. // PKCS_SMIME_CAPABILITIES
  4140. // szOID_RSA_SMIMECapabilities
  4141. //
  4142. // pvStructInfo points to following CRYPT_SMIME_CAPABILITIES data structure.
  4143. //
  4144. // Note, for CryptEncodeObject(X509_ASN_ENCODING), Parameters.cbData == 0
  4145. // causes the encoded parameters to be omitted and not encoded as a NULL
  4146. // (05 00) as is done when encoding a CRYPT_ALGORITHM_IDENTIFIER. This
  4147. // is per the SMIME specification for encoding capabilities.
  4148. //--------------------------------------------------------------------------
  4149. type
  4150. PCRYPT_SMIME_CAPABILITY = ^CRYPT_SMIME_CAPABILITY;
  4151. {$EXTERNALSYM PCRYPT_SMIME_CAPABILITY}
  4152. _CRYPT_SMIME_CAPABILITY = record
  4153. pszObjId: LPSTR;
  4154. Parameters: CRYPT_OBJID_BLOB;
  4155. end;
  4156. {$EXTERNALSYM _CRYPT_SMIME_CAPABILITY}
  4157. CRYPT_SMIME_CAPABILITY = _CRYPT_SMIME_CAPABILITY;
  4158. {$EXTERNALSYM CRYPT_SMIME_CAPABILITY}
  4159. TCryptSmimeCapability = CRYPT_SMIME_CAPABILITY;
  4160. PCryptSmimeCapability = PCRYPT_SMIME_CAPABILITY;
  4161. PCRYPT_SMIME_CAPABILITIES = ^CRYPT_SMIME_CAPABILITIES;
  4162. {$EXTERNALSYM PCRYPT_SMIME_CAPABILITIES}
  4163. _CRYPT_SMIME_CAPABILITIES = record
  4164. cCapability: DWORD;
  4165. rgCapability: PCRYPT_SMIME_CAPABILITY;
  4166. end;
  4167. {$EXTERNALSYM _CRYPT_SMIME_CAPABILITIES}
  4168. CRYPT_SMIME_CAPABILITIES = _CRYPT_SMIME_CAPABILITIES;
  4169. {$EXTERNALSYM CRYPT_SMIME_CAPABILITIES}
  4170. TCryptSmimeCapabilities = CRYPT_SMIME_CAPABILITIES;
  4171. PCryptSmimeCapabilities = PCRYPT_SMIME_CAPABILITIES;
  4172. //+-------------------------------------------------------------------------
  4173. // PKCS7_SIGNER_INFO
  4174. //
  4175. // pvStructInfo points to CMSG_SIGNER_INFO.
  4176. //--------------------------------------------------------------------------
  4177. //+-------------------------------------------------------------------------
  4178. // CMS_SIGNER_INFO
  4179. //
  4180. // pvStructInfo points to CMSG_CMS_SIGNER_INFO.
  4181. //--------------------------------------------------------------------------
  4182. //+-------------------------------------------------------------------------
  4183. // Netscape Certificate Extension Object Identifiers
  4184. //--------------------------------------------------------------------------
  4185. const
  4186. szOID_NETSCAPE = '2.16.840.1.113730';
  4187. {$EXTERNALSYM szOID_NETSCAPE}
  4188. szOID_NETSCAPE_CERT_EXTENSION = '2.16.840.1.113730.1';
  4189. {$EXTERNALSYM szOID_NETSCAPE_CERT_EXTENSION}
  4190. szOID_NETSCAPE_CERT_TYPE = '2.16.840.1.113730.1.1';
  4191. {$EXTERNALSYM szOID_NETSCAPE_CERT_TYPE}
  4192. szOID_NETSCAPE_BASE_URL = '2.16.840.1.113730.1.2';
  4193. {$EXTERNALSYM szOID_NETSCAPE_BASE_URL}
  4194. szOID_NETSCAPE_REVOCATION_URL = '2.16.840.1.113730.1.3';
  4195. {$EXTERNALSYM szOID_NETSCAPE_REVOCATION_URL}
  4196. szOID_NETSCAPE_CA_REVOCATION_URL = '2.16.840.1.113730.1.4';
  4197. {$EXTERNALSYM szOID_NETSCAPE_CA_REVOCATION_URL}
  4198. szOID_NETSCAPE_CERT_RENEWAL_URL = '2.16.840.1.113730.1.7';
  4199. {$EXTERNALSYM szOID_NETSCAPE_CERT_RENEWAL_URL}
  4200. szOID_NETSCAPE_CA_POLICY_URL = '2.16.840.1.113730.1.8';
  4201. {$EXTERNALSYM szOID_NETSCAPE_CA_POLICY_URL}
  4202. szOID_NETSCAPE_SSL_SERVER_NAME = '2.16.840.1.113730.1.12';
  4203. {$EXTERNALSYM szOID_NETSCAPE_SSL_SERVER_NAME}
  4204. szOID_NETSCAPE_COMMENT = '2.16.840.1.113730.1.13';
  4205. {$EXTERNALSYM szOID_NETSCAPE_COMMENT}
  4206. //+-------------------------------------------------------------------------
  4207. // Netscape Certificate Data Type Object Identifiers
  4208. //--------------------------------------------------------------------------
  4209. szOID_NETSCAPE_DATA_TYPE = '2.16.840.1.113730.2';
  4210. {$EXTERNALSYM szOID_NETSCAPE_DATA_TYPE}
  4211. szOID_NETSCAPE_CERT_SEQUENCE = '2.16.840.1.113730.2.5';
  4212. {$EXTERNALSYM szOID_NETSCAPE_CERT_SEQUENCE}
  4213. //+-------------------------------------------------------------------------
  4214. // szOID_NETSCAPE_CERT_TYPE extension
  4215. //
  4216. // Its value is a bit string. CryptDecodeObject/CryptEncodeObject using
  4217. // X509_BITS or X509_BITS_WITHOUT_TRAILING_ZEROES.
  4218. //
  4219. // The following bits are defined:
  4220. //--------------------------------------------------------------------------
  4221. NETSCAPE_SSL_CLIENT_AUTH_CERT_TYPE = $80;
  4222. {$EXTERNALSYM NETSCAPE_SSL_CLIENT_AUTH_CERT_TYPE}
  4223. NETSCAPE_SSL_SERVER_AUTH_CERT_TYPE = $40;
  4224. {$EXTERNALSYM NETSCAPE_SSL_SERVER_AUTH_CERT_TYPE}
  4225. NETSCAPE_SMIME_CERT_TYPE = $20;
  4226. {$EXTERNALSYM NETSCAPE_SMIME_CERT_TYPE}
  4227. NETSCAPE_SIGN_CERT_TYPE = $10;
  4228. {$EXTERNALSYM NETSCAPE_SIGN_CERT_TYPE}
  4229. NETSCAPE_SSL_CA_CERT_TYPE = $04;
  4230. {$EXTERNALSYM NETSCAPE_SSL_CA_CERT_TYPE}
  4231. NETSCAPE_SMIME_CA_CERT_TYPE = $02;
  4232. {$EXTERNALSYM NETSCAPE_SMIME_CA_CERT_TYPE}
  4233. NETSCAPE_SIGN_CA_CERT_TYPE = $01;
  4234. {$EXTERNALSYM NETSCAPE_SIGN_CA_CERT_TYPE}
  4235. //+-------------------------------------------------------------------------
  4236. // szOID_NETSCAPE_BASE_URL extension
  4237. //
  4238. // Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  4239. // X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  4240. // dwValueType = CERT_RDN_IA5_STRING.
  4241. //
  4242. // When present this string is added to the beginning of all relative URLs
  4243. // in the certificate. This extension can be considered an optimization
  4244. // to reduce the size of the URL extensions.
  4245. //--------------------------------------------------------------------------
  4246. //+-------------------------------------------------------------------------
  4247. // szOID_NETSCAPE_REVOCATION_URL extension
  4248. //
  4249. // Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  4250. // X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  4251. // dwValueType = CERT_RDN_IA5_STRING.
  4252. //
  4253. // It is a relative or absolute URL that can be used to check the
  4254. // revocation status of a certificate. The revocation check will be
  4255. // performed as an HTTP GET method using a url that is the concatenation of
  4256. // revocation-url and certificate-serial-number.
  4257. // Where the certificate-serial-number is encoded as a string of
  4258. // ascii hexadecimal digits. For example, if the netscape-base-url is
  4259. // https://www.certs-r-us.com/, the netscape-revocation-url is
  4260. // cgi-bin/check-rev.cgi?, and the certificate serial number is 173420,
  4261. // the resulting URL would be:
  4262. // https://www.certs-r-us.com/cgi-bin/check-rev.cgi?02a56c
  4263. //
  4264. // The server should return a document with a Content-Type of
  4265. // application/x-netscape-revocation. The document should contain
  4266. // a single ascii digit, '1' if the certificate is not curently valid,
  4267. // and '0' if it is curently valid.
  4268. //
  4269. // Note: for all of the URLs that include the certificate serial number,
  4270. // the serial number will be encoded as a string which consists of an even
  4271. // number of hexadecimal digits. If the number of significant digits is odd,
  4272. // the string will have a single leading zero to ensure an even number of
  4273. // digits is generated.
  4274. //--------------------------------------------------------------------------
  4275. //+-------------------------------------------------------------------------
  4276. // szOID_NETSCAPE_CA_REVOCATION_URL extension
  4277. //
  4278. // Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  4279. // X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  4280. // dwValueType = CERT_RDN_IA5_STRING.
  4281. //
  4282. // It is a relative or absolute URL that can be used to check the
  4283. // revocation status of any certificates that are signed by the CA that
  4284. // this certificate belongs to. This extension is only valid in CA
  4285. // certificates. The use of this extension is the same as the above
  4286. // szOID_NETSCAPE_REVOCATION_URL extension.
  4287. //--------------------------------------------------------------------------
  4288. //+-------------------------------------------------------------------------
  4289. // szOID_NETSCAPE_CERT_RENEWAL_URL extension
  4290. //
  4291. // Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  4292. // X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  4293. // dwValueType = CERT_RDN_IA5_STRING.
  4294. //
  4295. // It is a relative or absolute URL that points to a certificate renewal
  4296. // form. The renewal form will be accessed with an HTTP GET method using a
  4297. // url that is the concatenation of renewal-url and
  4298. // certificate-serial-number. Where the certificate-serial-number is
  4299. // encoded as a string of ascii hexadecimal digits. For example, if the
  4300. // netscape-base-url is https://www.certs-r-us.com/, the
  4301. // netscape-cert-renewal-url is cgi-bin/check-renew.cgi?, and the
  4302. // certificate serial number is 173420, the resulting URL would be:
  4303. // https://www.certs-r-us.com/cgi-bin/check-renew.cgi?02a56c
  4304. // The document returned should be an HTML form that will allow the user
  4305. // to request a renewal of their certificate.
  4306. //--------------------------------------------------------------------------
  4307. //+-------------------------------------------------------------------------
  4308. // szOID_NETSCAPE_CA_POLICY_URL extension
  4309. //
  4310. // Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  4311. // X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  4312. // dwValueType = CERT_RDN_IA5_STRING.
  4313. //
  4314. // It is a relative or absolute URL that points to a web page that
  4315. // describes the policies under which the certificate was issued.
  4316. //--------------------------------------------------------------------------
  4317. //+-------------------------------------------------------------------------
  4318. // szOID_NETSCAPE_SSL_SERVER_NAME extension
  4319. //
  4320. // Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  4321. // X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  4322. // dwValueType = CERT_RDN_IA5_STRING.
  4323. //
  4324. // It is a "shell expression" that can be used to match the hostname of the
  4325. // SSL server that is using this certificate. It is recommended that if
  4326. // the server's hostname does not match this pattern the user be notified
  4327. // and given the option to terminate the SSL connection. If this extension
  4328. // is not present then the CommonName in the certificate subject's
  4329. // distinguished name is used for the same purpose.
  4330. //--------------------------------------------------------------------------
  4331. //+-------------------------------------------------------------------------
  4332. // szOID_NETSCAPE_COMMENT extension
  4333. //
  4334. // Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  4335. // X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  4336. // dwValueType = CERT_RDN_IA5_STRING.
  4337. //
  4338. // It is a comment that may be displayed to the user when the certificate
  4339. // is viewed.
  4340. //--------------------------------------------------------------------------
  4341. //+-------------------------------------------------------------------------
  4342. // szOID_NETSCAPE_CERT_SEQUENCE
  4343. //
  4344. // Its value is a PKCS#7 ContentInfo structure wrapping a sequence of
  4345. // certificates. The value of the contentType field is
  4346. // szOID_NETSCAPE_CERT_SEQUENCE, while the content field is the following
  4347. // structure:
  4348. // CertificateSequence ::= SEQUENCE OF Certificate.
  4349. //
  4350. // CryptDecodeObject/CryptEncodeObject using
  4351. // PKCS_CONTENT_INFO_SEQUENCE_OF_ANY, where,
  4352. // pszObjId = szOID_NETSCAPE_CERT_SEQUENCE and the CRYPT_DER_BLOBs point
  4353. // to encoded X509 certificates.
  4354. //--------------------------------------------------------------------------
  4355. //+=========================================================================
  4356. // Object IDentifier (OID) Installable Functions: Data Structures and APIs
  4357. //==========================================================================
  4358. type
  4359. HCRYPTOIDFUNCSET = Pointer;
  4360. {$EXTERNALSYM HCRYPTOIDFUNCSET}
  4361. HCRYPTOIDFUNCADDR = Pointer;
  4362. {$EXTERNALSYM HCRYPTOIDFUNCADDR}
  4363. // Predefined OID Function Names
  4364. const
  4365. CRYPT_OID_ENCODE_OBJECT_FUNC = 'CryptDllEncodeObject';
  4366. {$EXTERNALSYM CRYPT_OID_ENCODE_OBJECT_FUNC}
  4367. CRYPT_OID_DECODE_OBJECT_FUNC = 'CryptDllDecodeObject';
  4368. {$EXTERNALSYM CRYPT_OID_DECODE_OBJECT_FUNC}
  4369. CRYPT_OID_ENCODE_OBJECT_EX_FUNC = 'CryptDllEncodeObjectEx';
  4370. {$EXTERNALSYM CRYPT_OID_ENCODE_OBJECT_EX_FUNC}
  4371. CRYPT_OID_DECODE_OBJECT_EX_FUNC = 'CryptDllDecodeObjectEx';
  4372. {$EXTERNALSYM CRYPT_OID_DECODE_OBJECT_EX_FUNC}
  4373. CRYPT_OID_CREATE_COM_OBJECT_FUNC = 'CryptDllCreateCOMObject';
  4374. {$EXTERNALSYM CRYPT_OID_CREATE_COM_OBJECT_FUNC}
  4375. CRYPT_OID_VERIFY_REVOCATION_FUNC = 'CertDllVerifyRevocation';
  4376. {$EXTERNALSYM CRYPT_OID_VERIFY_REVOCATION_FUNC}
  4377. CRYPT_OID_VERIFY_CTL_USAGE_FUNC = 'CertDllVerifyCTLUsage';
  4378. {$EXTERNALSYM CRYPT_OID_VERIFY_CTL_USAGE_FUNC}
  4379. CRYPT_OID_FORMAT_OBJECT_FUNC = 'CryptDllFormatObject';
  4380. {$EXTERNALSYM CRYPT_OID_FORMAT_OBJECT_FUNC}
  4381. CRYPT_OID_FIND_OID_INFO_FUNC = 'CryptDllFindOIDInfo';
  4382. {$EXTERNALSYM CRYPT_OID_FIND_OID_INFO_FUNC}
  4383. CRYPT_OID_FIND_LOCALIZED_NAME_FUNC = 'CryptDllFindLocalizedName';
  4384. {$EXTERNALSYM CRYPT_OID_FIND_LOCALIZED_NAME_FUNC}
  4385. // CryptDllEncodeObject has same function signature as CryptEncodeObject.
  4386. // CryptDllDecodeObject has same function signature as CryptDecodeObject.
  4387. // CryptDllEncodeObjectEx has same function signature as CryptEncodeObjectEx.
  4388. // The Ex version MUST support the CRYPT_ENCODE_ALLOC_FLAG option.
  4389. //
  4390. // If an Ex function isn't installed or registered, then, attempts to find
  4391. // a non-EX version. If the ALLOC flag is set, then, CryptEncodeObjectEx,
  4392. // does the allocation and calls the non-EX version twice.
  4393. // CryptDllDecodeObjectEx has same function signature as CryptDecodeObjectEx.
  4394. // The Ex version MUST support the CRYPT_DECODE_ALLOC_FLAG option.
  4395. //
  4396. // If an Ex function isn't installed or registered, then, attempts to find
  4397. // a non-EX version. If the ALLOC flag is set, then, CryptDecodeObjectEx,
  4398. // does the allocation and calls the non-EX version twice.
  4399. // CryptDllCreateCOMObject has the following signature:
  4400. // BOOL WINAPI CryptDllCreateCOMObject(
  4401. // IN DWORD dwEncodingType,
  4402. // IN LPCSTR pszOID,
  4403. // IN PCRYPT_DATA_BLOB pEncodedContent,
  4404. // IN DWORD dwFlags,
  4405. // IN REFIID riid,
  4406. // OUT void **ppvObj);
  4407. // CertDllVerifyRevocation has the same signature as CertVerifyRevocation
  4408. // (See CertVerifyRevocation for details on when called)
  4409. // CertDllVerifyCTLUsage has the same signature as CertVerifyCTLUsage
  4410. // CryptDllFindOIDInfo currently is only used to store values used by
  4411. // CryptFindOIDInfo. See CryptFindOIDInfo() for more details.
  4412. // CryptDllFindLocalizedName is only used to store localized string
  4413. // values used by CryptFindLocalizedName. See CryptFindLocalizedName() for
  4414. // more details.
  4415. // Example of a complete OID Function Registry Name:
  4416. // HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\OID
  4417. // Encoding Type 1\CryptDllEncodeObject\1.2.3
  4418. //
  4419. // The key's L"Dll" value contains the name of the Dll.
  4420. // The key's L"FuncName" value overrides the default function name
  4421. CRYPT_OID_REGPATH = 'Software\Microsoft\Cryptography\OID';
  4422. {$EXTERNALSYM CRYPT_OID_REGPATH}
  4423. CRYPT_OID_REG_ENCODING_TYPE_PREFIX = 'EncodingType ';
  4424. {$EXTERNALSYM CRYPT_OID_REG_ENCODING_TYPE_PREFIX}
  4425. CRYPT_OID_REG_DLL_VALUE_NAME = 'Dll';
  4426. {$EXTERNALSYM CRYPT_OID_REG_DLL_VALUE_NAME}
  4427. CRYPT_OID_REG_FUNC_NAME_VALUE_NAME = 'FuncName';
  4428. {$EXTERNALSYM CRYPT_OID_REG_FUNC_NAME_VALUE_NAME}
  4429. CRYPT_OID_REG_FUNC_NAME_VALUE_NAME_A = 'FuncName';
  4430. {$EXTERNALSYM CRYPT_OID_REG_FUNC_NAME_VALUE_NAME_A}
  4431. // CRYPT_INSTALL_OID_FUNC_BEFORE_FLAG can be set in the key's L"CryptFlags"
  4432. // value to register the functions before the installed functions.
  4433. //
  4434. // CryptSetOIDFunctionValue must be called to set this value. L"CryptFlags"
  4435. // must be set using a dwValueType of REG_DWORD.
  4436. CRYPT_OID_REG_FLAGS_VALUE_NAME = 'CryptFlags';
  4437. {$EXTERNALSYM CRYPT_OID_REG_FLAGS_VALUE_NAME}
  4438. // OID used for Default OID functions
  4439. CRYPT_DEFAULT_OID = 'DEFAULT';
  4440. {$EXTERNALSYM CRYPT_DEFAULT_OID}
  4441. type
  4442. PCRYPT_OID_FUNC_ENTRY = ^CRYPT_OID_FUNC_ENTRY;
  4443. {$EXTERNALSYM PCRYPT_OID_FUNC_ENTRY}
  4444. _CRYPT_OID_FUNC_ENTRY = record
  4445. pszOID: LPCSTR;
  4446. pvFuncAddr: Pointer;
  4447. end;
  4448. {$EXTERNALSYM _CRYPT_OID_FUNC_ENTRY}
  4449. CRYPT_OID_FUNC_ENTRY = _CRYPT_OID_FUNC_ENTRY;
  4450. {$EXTERNALSYM CRYPT_OID_FUNC_ENTRY}
  4451. TCryptOidFuncEntry = CRYPT_OID_FUNC_ENTRY;
  4452. PCryptOidFuncEntry = PCRYPT_OID_FUNC_ENTRY;
  4453. const
  4454. CRYPT_INSTALL_OID_FUNC_BEFORE_FLAG = 1;
  4455. {$EXTERNALSYM CRYPT_INSTALL_OID_FUNC_BEFORE_FLAG}
  4456. //+-------------------------------------------------------------------------
  4457. // Install a set of callable OID function addresses.
  4458. //
  4459. // By default the functions are installed at end of the list.
  4460. // Set CRYPT_INSTALL_OID_FUNC_BEFORE_FLAG to install at beginning of list.
  4461. //
  4462. // hModule should be updated with the hModule passed to DllMain to prevent
  4463. // the Dll containing the function addresses from being unloaded by
  4464. // CryptGetOIDFuncAddress/CryptFreeOIDFunctionAddress. This would be the
  4465. // case when the Dll has also regsvr32'ed OID functions via
  4466. // CryptRegisterOIDFunction.
  4467. //
  4468. // DEFAULT functions are installed by setting rgFuncEntry[].pszOID =
  4469. // CRYPT_DEFAULT_OID.
  4470. //--------------------------------------------------------------------------
  4471. function CryptInstallOIDFunctionAddress(hModule: HMODULE; dwEncodingType: DWORD;
  4472. pszFuncName: LPCSTR; cFuncEntry: DWORD; rgFuncEntry: PCRYPT_OID_FUNC_ENTRY;
  4473. dwFlags: DWORD): BOOL; stdcall;
  4474. {$EXTERNALSYM CryptInstallOIDFunctionAddress}
  4475. //+-------------------------------------------------------------------------
  4476. // Initialize and return handle to the OID function set identified by its
  4477. // function name.
  4478. //
  4479. // If the set already exists, a handle to the existing set is returned.
  4480. //--------------------------------------------------------------------------
  4481. function CryptInitOIDFunctionSet(pszFuncName: LPCSTR; dwFlags: DWORD): HCRYPTOIDFUNCSET; stdcall;
  4482. {$EXTERNALSYM CryptInitOIDFunctionSet}
  4483. //+-------------------------------------------------------------------------
  4484. // Search the list of installed functions for an encoding type and OID match.
  4485. // If not found, search the registry.
  4486. //
  4487. // For success, returns TRUE with *ppvFuncAddr updated with the function's
  4488. // address and *phFuncAddr updated with the function address's handle.
  4489. // The function's handle is AddRef'ed. CryptFreeOIDFunctionAddress needs to
  4490. // be called to release it.
  4491. //
  4492. // For a registry match, the Dll containing the function is loaded.
  4493. //
  4494. // By default, both the registered and installed function lists are searched.
  4495. // Set CRYPT_GET_INSTALLED_OID_FUNC_FLAG to only search the installed list
  4496. // of functions. This flag would be set by a registered function to get
  4497. // the address of a pre-installed function it was replacing. For example,
  4498. // the registered function might handle a new special case and call the
  4499. // pre-installed function to handle the remaining cases.
  4500. //--------------------------------------------------------------------------
  4501. function CryptGetOIDFunctionAddress(hFuncSet: HCRYPTOIDFUNCSET;
  4502. dwEncodingType: DWORD; pszOID: LPCSTR; dwFlags: DWORD;
  4503. var ppvFuncAddr: Pointer; var phFuncAddr: HCRYPTOIDFUNCADDR): BOOL; stdcall;
  4504. {$EXTERNALSYM CryptGetOIDFunctionAddress}
  4505. const
  4506. CRYPT_GET_INSTALLED_OID_FUNC_FLAG = $1;
  4507. {$EXTERNALSYM CRYPT_GET_INSTALLED_OID_FUNC_FLAG}
  4508. //+-------------------------------------------------------------------------
  4509. // Get the list of registered default Dll entries for the specified
  4510. // function set and encoding type.
  4511. //
  4512. // The returned list consists of none, one or more null terminated Dll file
  4513. // names. The list is terminated with an empty (L"\0") Dll file name.
  4514. // For example: L"first.dll" L"\0" L"second.dll" L"\0" L"\0"
  4515. //--------------------------------------------------------------------------
  4516. function CryptGetDefaultOIDDllList(hFuncSet: HCRYPTOIDFUNCSET; dwEncodingType: DWORD;
  4517. pwszDllList: LPWSTR; pcchDllList: DWORD): BOOL; stdcall;
  4518. {$EXTERNALSYM CryptGetDefaultOIDDllList}
  4519. //+-------------------------------------------------------------------------
  4520. // Either: get the first or next installed DEFAULT function OR
  4521. // load the Dll containing the DEFAULT function.
  4522. //
  4523. // If pwszDll is NULL, search the list of installed DEFAULT functions.
  4524. // *phFuncAddr must be set to NULL to get the first installed function.
  4525. // Successive installed functions are returned by setting *phFuncAddr
  4526. // to the hFuncAddr returned by the previous call.
  4527. //
  4528. // If pwszDll is NULL, the input *phFuncAddr
  4529. // is always CryptFreeOIDFunctionAddress'ed by this function, even for
  4530. // an error.
  4531. //
  4532. // If pwszDll isn't NULL, then, attempts to load the Dll and the DEFAULT
  4533. // function. *phFuncAddr is ignored upon entry and isn't
  4534. // CryptFreeOIDFunctionAddress'ed.
  4535. //
  4536. // For success, returns TRUE with *ppvFuncAddr updated with the function's
  4537. // address and *phFuncAddr updated with the function address's handle.
  4538. // The function's handle is AddRef'ed. CryptFreeOIDFunctionAddress needs to
  4539. // be called to release it or CryptGetDefaultOIDFunctionAddress can also
  4540. // be called for a NULL pwszDll.
  4541. //--------------------------------------------------------------------------
  4542. function CryptGetDefaultOIDFunctionAddress(hFuncSet: HCRYPTOIDFUNCSET;
  4543. dwEncodingType: DWORD; pwszDll: LPCWSTR; dwFlags: DWORD;
  4544. var ppvFuncAddr: Pointer; phFuncAddr: HCRYPTOIDFUNCADDR): BOOL; stdcall;
  4545. {$EXTERNALSYM CryptGetDefaultOIDFunctionAddress}
  4546. //+-------------------------------------------------------------------------
  4547. // Releases the handle AddRef'ed and returned by CryptGetOIDFunctionAddress
  4548. // or CryptGetDefaultOIDFunctionAddress.
  4549. //
  4550. // If a Dll was loaded for the function its unloaded. However, before doing
  4551. // the unload, the DllCanUnloadNow function exported by the loaded Dll is
  4552. // called. It should return S_FALSE to inhibit the unload or S_TRUE to enable
  4553. // the unload. If the Dll doesn't export DllCanUnloadNow, the Dll is unloaded.
  4554. //
  4555. // DllCanUnloadNow has the following signature:
  4556. // STDAPI DllCanUnloadNow(void);
  4557. //--------------------------------------------------------------------------
  4558. function CryptFreeOIDFunctionAddress(hFuncAddr: HCRYPTOIDFUNCADDR; dwFlags: DWORD): BOOL; stdcall;
  4559. {$EXTERNALSYM CryptFreeOIDFunctionAddress}
  4560. //+-------------------------------------------------------------------------
  4561. // Register the Dll containing the function to be called for the specified
  4562. // encoding type, function name and OID.
  4563. //
  4564. // pwszDll may contain environment-variable strings
  4565. // which are ExpandEnvironmentStrings()'ed before loading the Dll.
  4566. //
  4567. // In addition to registering the DLL, you may override the
  4568. // name of the function to be called. For example,
  4569. // pszFuncName = "CryptDllEncodeObject",
  4570. // pszOverrideFuncName = "MyEncodeXyz".
  4571. // This allows a Dll to export multiple OID functions for the same
  4572. // function name without needing to interpose its own OID dispatcher function.
  4573. //--------------------------------------------------------------------------
  4574. function CryptRegisterOIDFunction(dwEncodingType: DWORD; pszFuncName: LPCSTR;
  4575. pszOID: LPCSTR; pwszDll: LPCWSTR; pszOverrideFuncName: LPCSTR): BOOL; stdcall;
  4576. {$EXTERNALSYM CryptRegisterOIDFunction}
  4577. //+-------------------------------------------------------------------------
  4578. // Unregister the Dll containing the function to be called for the specified
  4579. // encoding type, function name and OID.
  4580. //--------------------------------------------------------------------------
  4581. function CryptUnregisterOIDFunction(dwEncodingType: DWORD; pszFuncName: LPCSTR;
  4582. pszOID: LPCSTR): BOOL; stdcall;
  4583. {$EXTERNALSYM CryptUnregisterOIDFunction}
  4584. //+-------------------------------------------------------------------------
  4585. // Register the Dll containing the default function to be called for the
  4586. // specified encoding type and function name.
  4587. //
  4588. // Unlike CryptRegisterOIDFunction, you can't override the function name
  4589. // needing to be exported by the Dll.
  4590. //
  4591. // The Dll is inserted before the entry specified by dwIndex.
  4592. // dwIndex == 0, inserts at the beginning.
  4593. // dwIndex == CRYPT_REGISTER_LAST_INDEX, appends at the end.
  4594. //
  4595. // pwszDll may contain environment-variable strings
  4596. // which are ExpandEnvironmentStrings()'ed before loading the Dll.
  4597. //--------------------------------------------------------------------------
  4598. function CryptRegisterDefaultOIDFunction(dwEncodingType: DWORD; pszFuncName: LPCSTR;
  4599. dwIndex: DWORD; pwszDll: LPCWSTR): BOOL; stdcall;
  4600. {$EXTERNALSYM CryptRegisterDefaultOIDFunction}
  4601. const
  4602. CRYPT_REGISTER_FIRST_INDEX = 0;
  4603. {$EXTERNALSYM CRYPT_REGISTER_FIRST_INDEX}
  4604. CRYPT_REGISTER_LAST_INDEX = DWORD($FFFFFFFF);
  4605. {$EXTERNALSYM CRYPT_REGISTER_LAST_INDEX}
  4606. //+-------------------------------------------------------------------------
  4607. // Unregister the Dll containing the default function to be called for
  4608. // the specified encoding type and function name.
  4609. //--------------------------------------------------------------------------
  4610. function CryptUnregisterDefaultOIDFunction(dwEncodingType: DWORD;
  4611. pszFuncName: LPCSTR; pwszDll: LPCWSTR): BOOL; stdcall;
  4612. {$EXTERNALSYM CryptUnregisterDefaultOIDFunction}
  4613. //+-------------------------------------------------------------------------
  4614. // Set the value for the specified encoding type, function name, OID and
  4615. // value name.
  4616. //
  4617. // See RegSetValueEx for the possible value types.
  4618. //
  4619. // String types are UNICODE.
  4620. //--------------------------------------------------------------------------
  4621. function CryptSetOIDFunctionValue(dwEncodingType: DWORD; pszFuncName: LPCSTR;
  4622. pszOID: LPCSTR; pwszValueName: LPCWSTR; dwValueType: DWORD; pbValueData: LPBYTE;
  4623. cbValueData: DWORD): BOOL; stdcall;
  4624. {$EXTERNALSYM CryptSetOIDFunctionValue}
  4625. //+-------------------------------------------------------------------------
  4626. // Get the value for the specified encoding type, function name, OID and
  4627. // value name.
  4628. //
  4629. // See RegEnumValue for the possible value types.
  4630. //
  4631. // String types are UNICODE.
  4632. //--------------------------------------------------------------------------
  4633. function CryptGetOIDFunctionValue(dwEncodingType: DWORD; pszFuncName: LPCSTR;
  4634. pszOID: LPCSTR; pwszValueName: LPCWSTR; var pdwValueType: DWORD;
  4635. pbValueData: LPBYTE; var pcbValueData: DWORD): BOOL; stdcall;
  4636. {$EXTERNALSYM CryptGetOIDFunctionValue}
  4637. type
  4638. PFN_CRYPT_ENUM_OID_FUNC = function(dwEncodingType: DWORD; pszFuncName,
  4639. pszOID: LPCSTR; cValue: DWORD; rgdwValueType: LPDWORD;
  4640. rgpwszValueName: LPCWSTR; rgpbValueData: LPBYTE; rgcbValueData: LPDWORD;
  4641. pvArg: Pointer): BOOL; stdcall;
  4642. {$EXTERNALSYM PFN_CRYPT_ENUM_OID_FUNC}
  4643. PFnCryptEnumOidFunc = PFN_CRYPT_ENUM_OID_FUNC;
  4644. //+-------------------------------------------------------------------------
  4645. // Enumerate the OID functions identified by their encoding type,
  4646. // function name and OID.
  4647. //
  4648. // pfnEnumOIDFunc is called for each registry key matching the input
  4649. // parameters. Setting dwEncodingType to CRYPT_MATCH_ANY_ENCODING_TYPE matches
  4650. // any. Setting pszFuncName or pszOID to NULL matches any.
  4651. //
  4652. // Set pszOID == CRYPT_DEFAULT_OID to restrict the enumeration to only the
  4653. // DEFAULT functions
  4654. //
  4655. // String types are UNICODE.
  4656. //--------------------------------------------------------------------------
  4657. function CryptEnumOIDFunction(dwEncodingType: DWORD; pszFuncName, pszOID: LPCSTR;
  4658. dwFlags: DWORD; pvArg: Pointer; pfnEnumOIDFunc: PFN_CRYPT_ENUM_OID_FUNC): BOOL; stdcall;
  4659. {$EXTERNALSYM CryptEnumOIDFunction}
  4660. const
  4661. CRYPT_MATCH_ANY_ENCODING_TYPE = DWORD($FFFFFFFF);
  4662. {$EXTERNALSYM CRYPT_MATCH_ANY_ENCODING_TYPE}
  4663. //+=========================================================================
  4664. // Object IDentifier (OID) Information: Data Structures and APIs
  4665. //==========================================================================
  4666. //+-------------------------------------------------------------------------
  4667. // OID Information
  4668. //--------------------------------------------------------------------------
  4669. type
  4670. PCRYPT_OID_INFO = ^CRYPT_OID_INFO;
  4671. {$EXTERNALSYM PCRYPT_OID_INFO}
  4672. _CRYPT_OID_INFO = record
  4673. cbSize: DWORD;
  4674. pszOID: LPCSTR;
  4675. pwszName: LPCWSTR;
  4676. dwGroupId: DWORD;
  4677. Union: record
  4678. case Integer of
  4679. 0: (dwValue: DWORD);
  4680. 1: (Algid: ALG_ID);
  4681. 2: (dwLength: DWORD);
  4682. end;
  4683. ExtraInfo: CRYPT_DATA_BLOB;
  4684. end;
  4685. {$EXTERNALSYM _CRYPT_OID_INFO}
  4686. CRYPT_OID_INFO = _CRYPT_OID_INFO;
  4687. {$EXTERNALSYM CRYPT_OID_INFO}
  4688. TCryptOidInfo = CRYPT_OID_INFO;
  4689. PCryptOidInfo = PCRYPT_OID_INFO;
  4690. CCRYPT_OID_INFO = CRYPT_OID_INFO;
  4691. {$EXTERNALSYM CCRYPT_OID_INFO}
  4692. PCCRYPT_OID_INFO = PCRYPT_OID_INFO;
  4693. {$EXTERNALSYM PCCRYPT_OID_INFO}
  4694. //+-------------------------------------------------------------------------
  4695. // OID Group IDs
  4696. //--------------------------------------------------------------------------
  4697. const
  4698. CRYPT_HASH_ALG_OID_GROUP_ID = 1;
  4699. {$EXTERNALSYM CRYPT_HASH_ALG_OID_GROUP_ID}
  4700. CRYPT_ENCRYPT_ALG_OID_GROUP_ID = 2;
  4701. {$EXTERNALSYM CRYPT_ENCRYPT_ALG_OID_GROUP_ID}
  4702. CRYPT_PUBKEY_ALG_OID_GROUP_ID = 3;
  4703. {$EXTERNALSYM CRYPT_PUBKEY_ALG_OID_GROUP_ID}
  4704. CRYPT_SIGN_ALG_OID_GROUP_ID = 4;
  4705. {$EXTERNALSYM CRYPT_SIGN_ALG_OID_GROUP_ID}
  4706. CRYPT_RDN_ATTR_OID_GROUP_ID = 5;
  4707. {$EXTERNALSYM CRYPT_RDN_ATTR_OID_GROUP_ID}
  4708. CRYPT_EXT_OR_ATTR_OID_GROUP_ID = 6;
  4709. {$EXTERNALSYM CRYPT_EXT_OR_ATTR_OID_GROUP_ID}
  4710. CRYPT_ENHKEY_USAGE_OID_GROUP_ID = 7;
  4711. {$EXTERNALSYM CRYPT_ENHKEY_USAGE_OID_GROUP_ID}
  4712. CRYPT_POLICY_OID_GROUP_ID = 8;
  4713. {$EXTERNALSYM CRYPT_POLICY_OID_GROUP_ID}
  4714. CRYPT_LAST_OID_GROUP_ID = 8;
  4715. {$EXTERNALSYM CRYPT_LAST_OID_GROUP_ID}
  4716. CRYPT_FIRST_ALG_OID_GROUP_ID = CRYPT_HASH_ALG_OID_GROUP_ID;
  4717. {$EXTERNALSYM CRYPT_FIRST_ALG_OID_GROUP_ID}
  4718. CRYPT_LAST_ALG_OID_GROUP_ID = CRYPT_SIGN_ALG_OID_GROUP_ID;
  4719. {$EXTERNALSYM CRYPT_LAST_ALG_OID_GROUP_ID}
  4720. // The CRYPT_*_ALG_OID_GROUP_ID's have an Algid. The CRYPT_RDN_ATTR_OID_GROUP_ID
  4721. // has a dwLength. The CRYPT_EXT_OR_ATTR_OID_GROUP_ID,
  4722. // CRYPT_ENHKEY_USAGE_OID_GROUP_ID or CRYPT_POLICY_OID_GROUP_ID don't have a
  4723. // dwValue.
  4724. //
  4725. // CRYPT_PUBKEY_ALG_OID_GROUP_ID has the following optional ExtraInfo:
  4726. // DWORD[0] - Flags. CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG can be set to
  4727. // inhibit the reformatting of the signature before
  4728. // CryptVerifySignature is called or after CryptSignHash
  4729. // is called. CRYPT_OID_USE_PUBKEY_PARA_FOR_PKCS7_FLAG can
  4730. // be set to include the public key algorithm's parameters
  4731. // in the PKCS7's digestEncryptionAlgorithm's parameters.
  4732. // CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG can be set to omit
  4733. // NULL parameters when encoding.
  4734. CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG = $1;
  4735. {$EXTERNALSYM CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG}
  4736. CRYPT_OID_USE_PUBKEY_PARA_FOR_PKCS7_FLAG = $2;
  4737. {$EXTERNALSYM CRYPT_OID_USE_PUBKEY_PARA_FOR_PKCS7_FLAG}
  4738. CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG = $4;
  4739. {$EXTERNALSYM CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG}
  4740. // CRYPT_SIGN_ALG_OID_GROUP_ID has the following optional ExtraInfo:
  4741. // DWORD[0] - Public Key Algid.
  4742. // DWORD[1] - Flags. Same as above for CRYPT_PUBKEY_ALG_OID_GROUP_ID.
  4743. // DWORD[2] - Optional CryptAcquireContext(CRYPT_VERIFYCONTEXT)'s dwProvType.
  4744. // If omitted or 0, uses Public Key Algid to select
  4745. // appropriate dwProvType for signature verification.
  4746. // CRYPT_RDN_ATTR_OID_GROUP_ID has the following optional ExtraInfo:
  4747. // Array of DWORDs:
  4748. // [0 ..] - Null terminated list of acceptable RDN attribute
  4749. // value types. An empty list implies CERT_RDN_PRINTABLE_STRING,
  4750. // CERT_RDN_UNICODE_STRING, 0.
  4751. //+-------------------------------------------------------------------------
  4752. // Find OID information. Returns NULL if unable to find any information
  4753. // for the specified key and group. Note, returns a pointer to a constant
  4754. // data structure. The returned pointer MUST NOT be freed.
  4755. //
  4756. // dwKeyType's:
  4757. // CRYPT_OID_INFO_OID_KEY, pvKey points to a szOID
  4758. // CRYPT_OID_INFO_NAME_KEY, pvKey points to a wszName
  4759. // CRYPT_OID_INFO_ALGID_KEY, pvKey points to an ALG_ID
  4760. // CRYPT_OID_INFO_SIGN_KEY, pvKey points to an array of two ALG_ID's:
  4761. // ALG_ID[0] - Hash Algid
  4762. // ALG_ID[1] - PubKey Algid
  4763. //
  4764. // Setting dwGroupId to 0, searches all groups according to the dwKeyType.
  4765. // Otherwise, only the dwGroupId is searched.
  4766. //--------------------------------------------------------------------------
  4767. function CryptFindOIDInfo(dwKeyType: DWORD; pvKey: Pointer; dwGroupId: DWORD): PCCRYPT_OID_INFO; stdcall;
  4768. {$EXTERNALSYM CryptFindOIDInfo}
  4769. const
  4770. CRYPT_OID_INFO_OID_KEY = 1;
  4771. {$EXTERNALSYM CRYPT_OID_INFO_OID_KEY}
  4772. CRYPT_OID_INFO_NAME_KEY = 2;
  4773. {$EXTERNALSYM CRYPT_OID_INFO_NAME_KEY}
  4774. CRYPT_OID_INFO_ALGID_KEY = 3;
  4775. {$EXTERNALSYM CRYPT_OID_INFO_ALGID_KEY}
  4776. CRYPT_OID_INFO_SIGN_KEY = 4;
  4777. {$EXTERNALSYM CRYPT_OID_INFO_SIGN_KEY}
  4778. //+-------------------------------------------------------------------------
  4779. // Register OID information. The OID information specified in the
  4780. // CCRYPT_OID_INFO structure is persisted to the registry.
  4781. //
  4782. // crypt32.dll contains information for the commonly known OIDs. This function
  4783. // allows applications to augment crypt32.dll's OID information. During
  4784. // CryptFindOIDInfo's first call, the registered OID information is installed.
  4785. //
  4786. // By default the registered OID information is installed after crypt32.dll's
  4787. // OID entries. Set CRYPT_INSTALL_OID_INFO_BEFORE_FLAG to install before.
  4788. //--------------------------------------------------------------------------
  4789. function CryptRegisterOIDInfo(pInfo: PCCRYPT_OID_INFO; dwFlags: DWORD): BOOL; stdcall;
  4790. {$EXTERNALSYM CryptRegisterOIDInfo}
  4791. const
  4792. CRYPT_INSTALL_OID_INFO_BEFORE_FLAG = 1;
  4793. {$EXTERNALSYM CRYPT_INSTALL_OID_INFO_BEFORE_FLAG}
  4794. //+-------------------------------------------------------------------------
  4795. // Unregister OID information. Only the pszOID and dwGroupId fields are
  4796. // used to identify the OID information to be unregistered.
  4797. //--------------------------------------------------------------------------
  4798. function CryptUnregisterOIDInfo(pInfo: PCCRYPT_OID_INFO): BOOL; stdcall;
  4799. {$EXTERNALSYM CryptUnregisterOIDInfo}
  4800. // If the callback returns FALSE, stops the enumeration.
  4801. type
  4802. PFN_CRYPT_ENUM_OID_INFO = function(pInfo: PCCRYPT_OID_INFO; pvArg: Pointer): BOOL; stdcall;
  4803. {$EXTERNALSYM PFN_CRYPT_ENUM_OID_INFO}
  4804. PFnCryptEnumOidInfo = PFN_CRYPT_ENUM_OID_INFO;
  4805. //+-------------------------------------------------------------------------
  4806. // Enumerate the OID information.
  4807. //
  4808. // pfnEnumOIDInfo is called for each OID information entry.
  4809. //
  4810. // Setting dwGroupId to 0 matches all groups. Otherwise, only enumerates
  4811. // entries in the specified group.
  4812. //
  4813. // dwFlags currently isn't used and must be set to 0.
  4814. //--------------------------------------------------------------------------
  4815. function CryptEnumOIDInfo(dwGroupId: DWORD; dwFlags: DWORD; pvArg: Pointer;
  4816. pfnEnumOIDInfo: PFN_CRYPT_ENUM_OID_INFO): BOOL; stdcall;
  4817. {$EXTERNALSYM CryptEnumOIDInfo}
  4818. //+-------------------------------------------------------------------------
  4819. // Find the localized name for the specified name. For example, find the
  4820. // localized name for the "Root" system store name. A case insensitive
  4821. // string comparison is done.
  4822. //
  4823. // Returns NULL if unable to find the the specified name.
  4824. //
  4825. // Localized names for the predefined system stores ("Root", "My") and
  4826. // predefined physical stores (".Default", ".LocalMachine") are pre-installed
  4827. // as resource strings in crypt32.dll. CryptSetOIDFunctionValue can be called
  4828. // as follows to register additional localized strings:
  4829. // dwEncodingType = CRYPT_LOCALIZED_NAME_ENCODING_TYPE
  4830. // pszFuncName = CRYPT_OID_FIND_LOCALIZED_NAME_FUNC
  4831. // pszOID = CRYPT_LOCALIZED_NAME_OID
  4832. // pwszValueName = Name to be localized, for example, L"ApplicationStore"
  4833. // dwValueType = REG_SZ
  4834. // pbValueData = pointer to the UNICODE localized string
  4835. // cbValueData = (wcslen(UNICODE localized string) + 1) * sizeof(WCHAR)
  4836. //
  4837. // To unregister, set pbValueData to NULL and cbValueData to 0.
  4838. //
  4839. // The registered names are searched before the pre-installed names.
  4840. //--------------------------------------------------------------------------
  4841. function CryptFindLocalizedName(pwszCryptName: LPCWSTR): LPCWSTR; stdcall;
  4842. {$EXTERNALSYM CryptFindLocalizedName}
  4843. const
  4844. CRYPT_LOCALIZED_NAME_ENCODING_TYPE = 0;
  4845. {$EXTERNALSYM CRYPT_LOCALIZED_NAME_ENCODING_TYPE}
  4846. CRYPT_LOCALIZED_NAME_OID = 'LocalizedNames';
  4847. {$EXTERNALSYM CRYPT_LOCALIZED_NAME_OID}
  4848. //+=========================================================================
  4849. // Low Level Cryptographic Message Data Structures and APIs
  4850. //==========================================================================
  4851. type
  4852. HCRYPTMSG = Pointer;
  4853. {$EXTERNALSYM HCRYPTMSG}
  4854. PHCRYPTMSG = ^HCRYPTMSG;
  4855. {$NODEFINE PHCRYPTMSG}
  4856. const
  4857. szOID_PKCS_7_DATA = '1.2.840.113549.1.7.1';
  4858. {$EXTERNALSYM szOID_PKCS_7_DATA}
  4859. szOID_PKCS_7_SIGNED = '1.2.840.113549.1.7.2';
  4860. {$EXTERNALSYM szOID_PKCS_7_SIGNED}
  4861. szOID_PKCS_7_ENVELOPED = '1.2.840.113549.1.7.3';
  4862. {$EXTERNALSYM szOID_PKCS_7_ENVELOPED}
  4863. szOID_PKCS_7_SIGNEDANDENVELOPED = '1.2.840.113549.1.7.4';
  4864. {$EXTERNALSYM szOID_PKCS_7_SIGNEDANDENVELOPED}
  4865. szOID_PKCS_7_DIGESTED = '1.2.840.113549.1.7.5';
  4866. {$EXTERNALSYM szOID_PKCS_7_DIGESTED}
  4867. szOID_PKCS_7_ENCRYPTED = '1.2.840.113549.1.7.6';
  4868. {$EXTERNALSYM szOID_PKCS_7_ENCRYPTED}
  4869. szOID_PKCS_9_CONTENT_TYPE = '1.2.840.113549.1.9.3';
  4870. {$EXTERNALSYM szOID_PKCS_9_CONTENT_TYPE}
  4871. szOID_PKCS_9_MESSAGE_DIGEST = '1.2.840.113549.1.9.4';
  4872. {$EXTERNALSYM szOID_PKCS_9_MESSAGE_DIGEST}
  4873. //+-------------------------------------------------------------------------
  4874. // Message types
  4875. //--------------------------------------------------------------------------
  4876. CMSG_DATA = 1;
  4877. {$EXTERNALSYM CMSG_DATA}
  4878. CMSG_SIGNED = 2;
  4879. {$EXTERNALSYM CMSG_SIGNED}
  4880. CMSG_ENVELOPED = 3;
  4881. {$EXTERNALSYM CMSG_ENVELOPED}
  4882. CMSG_SIGNED_AND_ENVELOPED = 4;
  4883. {$EXTERNALSYM CMSG_SIGNED_AND_ENVELOPED}
  4884. CMSG_HASHED = 5;
  4885. {$EXTERNALSYM CMSG_HASHED}
  4886. CMSG_ENCRYPTED = 6;
  4887. {$EXTERNALSYM CMSG_ENCRYPTED}
  4888. //+-------------------------------------------------------------------------
  4889. // Message Type Bit Flags
  4890. //--------------------------------------------------------------------------
  4891. CMSG_ALL_FLAGS = not 0;
  4892. {$EXTERNALSYM CMSG_ALL_FLAGS}
  4893. CMSG_DATA_FLAG = 1 shl CMSG_DATA;
  4894. {$EXTERNALSYM CMSG_DATA_FLAG}
  4895. CMSG_SIGNED_FLAG = 1 shl CMSG_SIGNED;
  4896. {$EXTERNALSYM CMSG_SIGNED_FLAG}
  4897. CMSG_ENVELOPED_FLAG = 1 shl CMSG_ENVELOPED;
  4898. {$EXTERNALSYM CMSG_ENVELOPED_FLAG}
  4899. CMSG_SIGNED_AND_ENVELOPED_FLAG = 1 shl CMSG_SIGNED_AND_ENVELOPED;
  4900. {$EXTERNALSYM CMSG_SIGNED_AND_ENVELOPED_FLAG}
  4901. CMSG_HASHED_FLAG = 1 shl CMSG_HASHED;
  4902. {$EXTERNALSYM CMSG_HASHED_FLAG}
  4903. CMSG_ENCRYPTED_FLAG = 1 shl CMSG_ENCRYPTED;
  4904. {$EXTERNALSYM CMSG_ENCRYPTED_FLAG}
  4905. //+-------------------------------------------------------------------------
  4906. // Certificate Issuer and SerialNumber
  4907. //--------------------------------------------------------------------------
  4908. type
  4909. PCERT_ISSUER_SERIAL_NUMBER = ^CERT_ISSUER_SERIAL_NUMBER;
  4910. {$EXTERNALSYM PCERT_ISSUER_SERIAL_NUMBER}
  4911. _CERT_ISSUER_SERIAL_NUMBER = record
  4912. Issuer: CERT_NAME_BLOB;
  4913. SerialNumber: CRYPT_INTEGER_BLOB;
  4914. end;
  4915. {$EXTERNALSYM _CERT_ISSUER_SERIAL_NUMBER}
  4916. CERT_ISSUER_SERIAL_NUMBER = _CERT_ISSUER_SERIAL_NUMBER;
  4917. {$EXTERNALSYM CERT_ISSUER_SERIAL_NUMBER}
  4918. TCertIssuerSerialNumber = CERT_ISSUER_SERIAL_NUMBER;
  4919. PCertIssuerSerialNumber = PCERT_ISSUER_SERIAL_NUMBER;
  4920. //+-------------------------------------------------------------------------
  4921. // Certificate Identifier
  4922. //--------------------------------------------------------------------------
  4923. PCERT_ID = ^CERT_ID;
  4924. {$EXTERNALSYM PCERT_ID}
  4925. _CERT_ID = record
  4926. dwIdChoice: DWORD;
  4927. case Integer of
  4928. // CERT_ID_ISSUER_SERIAL_NUMBER
  4929. 0: (IssuerSerialNumber: CERT_ISSUER_SERIAL_NUMBER);
  4930. // CERT_ID_KEY_IDENTIFIER
  4931. 1: (KeyId: CRYPT_HASH_BLOB);
  4932. // CERT_ID_SHA1_HASH
  4933. 2: (HashId: CRYPT_HASH_BLOB);
  4934. end;
  4935. {$EXTERNALSYM _CERT_ID}
  4936. CERT_ID = _CERT_ID;
  4937. {$EXTERNALSYM CERT_ID}
  4938. TCertId = CERT_ID;
  4939. PCertId = PCERT_ID;
  4940. const
  4941. CERT_ID_ISSUER_SERIAL_NUMBER = 1;
  4942. {$EXTERNALSYM CERT_ID_ISSUER_SERIAL_NUMBER}
  4943. CERT_ID_KEY_IDENTIFIER = 2;
  4944. {$EXTERNALSYM CERT_ID_KEY_IDENTIFIER}
  4945. CERT_ID_SHA1_HASH = 3;
  4946. {$EXTERNALSYM CERT_ID_SHA1_HASH}
  4947. //+-------------------------------------------------------------------------
  4948. // The message encode information (pvMsgEncodeInfo) is message type dependent
  4949. //--------------------------------------------------------------------------
  4950. //+-------------------------------------------------------------------------
  4951. // CMSG_DATA: pvMsgEncodeInfo = NULL
  4952. //--------------------------------------------------------------------------
  4953. //+-------------------------------------------------------------------------
  4954. // CMSG_SIGNED
  4955. //
  4956. // The pCertInfo in the CMSG_SIGNER_ENCODE_INFO provides the Issuer, SerialNumber
  4957. // and PublicKeyInfo.Algorithm. The PublicKeyInfo.Algorithm implicitly
  4958. // specifies the HashEncryptionAlgorithm to be used.
  4959. //
  4960. // If the SignerId is present with a nonzero dwIdChoice its used instead
  4961. // of the Issuer and SerialNumber in pCertInfo.
  4962. //
  4963. // CMS supports the KEY_IDENTIFIER and ISSUER_SERIAL_NUMBER CERT_IDs. PKCS #7
  4964. // version 1.5 only supports the ISSUER_SERIAL_NUMBER CERT_ID choice.
  4965. //
  4966. // If HashEncryptionAlgorithm is present and not NULL its used instead of
  4967. // the PublicKeyInfo.Algorithm.
  4968. //
  4969. // Note, for RSA, the hash encryption algorithm is normally the same as
  4970. // the public key algorithm. For DSA, the hash encryption algorithm is
  4971. // normally a DSS signature algorithm.
  4972. //
  4973. // pvHashEncryptionAuxInfo currently isn't used and must be set to NULL if
  4974. // present in the data structure.
  4975. //
  4976. // The hCryptProv and dwKeySpec specify the private key to use. If dwKeySpec
  4977. // == 0, then, defaults to AT_SIGNATURE.
  4978. //
  4979. // If CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags
  4980. // passed to CryptMsgOpenToEncode(), the signer hCryptProv's are released.
  4981. //
  4982. // pvHashAuxInfo currently isn't used and must be set to NULL.
  4983. //
  4984. // CMS signed messages allow the inclusion of Attribute Certs.
  4985. //--------------------------------------------------------------------------
  4986. type
  4987. PCMSG_SIGNER_ENCODE_INFO = ^CMSG_SIGNER_ENCODE_INFO;
  4988. {$EXTERNALSYM PCMSG_SIGNER_ENCODE_INFO}
  4989. _CMSG_SIGNER_ENCODE_INFO = record
  4990. cbSize: DWORD;
  4991. pCertInfo: PCERT_INFO;
  4992. hCryptProv: HCRYPTPROV;
  4993. dwKeySpec: DWORD;
  4994. HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  4995. pvHashAuxInfo: Pointer;
  4996. cAuthAttr: DWORD;
  4997. rgAuthAttr: PCRYPT_ATTRIBUTE;
  4998. cUnauthAttr: DWORD;
  4999. rgUnauthAttr: PCRYPT_ATTRIBUTE;
  5000. {$IFDEF CMSG_SIGNER_ENCODE_INFO_HAS_CMS_FIELDS}
  5001. SignerId: CERT_ID;
  5002. HashEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5003. pvHashEncryptionAuxInfo: Pointer;
  5004. {$ENDIF CMSG_SIGNER_ENCODE_INFO_HAS_CMS_FIELDS}
  5005. end;
  5006. {$EXTERNALSYM _CMSG_SIGNER_ENCODE_INFO}
  5007. CMSG_SIGNER_ENCODE_INFO = _CMSG_SIGNER_ENCODE_INFO;
  5008. {$EXTERNALSYM CMSG_SIGNER_ENCODE_INFO}
  5009. TCmsgSignerEncodeInfo = CMSG_SIGNER_ENCODE_INFO;
  5010. PCmsgSignerEncodeInfo = PCMSG_SIGNER_ENCODE_INFO;
  5011. PCMSG_SIGNED_ENCODE_INFO = ^CMSG_SIGNED_ENCODE_INFO;
  5012. {$EXTERNALSYM PCMSG_SIGNED_ENCODE_INFO}
  5013. _CMSG_SIGNED_ENCODE_INFO = record
  5014. cbSize: DWORD;
  5015. cSigners: DWORD;
  5016. rgSigners: PCMSG_SIGNER_ENCODE_INFO;
  5017. cCertEncoded: DWORD;
  5018. rgCertEncoded: PCERT_BLOB;
  5019. cCrlEncoded: DWORD;
  5020. rgCrlEncoded: PCRL_BLOB;
  5021. {$IFDEF CMSG_SIGNED_ENCODE_INFO_HAS_CMS_FIELDS}
  5022. cAttrCertEncoded: DWORD;
  5023. rgAttrCertEncoded: PCERT_BLOB;
  5024. {$ENDIF CMSG_SIGNED_ENCODE_INFO_HAS_CMS_FIELDS}
  5025. end;
  5026. {$EXTERNALSYM _CMSG_SIGNED_ENCODE_INFO}
  5027. CMSG_SIGNED_ENCODE_INFO = _CMSG_SIGNED_ENCODE_INFO;
  5028. {$EXTERNALSYM CMSG_SIGNED_ENCODE_INFO}
  5029. TCmsgSignedEncodeInfo = CMSG_SIGNED_ENCODE_INFO;
  5030. PCmsgSignedEncodeInfo = PCMSG_SIGNED_ENCODE_INFO;
  5031. //+-------------------------------------------------------------------------
  5032. // CMSG_ENVELOPED
  5033. //
  5034. // The PCERT_INFO for the rgRecipients provides the Issuer, SerialNumber
  5035. // and PublicKeyInfo. The PublicKeyInfo.Algorithm implicitly
  5036. // specifies the KeyEncryptionAlgorithm to be used.
  5037. //
  5038. // The PublicKeyInfo.PublicKey in PCERT_INFO is used to encrypt the content
  5039. // encryption key for the recipient.
  5040. //
  5041. // hCryptProv is used to do the content encryption, recipient key encryption
  5042. // and export. The hCryptProv's private keys aren't used. If hCryptProv
  5043. // is NULL, a default hCryptProv is chosen according to the
  5044. // ContentEncryptionAlgorithm and the first recipient KeyEncryptionAlgorithm.
  5045. //
  5046. // If CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags
  5047. // passed to CryptMsgOpenToEncode(), the envelope's hCryptProv is released.
  5048. //
  5049. // Note: CAPI currently doesn't support more than one KeyEncryptionAlgorithm
  5050. // per provider. This will need to be fixed.
  5051. //
  5052. // Currently, pvEncryptionAuxInfo is only defined for RC2 or RC4 encryption
  5053. // algorithms. Otherwise, its not used and must be set to NULL.
  5054. // See CMSG_RC2_AUX_INFO for the RC2 encryption algorithms.
  5055. // See CMSG_RC4_AUX_INFO for the RC4 encryption algorithms.
  5056. //
  5057. // To enable SP3 compatible encryption, pvEncryptionAuxInfo should point to
  5058. // a CMSG_SP3_COMPATIBLE_AUX_INFO data structure.
  5059. //
  5060. // To enable the CMS envelope enhancements, rgpRecipients must be set to
  5061. // NULL, and rgCmsRecipients updated to point to an array of
  5062. // CMSG_RECIPIENT_ENCODE_INFO's.
  5063. //
  5064. // Also, CMS envelope enhancements support the inclusion of a bag of
  5065. // Certs, CRLs, Attribute Certs and/or Unprotected Attributes.
  5066. //--------------------------------------------------------------------------
  5067. type
  5068. PCMSG_ENVELOPED_ENCODE_INFO = ^CMSG_ENVELOPED_ENCODE_INFO;
  5069. {$EXTERNALSYM PCMSG_ENVELOPED_ENCODE_INFO}
  5070. _CMSG_ENVELOPED_ENCODE_INFO = record
  5071. cbSize: DWORD;
  5072. hCryptProv: HCRYPTPROV;
  5073. ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5074. pvEncryptionAuxInfo: Pointer;
  5075. cRecipients: DWORD;
  5076. // The following array may only be used for transport recipients identified
  5077. // by their IssuereAndSerialNumber. If rgpRecipients != NULL, then,
  5078. // the rgCmsRecipients must be NULL.
  5079. rgpRecipients: PCERT_INFO;
  5080. {$IFDEF CMSG_ENVELOPED_ENCODE_INFO_HAS_CMS_FIELDS}
  5081. // If rgCmsRecipients != NULL, then, the above rgpRecipients must be
  5082. // NULL.
  5083. rgCmsRecipients: PCMSG_RECIPIENT_ENCODE_INFO;
  5084. cCertEncoded: DWORD;
  5085. rgCertEncoded: PCERT_BLOB;
  5086. cCrlEncoded: DWORD;
  5087. rgCrlEncoded: PCRL_BLOB;
  5088. cAttrCertEncoded: DWORD;
  5089. rgAttrCertEncoded: PCERT_BLOB;
  5090. cUnprotectedAttr: DWORD;
  5091. rgUnprotectedAttr: PCRYPT_ATTRIBUTE;
  5092. {$ENDIF CMSG_ENVELOPED_ENCODE_INFO_HAS_CMS_FIELDS}
  5093. end;
  5094. {$EXTERNALSYM _CMSG_ENVELOPED_ENCODE_INFO}
  5095. CMSG_ENVELOPED_ENCODE_INFO = _CMSG_ENVELOPED_ENCODE_INFO;
  5096. {$EXTERNALSYM CMSG_ENVELOPED_ENCODE_INFO}
  5097. TCmsgEnvelopedEncodeInfo = CMSG_ENVELOPED_ENCODE_INFO;
  5098. PCmsgEnvelopedEncodeInfo = PCMSG_ENVELOPED_ENCODE_INFO;
  5099. //+-------------------------------------------------------------------------
  5100. // Key Transport Recipient Encode Info
  5101. //
  5102. // hCryptProv is used to do the recipient key encryption
  5103. // and export. The hCryptProv's private keys aren't used.
  5104. //
  5105. // If hCryptProv is NULL, then, the hCryptProv specified in
  5106. // CMSG_ENVELOPED_ENCODE_INFO is used.
  5107. //
  5108. // Note, even if CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags
  5109. // passed to CryptMsgOpenToEncode(), this hCryptProv isn't released.
  5110. //
  5111. // CMS supports the KEY_IDENTIFIER and ISSUER_SERIAL_NUMBER CERT_IDs. PKCS #7
  5112. // version 1.5 only supports the ISSUER_SERIAL_NUMBER CERT_ID choice.
  5113. //--------------------------------------------------------------------------
  5114. PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO = ^CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO;
  5115. {$EXTERNALSYM PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO}
  5116. _CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO = record
  5117. cbSize: DWORD;
  5118. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5119. pvKeyEncryptionAuxInfo: Pointer;
  5120. hCryptProv: HCRYPTPROV;
  5121. RecipientPublicKey: CRYPT_BIT_BLOB;
  5122. RecipientId: CERT_ID;
  5123. end;
  5124. {$EXTERNALSYM _CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO}
  5125. CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO = _CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO;
  5126. {$EXTERNALSYM CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO}
  5127. TCmsgKeyTransRecipientEncodeInfo = CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO;
  5128. PCmsgKeyTransRecipientEncodeInfo = PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO;
  5129. //+-------------------------------------------------------------------------
  5130. // Key Agreement Recipient Encode Info
  5131. //
  5132. // If hCryptProv is NULL, then, the hCryptProv specified in
  5133. // CMSG_ENVELOPED_ENCODE_INFO is used.
  5134. //
  5135. // For the CMSG_KEY_AGREE_STATIC_KEY_CHOICE, both the hCryptProv and
  5136. // dwKeySpec must be specified to select the sender's private key.
  5137. //
  5138. // Note, even if CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags
  5139. // passed to CryptMsgOpenToEncode(), this hCryptProv isn't released.
  5140. //
  5141. // CMS supports the KEY_IDENTIFIER and ISSUER_SERIAL_NUMBER CERT_IDs.
  5142. //
  5143. // There is 1 key choice, ephemeral originator. The originator's ephemeral
  5144. // key is generated using the public key algorithm parameters shared
  5145. // amongst all the recipients.
  5146. //
  5147. // There are 2 key choices: ephemeral originator or static sender. The
  5148. // originator's ephemeral key is generated using the public key algorithm
  5149. // parameters shared amongst all the recipients. For the static sender its
  5150. // private key is used. The hCryptProv and dwKeySpec specify the private key.
  5151. // The pSenderId identifies the certificate containing the sender's public key.
  5152. //
  5153. // Currently, pvKeyEncryptionAuxInfo isn't used and must be set to NULL.
  5154. //
  5155. // If KeyEncryptionAlgorithm.Parameters.cbData == 0, then, its Parameters
  5156. // are updated with the encoded KeyWrapAlgorithm.
  5157. //
  5158. // Currently, pvKeyWrapAuxInfo is only defined for algorithms with
  5159. // RC2. Otherwise, its not used and must be set to NULL.
  5160. // When set for RC2 algorithms, points to a CMSG_RC2_AUX_INFO containing
  5161. // the RC2 effective key length.
  5162. //
  5163. // Note, key agreement recipients are not supported in PKCS #7 version 1.5.
  5164. //--------------------------------------------------------------------------
  5165. PCMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO = ^CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO;
  5166. {$EXTERNALSYM PCMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO}
  5167. _CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO = record
  5168. cbSize: DWORD;
  5169. RecipientPublicKey: CRYPT_BIT_BLOB;
  5170. RecipientId: CERT_ID;
  5171. // Following fields are optional and only applicable to KEY_IDENTIFIER
  5172. // CERT_IDs.
  5173. Date: FILETIME;
  5174. pOtherAttr: PCRYPT_ATTRIBUTE_TYPE_VALUE;
  5175. end;
  5176. {$EXTERNALSYM _CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO}
  5177. CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO = _CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO;
  5178. {$EXTERNALSYM CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO}
  5179. TCmsgRecipientEncryptedKeyEncodeInfo = CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO;
  5180. PCmsgRecipientEncryptedKeyEncodeInfo = PCMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO;
  5181. PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO = ^CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO;
  5182. {$EXTERNALSYM PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO}
  5183. _CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO = record
  5184. cbSize: DWORD;
  5185. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5186. pvKeyEncryptionAuxInfo: Pointer;
  5187. KeyWrapAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5188. pvKeyWrapAuxInfo: Pointer;
  5189. // The following hCryptProv and dwKeySpec must be specified for the
  5190. // CMSG_KEY_AGREE_STATIC_KEY_CHOICE.
  5191. //
  5192. // For CMSG_KEY_AGREE_EPHEMERAL_KEY_CHOICE, dwKeySpec isn't applicable
  5193. // and hCryptProv is optional.
  5194. hCryptProv: HCRYPTPROV;
  5195. dwKeySpec: DWORD;
  5196. dwKeyChoice: DWORD;
  5197. Union: record
  5198. case Integer of
  5199. // CMSG_KEY_AGREE_EPHEMERAL_KEY_CHOICE
  5200. //
  5201. // The ephemeral public key algorithm and parameters.
  5202. 0: (pEphemeralAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER);
  5203. // CMSG_KEY_AGREE_STATIC_KEY_CHOICE
  5204. //
  5205. // The CertId of the sender's certificate
  5206. 1: (pSenderId: PCERT_ID);
  5207. end;
  5208. UserKeyingMaterial: CRYPT_DATA_BLOB; // OPTIONAL
  5209. cRecipientEncryptedKeys: DWORD;
  5210. rgpRecipientEncryptedKeys: PCMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO;
  5211. end;
  5212. {$EXTERNALSYM _CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO}
  5213. CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO = _CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO;
  5214. {$EXTERNALSYM CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO}
  5215. TCmsgKeyAgreeRecipientEncodeInfo = CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO;
  5216. PCmsgKeyAgreeRecipientEncodeInfo = PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO;
  5217. const
  5218. CMSG_KEY_AGREE_EPHEMERAL_KEY_CHOICE = 1;
  5219. {$EXTERNALSYM CMSG_KEY_AGREE_EPHEMERAL_KEY_CHOICE}
  5220. CMSG_KEY_AGREE_STATIC_KEY_CHOICE = 2;
  5221. {$EXTERNALSYM CMSG_KEY_AGREE_STATIC_KEY_CHOICE}
  5222. //+-------------------------------------------------------------------------
  5223. // Mail List Recipient Encode Info
  5224. //
  5225. // There is 1 choice for the KeyEncryptionKey: an already created CSP key
  5226. // handle. For the key handle choice, hCryptProv must be nonzero. This key
  5227. // handle isn't destroyed.
  5228. //
  5229. // Note, even if CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags
  5230. // passed to CryptMsgOpenToEncode(), this hCryptProv isn't released.
  5231. //
  5232. // Currently, pvKeyEncryptionAuxInfo is only defined for RC2 key wrap
  5233. // algorithms. Otherwise, its not used and must be set to NULL.
  5234. // When set for RC2 algorithms, points to a CMSG_RC2_AUX_INFO containing
  5235. // the RC2 effective key length.
  5236. //
  5237. // Note, mail list recipients are not supported in PKCS #7 version 1.5.
  5238. //--------------------------------------------------------------------------
  5239. type
  5240. PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO = ^CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO;
  5241. {$EXTERNALSYM PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO}
  5242. _CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO = record
  5243. cbSize: DWORD;
  5244. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5245. pvKeyEncryptionAuxInfo: Pointer;
  5246. hCryptProv: HCRYPTPROV;
  5247. dwKeyChoice: DWORD;
  5248. Union: record
  5249. case Integer of
  5250. // CMSG_MAIL_LIST_HANDLE_KEY_CHOICE
  5251. 0: (hKeyEncryptionKey: HCRYPTKEY);
  5252. // Reserve space for a potential pointer choice
  5253. 1: (pvKeyEncryptionKey: Pointer);
  5254. end;
  5255. KeyId: CRYPT_DATA_BLOB;
  5256. // Following fields are optional.
  5257. Date: FILETIME;
  5258. pOtherAttr: PCRYPT_ATTRIBUTE_TYPE_VALUE;
  5259. end;
  5260. {$EXTERNALSYM _CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO}
  5261. CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO = _CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO;
  5262. {$EXTERNALSYM CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO}
  5263. TCmsgMailListRecipientEncodeInfo = CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO;
  5264. PCmsgMailListRecipientEncodeInfo = PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO;
  5265. const
  5266. CMSG_MAIL_LIST_HANDLE_KEY_CHOICE = 1;
  5267. {$EXTERNALSYM CMSG_MAIL_LIST_HANDLE_KEY_CHOICE}
  5268. //+-------------------------------------------------------------------------
  5269. // Recipient Encode Info
  5270. //
  5271. // Note, only key transport recipients are supported in PKCS #7 version 1.5.
  5272. //--------------------------------------------------------------------------
  5273. type
  5274. PCMSG_RECIPIENT_ENCODE_INFO = ^CMSG_RECIPIENT_ENCODE_INFO;
  5275. {$NODEFINE PCMSG_RECIPIENT_ENCODE_INFO}
  5276. _CMSG_RECIPIENT_ENCODE_INFO = record
  5277. dwRecipientChoice: DWORD;
  5278. case Integer of
  5279. // CMSG_KEY_TRANS_RECIPIENT
  5280. 0: (pKeyTrans: PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO);
  5281. // CMSG_KEY_AGREE_RECIPIENT
  5282. 1: (pKeyAgree: PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO);
  5283. // CMSG_MAIL_LIST_RECIPIENT
  5284. 2: (pMailList: PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO);
  5285. end;
  5286. {$EXTERNALSYM _CMSG_RECIPIENT_ENCODE_INFO}
  5287. CMSG_RECIPIENT_ENCODE_INFO = _CMSG_RECIPIENT_ENCODE_INFO;
  5288. {$NODEFINE CMSG_RECIPIENT_ENCODE_INFO}
  5289. TCmsgRecipientEncodeInfo = CMSG_RECIPIENT_ENCODE_INFO;
  5290. PCmsgRecipientEncodeInfo = PCMSG_RECIPIENT_ENCODE_INFO;
  5291. const
  5292. CMSG_KEY_TRANS_RECIPIENT = 1;
  5293. {$EXTERNALSYM CMSG_KEY_TRANS_RECIPIENT}
  5294. CMSG_KEY_AGREE_RECIPIENT = 2;
  5295. {$EXTERNALSYM CMSG_KEY_AGREE_RECIPIENT}
  5296. CMSG_MAIL_LIST_RECIPIENT = 3;
  5297. {$EXTERNALSYM CMSG_MAIL_LIST_RECIPIENT}
  5298. //+-------------------------------------------------------------------------
  5299. // CMSG_RC2_AUX_INFO
  5300. //
  5301. // AuxInfo for RC2 encryption algorithms. The pvEncryptionAuxInfo field
  5302. // in CMSG_ENCRYPTED_ENCODE_INFO should be updated to point to this
  5303. // structure. If not specified, defaults to 40 bit.
  5304. //
  5305. // Note, this AuxInfo is only used when, the ContentEncryptionAlgorithm's
  5306. // Parameter.cbData is zero. Otherwise, the Parameters is decoded to
  5307. // get the bit length.
  5308. //
  5309. // If CMSG_SP3_COMPATIBLE_ENCRYPT_FLAG is set in dwBitLen, then, SP3
  5310. // compatible encryption is done and the bit length is ignored.
  5311. //--------------------------------------------------------------------------
  5312. type
  5313. PCMSG_RC2_AUX_INFO = ^CMSG_RC2_AUX_INFO;
  5314. {$EXTERNALSYM PCMSG_RC2_AUX_INFO}
  5315. _CMSG_RC2_AUX_INFO = record
  5316. cbSize: DWORD;
  5317. dwBitLen: DWORD;
  5318. end;
  5319. {$EXTERNALSYM _CMSG_RC2_AUX_INFO}
  5320. CMSG_RC2_AUX_INFO = _CMSG_RC2_AUX_INFO;
  5321. {$EXTERNALSYM CMSG_RC2_AUX_INFO}
  5322. TCmsgRc2AuxInfo = CMSG_RC2_AUX_INFO;
  5323. PCmsgRc2AuxInfo = PCMSG_RC2_AUX_INFO;
  5324. //+-------------------------------------------------------------------------
  5325. // CMSG_SP3_COMPATIBLE_AUX_INFO
  5326. //
  5327. // AuxInfo for enabling SP3 compatible encryption.
  5328. //
  5329. // The CMSG_SP3_COMPATIBLE_ENCRYPT_FLAG is set in dwFlags to enable SP3
  5330. // compatible encryption. When set, uses zero salt instead of no salt,
  5331. // the encryption algorithm parameters are NULL instead of containing the
  5332. // encoded RC2 parameters or encoded IV octet string and the encrypted
  5333. // symmetric key is encoded little endian instead of big endian.
  5334. //--------------------------------------------------------------------------
  5335. PCMSG_SP3_COMPATIBLE_AUX_INFO = ^CMSG_SP3_COMPATIBLE_AUX_INFO;
  5336. {$EXTERNALSYM PCMSG_SP3_COMPATIBLE_AUX_INFO}
  5337. _CMSG_SP3_COMPATIBLE_AUX_INFO = record
  5338. cbSize: DWORD;
  5339. dwFlags: DWORD;
  5340. end;
  5341. {$EXTERNALSYM _CMSG_SP3_COMPATIBLE_AUX_INFO}
  5342. CMSG_SP3_COMPATIBLE_AUX_INFO = _CMSG_SP3_COMPATIBLE_AUX_INFO;
  5343. {$EXTERNALSYM CMSG_SP3_COMPATIBLE_AUX_INFO}
  5344. TCmsgSp3CompatibleAuxInfo = CMSG_SP3_COMPATIBLE_AUX_INFO;
  5345. PCmsgSp3CompatibleAuxInfo = PCMSG_SP3_COMPATIBLE_AUX_INFO;
  5346. const
  5347. CMSG_SP3_COMPATIBLE_ENCRYPT_FLAG = DWORD($80000000);
  5348. {$EXTERNALSYM CMSG_SP3_COMPATIBLE_ENCRYPT_FLAG}
  5349. //+-------------------------------------------------------------------------
  5350. // CMSG_RC4_AUX_INFO
  5351. //
  5352. // AuxInfo for RC4 encryption algorithms. The pvEncryptionAuxInfo field
  5353. // in CMSG_ENCRYPTED_ENCODE_INFO should be updated to point to this
  5354. // structure. If not specified, uses the CSP's default bit length with no
  5355. // salt. Note, the base CSP has a 40 bit default and the enhanced CSP has
  5356. // a 128 bit default.
  5357. //
  5358. // If CMSG_RC4_NO_SALT_FLAG is set in dwBitLen, then, no salt is generated.
  5359. // Otherwise, (128 - dwBitLen)/8 bytes of salt are generated and encoded
  5360. // as an OCTET STRING in the algorithm parameters field.
  5361. //--------------------------------------------------------------------------
  5362. type
  5363. PCMSG_RC4_AUX_INFO = ^CMSG_RC4_AUX_INFO;
  5364. {$EXTERNALSYM PCMSG_RC4_AUX_INFO}
  5365. _CMSG_RC4_AUX_INFO = record
  5366. cbSize: DWORD;
  5367. dwBitLen: DWORD;
  5368. end;
  5369. {$EXTERNALSYM _CMSG_RC4_AUX_INFO}
  5370. CMSG_RC4_AUX_INFO = _CMSG_RC4_AUX_INFO;
  5371. {$EXTERNALSYM CMSG_RC4_AUX_INFO}
  5372. TCmsgRc4AuxInfo = CMSG_RC4_AUX_INFO;
  5373. PCmsgRc4AuxInfo = PCMSG_RC4_AUX_INFO;
  5374. const
  5375. CMSG_RC4_NO_SALT_FLAG = $40000000;
  5376. {$EXTERNALSYM CMSG_RC4_NO_SALT_FLAG}
  5377. //+-------------------------------------------------------------------------
  5378. // CMSG_SIGNED_AND_ENVELOPED
  5379. //
  5380. // For PKCS #7, a signed and enveloped message doesn't have the
  5381. // signer's authenticated or unauthenticated attributes. Otherwise, a
  5382. // combination of the CMSG_SIGNED_ENCODE_INFO and CMSG_ENVELOPED_ENCODE_INFO.
  5383. //--------------------------------------------------------------------------
  5384. type
  5385. PCMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO = ^CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO;
  5386. {$EXTERNALSYM PCMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO}
  5387. _CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO = record
  5388. cbSize: DWORD;
  5389. SignedInfo: CMSG_SIGNED_ENCODE_INFO;
  5390. EnvelopedInfo: CMSG_ENVELOPED_ENCODE_INFO;
  5391. end;
  5392. {$EXTERNALSYM _CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO}
  5393. CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO = _CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO;
  5394. {$EXTERNALSYM CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO}
  5395. TCmsgSignedAndEnvelopedEncodeInfo = CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO;
  5396. PCmsgSignedAndEnvelopedEncodeInfo = PCMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO;
  5397. //+-------------------------------------------------------------------------
  5398. // CMSG_HASHED
  5399. //
  5400. // hCryptProv is used to do the hash. Doesn't need to use a private key.
  5401. //
  5402. // If CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags
  5403. // passed to CryptMsgOpenToEncode(), the hCryptProv is released.
  5404. //
  5405. // If fDetachedHash is set, then, the encoded message doesn't contain
  5406. // any content (its treated as NULL Data)
  5407. //
  5408. // pvHashAuxInfo currently isn't used and must be set to NULL.
  5409. //--------------------------------------------------------------------------
  5410. PCMSG_HASHED_ENCODE_INFO = ^CMSG_HASHED_ENCODE_INFO;
  5411. {$EXTERNALSYM PCMSG_HASHED_ENCODE_INFO}
  5412. _CMSG_HASHED_ENCODE_INFO = record
  5413. cbSize: DWORD;
  5414. hCryptProv: HCRYPTPROV;
  5415. HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5416. pvHashAuxInfo: Pointer;
  5417. end;
  5418. {$EXTERNALSYM _CMSG_HASHED_ENCODE_INFO}
  5419. CMSG_HASHED_ENCODE_INFO = _CMSG_HASHED_ENCODE_INFO;
  5420. {$EXTERNALSYM CMSG_HASHED_ENCODE_INFO}
  5421. TCmsgHashedEncodeInfo = CMSG_HASHED_ENCODE_INFO;
  5422. PCmsgHashedEncodeInfo = PCMSG_HASHED_ENCODE_INFO;
  5423. //+-------------------------------------------------------------------------
  5424. // CMSG_ENCRYPTED
  5425. //
  5426. // The key used to encrypt the message is identified outside of the message
  5427. // content (for example, password).
  5428. //
  5429. // The content input to CryptMsgUpdate has already been encrypted.
  5430. //
  5431. // pvEncryptionAuxInfo currently isn't used and must be set to NULL.
  5432. //--------------------------------------------------------------------------
  5433. PCMSG_ENCRYPTED_ENCODE_INFO = ^CMSG_ENCRYPTED_ENCODE_INFO;
  5434. {$EXTERNALSYM PCMSG_ENCRYPTED_ENCODE_INFO}
  5435. _CMSG_ENCRYPTED_ENCODE_INFO = record
  5436. cbSize: DWORD;
  5437. ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5438. pvEncryptionAuxInfo: Pointer;
  5439. end;
  5440. {$EXTERNALSYM _CMSG_ENCRYPTED_ENCODE_INFO}
  5441. CMSG_ENCRYPTED_ENCODE_INFO = _CMSG_ENCRYPTED_ENCODE_INFO;
  5442. {$EXTERNALSYM CMSG_ENCRYPTED_ENCODE_INFO}
  5443. TCmsgEncryptedEncodeInfo = CMSG_ENCRYPTED_ENCODE_INFO;
  5444. PCmsgEncryptedEncodeInfo = PCMSG_ENCRYPTED_ENCODE_INFO;
  5445. //+-------------------------------------------------------------------------
  5446. // This parameter allows messages to be of variable length with streamed
  5447. // output.
  5448. //
  5449. // By default, messages are of a definite length and
  5450. // CryptMsgGetParam(CMSG_CONTENT_PARAM) is
  5451. // called to get the cryptographically processed content. Until closed,
  5452. // the handle keeps a copy of the processed content.
  5453. //
  5454. // With streamed output, the processed content can be freed as its streamed.
  5455. //
  5456. // If the length of the content to be updated is known at the time of the
  5457. // open, then, ContentLength should be set to that length. Otherwise, it
  5458. // should be set to CMSG_INDEFINITE_LENGTH.
  5459. //--------------------------------------------------------------------------
  5460. type
  5461. PFN_CMSG_STREAM_OUTPUT = function(pvArg: Pointer; pbData: LPBYTE;
  5462. cbData: DWORD; fFinal: BOOL): BOOL; stdcall;
  5463. {$EXTERNALSYM PFN_CMSG_STREAM_OUTPUT}
  5464. PFnCMsgStreamOutput = PFN_CMSG_STREAM_OUTPUT;
  5465. const
  5466. CMSG_INDEFINITE_LENGTH = DWORD($FFFFFFFF);
  5467. {$EXTERNALSYM CMSG_INDEFINITE_LENGTH}
  5468. type
  5469. PCMSG_STREAM_INFO = ^CMSG_STREAM_INFO;
  5470. {$EXTERNALSYM PCMSG_STREAM_INFO}
  5471. _CMSG_STREAM_INFO = record
  5472. cbContent: DWORD;
  5473. pfnStreamOutput: PFN_CMSG_STREAM_OUTPUT;
  5474. pvArg: Pointer;
  5475. end;
  5476. {$EXTERNALSYM _CMSG_STREAM_INFO}
  5477. CMSG_STREAM_INFO = _CMSG_STREAM_INFO;
  5478. {$EXTERNALSYM CMSG_STREAM_INFO}
  5479. TCmsgStreamInfo = CMSG_STREAM_INFO;
  5480. PCmsgStreamInfo = PCMSG_STREAM_INFO;
  5481. //+-------------------------------------------------------------------------
  5482. // Open dwFlags
  5483. //--------------------------------------------------------------------------
  5484. const
  5485. CMSG_BARE_CONTENT_FLAG = $00000001;
  5486. {$EXTERNALSYM CMSG_BARE_CONTENT_FLAG}
  5487. CMSG_LENGTH_ONLY_FLAG = $00000002;
  5488. {$EXTERNALSYM CMSG_LENGTH_ONLY_FLAG}
  5489. CMSG_DETACHED_FLAG = $00000004;
  5490. {$EXTERNALSYM CMSG_DETACHED_FLAG}
  5491. CMSG_AUTHENTICATED_ATTRIBUTES_FLAG = $00000008;
  5492. {$EXTERNALSYM CMSG_AUTHENTICATED_ATTRIBUTES_FLAG}
  5493. CMSG_CONTENTS_OCTETS_FLAG = $00000010;
  5494. {$EXTERNALSYM CMSG_CONTENTS_OCTETS_FLAG}
  5495. CMSG_MAX_LENGTH_FLAG = $00000020;
  5496. {$EXTERNALSYM CMSG_MAX_LENGTH_FLAG}
  5497. // When set, nonData type inner content is encapsulated within an
  5498. // OCTET STRING. Applicable to both Signed and Enveloped messages.
  5499. CMSG_CMS_ENCAPSULATED_CONTENT_FLAG = $00000040;
  5500. {$EXTERNALSYM CMSG_CMS_ENCAPSULATED_CONTENT_FLAG}
  5501. // If set, then, the hCryptProv passed to CryptMsgOpenToEncode or
  5502. // CryptMsgOpenToDecode is released on the final CryptMsgClose.
  5503. // Not released if CryptMsgOpenToEncode or CryptMsgOpenToDecode fails.
  5504. //
  5505. // Note, the envelope recipient hCryptProv's aren't released.
  5506. CMSG_CRYPT_RELEASE_CONTEXT_FLAG = $00008000;
  5507. {$EXTERNALSYM CMSG_CRYPT_RELEASE_CONTEXT_FLAG}
  5508. //+-------------------------------------------------------------------------
  5509. // Open a cryptographic message for encoding
  5510. //
  5511. // For PKCS #7:
  5512. // If the content to be passed to CryptMsgUpdate has already
  5513. // been message encoded (the input to CryptMsgUpdate is the streamed output
  5514. // from another message encode), then, the CMSG_ENCODED_CONTENT_INFO_FLAG should
  5515. // be set in dwFlags. If not set, then, the inner ContentType is Data and
  5516. // the input to CryptMsgUpdate is treated as the inner Data type's Content,
  5517. // a string of bytes.
  5518. // If CMSG_BARE_CONTENT_FLAG is specified for a streamed message,
  5519. // the streamed output will not have an outer ContentInfo wrapper. This
  5520. // makes it suitable to be streamed into an enclosing message.
  5521. //
  5522. // The pStreamInfo parameter needs to be set to stream the encoded message
  5523. // output.
  5524. //--------------------------------------------------------------------------
  5525. function CryptMsgOpenToEncode(dwMsgEncodingType, dwFlags, dwMsgType: DWORD;
  5526. pvMsgEncodeInfo: Pointer; pszInnerContentObjID: LPSTR;
  5527. pStreamInfo: PCMSG_STREAM_INFO): HCRYPTMSG; stdcall;
  5528. {$EXTERNALSYM CryptMsgOpenToEncode}
  5529. //+-------------------------------------------------------------------------
  5530. // Calculate the length of an encoded cryptographic message.
  5531. //
  5532. // Calculates the length of the encoded message given the
  5533. // message type, encoding parameters and total length of
  5534. // the data to be updated. Note, this might not be the exact length. However,
  5535. // it will always be greater than or equal to the actual length.
  5536. //--------------------------------------------------------------------------
  5537. function CryptMsgCalculateEncodedLength(dwMsgEncodingType, dwFlags, dwMsgType: DWORD;
  5538. pvMsgEncodeInfo: Pointer; pszInnerContentObjID: LPSTR; cbData: DWORD): DWORD; stdcall;
  5539. {$EXTERNALSYM CryptMsgCalculateEncodedLength}
  5540. //+-------------------------------------------------------------------------
  5541. // Open a cryptographic message for decoding
  5542. //
  5543. // hCryptProv specifies the crypto provider to use for hashing and/or
  5544. // decrypting the message. If hCryptProv is NULL, a default crypt provider
  5545. // is used.
  5546. //
  5547. // Currently pRecipientInfo isn't used and should be set to NULL.
  5548. //
  5549. // The pStreamInfo parameter needs to be set to stream the decoded content
  5550. // output.
  5551. //--------------------------------------------------------------------------
  5552. function CryptMsgOpenToDecode(dwMsgEncodingType, dwFlags, dwMsgType: DWORD;
  5553. hCryptProv: HCRYPTPROV; pRecipientInfo: PCERT_INFO;
  5554. pStreamInfo: PCMSG_STREAM_INFO): HCRYPTMSG; stdcall;
  5555. {$EXTERNALSYM CryptMsgOpenToDecode}
  5556. //+-------------------------------------------------------------------------
  5557. // Duplicate a cryptographic message handle
  5558. //--------------------------------------------------------------------------
  5559. function CryptMsgDuplicate(hCryptMsg: HCRYPTMSG): HCRYPTMSG; stdcall;
  5560. {$EXTERNALSYM CryptMsgDuplicate}
  5561. //+-------------------------------------------------------------------------
  5562. // Close a cryptographic message handle
  5563. //
  5564. // LastError is preserved unless FALSE is returned.
  5565. //--------------------------------------------------------------------------
  5566. function CryptMsgClose(hCryptMsg: HCRYPTMSG): BOOL; stdcall;
  5567. {$EXTERNALSYM CryptMsgClose}
  5568. //+-------------------------------------------------------------------------
  5569. // Update the content of a cryptographic message. Depending on how the
  5570. // message was opened, the content is either encoded or decoded.
  5571. //
  5572. // This function is repetitively called to append to the message content.
  5573. // fFinal is set to identify the last update. On fFinal, the encode/decode
  5574. // is completed. The encoded/decoded content and the decoded parameters
  5575. // are valid until the open and all duplicated handles are closed.
  5576. //--------------------------------------------------------------------------
  5577. function CryptMsgUpdate(hCryptMsg: HCRYPTMSG; pbData: LPBYTE; cbData: DWORD;
  5578. fFinal: BOOL): BOOL; stdcall;
  5579. {$EXTERNALSYM CryptMsgUpdate}
  5580. //+-------------------------------------------------------------------------
  5581. // Get a parameter after encoding/decoding a cryptographic message. Called
  5582. // after the final CryptMsgUpdate. Only the CMSG_CONTENT_PARAM and
  5583. // CMSG_COMPUTED_HASH_PARAM are valid for an encoded message.
  5584. //
  5585. // For an encoded HASHED message, the CMSG_COMPUTED_HASH_PARAM can be got
  5586. // before any CryptMsgUpdates to get its length.
  5587. //
  5588. // The pvData type definition depends on the dwParamType value.
  5589. //
  5590. // Elements pointed to by fields in the pvData structure follow the
  5591. // structure. Therefore, *pcbData may exceed the size of the structure.
  5592. //
  5593. // Upon input, if *pcbData == 0, then, *pcbData is updated with the length
  5594. // of the data and the pvData parameter is ignored.
  5595. //
  5596. // Upon return, *pcbData is updated with the length of the data.
  5597. //
  5598. // The OBJID BLOBs returned in the pvData structures point to
  5599. // their still encoded representation. The appropriate functions
  5600. // must be called to decode the information.
  5601. //
  5602. // See below for a list of the parameters to get.
  5603. //--------------------------------------------------------------------------
  5604. function CryptMsgGetParam(hCryptMsg: HCRYPTMSG; dwParamType, dwIndex: DWORD;
  5605. pvData: Pointer; var pcbData: DWORD): BOOL; stdcall;
  5606. {$EXTERNALSYM CryptMsgGetParam}
  5607. //+-------------------------------------------------------------------------
  5608. // Get parameter types and their corresponding data structure definitions.
  5609. //--------------------------------------------------------------------------
  5610. const
  5611. CMSG_TYPE_PARAM = 1;
  5612. {$EXTERNALSYM CMSG_TYPE_PARAM}
  5613. CMSG_CONTENT_PARAM = 2;
  5614. {$EXTERNALSYM CMSG_CONTENT_PARAM}
  5615. CMSG_BARE_CONTENT_PARAM = 3;
  5616. {$EXTERNALSYM CMSG_BARE_CONTENT_PARAM}
  5617. CMSG_INNER_CONTENT_TYPE_PARAM = 4;
  5618. {$EXTERNALSYM CMSG_INNER_CONTENT_TYPE_PARAM}
  5619. CMSG_SIGNER_COUNT_PARAM = 5;
  5620. {$EXTERNALSYM CMSG_SIGNER_COUNT_PARAM}
  5621. CMSG_SIGNER_INFO_PARAM = 6;
  5622. {$EXTERNALSYM CMSG_SIGNER_INFO_PARAM}
  5623. CMSG_SIGNER_CERT_INFO_PARAM = 7;
  5624. {$EXTERNALSYM CMSG_SIGNER_CERT_INFO_PARAM}
  5625. CMSG_SIGNER_HASH_ALGORITHM_PARAM = 8;
  5626. {$EXTERNALSYM CMSG_SIGNER_HASH_ALGORITHM_PARAM}
  5627. CMSG_SIGNER_AUTH_ATTR_PARAM = 9;
  5628. {$EXTERNALSYM CMSG_SIGNER_AUTH_ATTR_PARAM}
  5629. CMSG_SIGNER_UNAUTH_ATTR_PARAM = 10;
  5630. {$EXTERNALSYM CMSG_SIGNER_UNAUTH_ATTR_PARAM}
  5631. CMSG_CERT_COUNT_PARAM = 11;
  5632. {$EXTERNALSYM CMSG_CERT_COUNT_PARAM}
  5633. CMSG_CERT_PARAM = 12;
  5634. {$EXTERNALSYM CMSG_CERT_PARAM}
  5635. CMSG_CRL_COUNT_PARAM = 13;
  5636. {$EXTERNALSYM CMSG_CRL_COUNT_PARAM}
  5637. CMSG_CRL_PARAM = 14;
  5638. {$EXTERNALSYM CMSG_CRL_PARAM}
  5639. CMSG_ENVELOPE_ALGORITHM_PARAM = 15;
  5640. {$EXTERNALSYM CMSG_ENVELOPE_ALGORITHM_PARAM}
  5641. CMSG_RECIPIENT_COUNT_PARAM = 17;
  5642. {$EXTERNALSYM CMSG_RECIPIENT_COUNT_PARAM}
  5643. CMSG_RECIPIENT_INDEX_PARAM = 18;
  5644. {$EXTERNALSYM CMSG_RECIPIENT_INDEX_PARAM}
  5645. CMSG_RECIPIENT_INFO_PARAM = 19;
  5646. {$EXTERNALSYM CMSG_RECIPIENT_INFO_PARAM}
  5647. CMSG_HASH_ALGORITHM_PARAM = 20;
  5648. {$EXTERNALSYM CMSG_HASH_ALGORITHM_PARAM}
  5649. CMSG_HASH_DATA_PARAM = 21;
  5650. {$EXTERNALSYM CMSG_HASH_DATA_PARAM}
  5651. CMSG_COMPUTED_HASH_PARAM = 22;
  5652. {$EXTERNALSYM CMSG_COMPUTED_HASH_PARAM}
  5653. CMSG_ENCRYPT_PARAM = 26;
  5654. {$EXTERNALSYM CMSG_ENCRYPT_PARAM}
  5655. CMSG_ENCRYPTED_DIGEST = 27;
  5656. {$EXTERNALSYM CMSG_ENCRYPTED_DIGEST}
  5657. CMSG_ENCODED_SIGNER = 28;
  5658. {$EXTERNALSYM CMSG_ENCODED_SIGNER}
  5659. CMSG_ENCODED_MESSAGE = 29;
  5660. {$EXTERNALSYM CMSG_ENCODED_MESSAGE}
  5661. CMSG_VERSION_PARAM = 30;
  5662. {$EXTERNALSYM CMSG_VERSION_PARAM}
  5663. CMSG_ATTR_CERT_COUNT_PARAM = 31;
  5664. {$EXTERNALSYM CMSG_ATTR_CERT_COUNT_PARAM}
  5665. CMSG_ATTR_CERT_PARAM = 32;
  5666. {$EXTERNALSYM CMSG_ATTR_CERT_PARAM}
  5667. CMSG_CMS_RECIPIENT_COUNT_PARAM = 33;
  5668. {$EXTERNALSYM CMSG_CMS_RECIPIENT_COUNT_PARAM}
  5669. CMSG_CMS_RECIPIENT_INDEX_PARAM = 34;
  5670. {$EXTERNALSYM CMSG_CMS_RECIPIENT_INDEX_PARAM}
  5671. CMSG_CMS_RECIPIENT_ENCRYPTED_KEY_INDEX_PARAM = 35;
  5672. {$EXTERNALSYM CMSG_CMS_RECIPIENT_ENCRYPTED_KEY_INDEX_PARAM}
  5673. CMSG_CMS_RECIPIENT_INFO_PARAM = 36;
  5674. {$EXTERNALSYM CMSG_CMS_RECIPIENT_INFO_PARAM}
  5675. CMSG_UNPROTECTED_ATTR_PARAM = 37;
  5676. {$EXTERNALSYM CMSG_UNPROTECTED_ATTR_PARAM}
  5677. CMSG_SIGNER_CERT_ID_PARAM = 38;
  5678. {$EXTERNALSYM CMSG_SIGNER_CERT_ID_PARAM}
  5679. CMSG_CMS_SIGNER_INFO_PARAM = 39;
  5680. {$EXTERNALSYM CMSG_CMS_SIGNER_INFO_PARAM}
  5681. //+-------------------------------------------------------------------------
  5682. // CMSG_TYPE_PARAM
  5683. //
  5684. // The type of the decoded message.
  5685. //
  5686. // pvData points to a DWORD
  5687. //--------------------------------------------------------------------------
  5688. //+-------------------------------------------------------------------------
  5689. // CMSG_CONTENT_PARAM
  5690. //
  5691. // The encoded content of a cryptographic message. Depending on how the
  5692. // message was opened, the content is either the whole PKCS#7
  5693. // message (opened to encode) or the inner content (opened to decode).
  5694. // In the decode case, the decrypted content is returned, if enveloped.
  5695. // If not enveloped, and if the inner content is of type DATA, the returned
  5696. // data is the contents octets of the inner content.
  5697. //
  5698. // pvData points to the buffer receiving the content bytes
  5699. //--------------------------------------------------------------------------
  5700. //+-------------------------------------------------------------------------
  5701. // CMSG_BARE_CONTENT_PARAM
  5702. //
  5703. // The encoded content of an encoded cryptographic message, without the
  5704. // outer layer of ContentInfo. That is, only the encoding of the
  5705. // ContentInfo.content field is returned.
  5706. //
  5707. // pvData points to the buffer receiving the content bytes
  5708. //--------------------------------------------------------------------------
  5709. //+-------------------------------------------------------------------------
  5710. // CMSG_INNER_CONTENT_TYPE_PARAM
  5711. //
  5712. // The type of the inner content of a decoded cryptographic message,
  5713. // in the form of a NULL-terminated object identifier string
  5714. // (eg. "1.2.840.113549.1.7.1").
  5715. //
  5716. // pvData points to the buffer receiving the object identifier string
  5717. //--------------------------------------------------------------------------
  5718. //+-------------------------------------------------------------------------
  5719. // CMSG_SIGNER_COUNT_PARAM
  5720. //
  5721. // Count of signers in a SIGNED or SIGNED_AND_ENVELOPED message
  5722. //
  5723. // pvData points to a DWORD
  5724. //--------------------------------------------------------------------------
  5725. //+-------------------------------------------------------------------------
  5726. // CMSG_SIGNER_CERT_INFO_PARAM
  5727. //
  5728. // To get all the signers, repetitively call CryptMsgGetParam, with
  5729. // dwIndex set to 0 .. SignerCount - 1.
  5730. //
  5731. // pvData points to a CERT_INFO struct.
  5732. //
  5733. // Only the following fields have been updated in the CERT_INFO struct:
  5734. // Issuer and SerialNumber.
  5735. //
  5736. // Note, if the KEYID choice was selected for a CMS SignerId, then, the
  5737. // SerialNumber is 0 and the Issuer is encoded containing a single RDN with a
  5738. // single Attribute whose OID is szOID_KEYID_RDN, value type is
  5739. // CERT_RDN_OCTET_STRING and value is the KEYID. When the
  5740. // CertGetSubjectCertificateFromStore and
  5741. // CertFindCertificateInStore(CERT_FIND_SUBJECT_CERT) APIs see this
  5742. // special KEYID Issuer and SerialNumber, they do a KEYID match.
  5743. //--------------------------------------------------------------------------
  5744. //+-------------------------------------------------------------------------
  5745. // CMSG_SIGNER_INFO_PARAM
  5746. //
  5747. // To get all the signers, repetitively call CryptMsgGetParam, with
  5748. // dwIndex set to 0 .. SignerCount - 1.
  5749. //
  5750. // pvData points to a CMSG_SIGNER_INFO struct.
  5751. //
  5752. // Note, if the KEYID choice was selected for a CMS SignerId, then, the
  5753. // SerialNumber is 0 and the Issuer is encoded containing a single RDN with a
  5754. // single Attribute whose OID is szOID_KEYID_RDN, value type is
  5755. // CERT_RDN_OCTET_STRING and value is the KEYID. When the
  5756. // CertGetSubjectCertificateFromStore and
  5757. // CertFindCertificateInStore(CERT_FIND_SUBJECT_CERT) APIs see this
  5758. // special KEYID Issuer and SerialNumber, they do a KEYID match.
  5759. //--------------------------------------------------------------------------
  5760. type
  5761. PCMSG_SIGNER_INFO = ^CMSG_SIGNER_INFO;
  5762. {$EXTERNALSYM PCMSG_SIGNER_INFO}
  5763. _CMSG_SIGNER_INFO = record
  5764. dwVersion: DWORD;
  5765. Issuer: CERT_NAME_BLOB;
  5766. SerialNumber: CRYPT_INTEGER_BLOB;
  5767. HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5768. HashEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5769. EncryptedHash: CRYPT_DATA_BLOB;
  5770. AuthAttrs: CRYPT_ATTRIBUTES;
  5771. UnauthAttrs: CRYPT_ATTRIBUTES;
  5772. end;
  5773. {$EXTERNALSYM _CMSG_SIGNER_INFO}
  5774. CMSG_SIGNER_INFO = _CMSG_SIGNER_INFO;
  5775. {$EXTERNALSYM CMSG_SIGNER_INFO}
  5776. TCmsgSignerInfo = CMSG_SIGNER_INFO;
  5777. PCmsgSignerInfo = PCMSG_SIGNER_INFO;
  5778. //+-------------------------------------------------------------------------
  5779. // CMSG_SIGNER_CERT_ID_PARAM
  5780. //
  5781. // To get all the signers, repetitively call CryptMsgGetParam, with
  5782. // dwIndex set to 0 .. SignerCount - 1.
  5783. //
  5784. // pvData points to a CERT_ID struct.
  5785. //--------------------------------------------------------------------------
  5786. //+-------------------------------------------------------------------------
  5787. // CMSG_CMS_SIGNER_INFO_PARAM
  5788. //
  5789. // Same as CMSG_SIGNER_INFO_PARAM, except, contains SignerId instead of
  5790. // Issuer and SerialNumber.
  5791. //
  5792. // To get all the signers, repetitively call CryptMsgGetParam, with
  5793. // dwIndex set to 0 .. SignerCount - 1.
  5794. //
  5795. // pvData points to a CMSG_CMS_SIGNER_INFO struct.
  5796. //--------------------------------------------------------------------------
  5797. PCMSG_CMS_SIGNER_INFO = ^CMSG_CMS_SIGNER_INFO;
  5798. {$EXTERNALSYM PCMSG_CMS_SIGNER_INFO}
  5799. _CMSG_CMS_SIGNER_INFO = record
  5800. dwVersion: DWORD;
  5801. SignerId: CERT_ID;
  5802. HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5803. HashEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5804. EncryptedHash: CRYPT_DATA_BLOB;
  5805. AuthAttrs: CRYPT_ATTRIBUTES;
  5806. UnauthAttrs: CRYPT_ATTRIBUTES;
  5807. end;
  5808. {$EXTERNALSYM _CMSG_CMS_SIGNER_INFO}
  5809. CMSG_CMS_SIGNER_INFO = _CMSG_CMS_SIGNER_INFO;
  5810. {$EXTERNALSYM CMSG_CMS_SIGNER_INFO}
  5811. TCmsgCmsSignerInfo = CMSG_CMS_SIGNER_INFO;
  5812. PCmsgCmsSignerInfo = PCMSG_CMS_SIGNER_INFO;
  5813. //+-------------------------------------------------------------------------
  5814. // CMSG_SIGNER_HASH_ALGORITHM_PARAM
  5815. //
  5816. // This parameter specifies the HashAlgorithm that was used for the signer.
  5817. //
  5818. // Set dwIndex to iterate through all the signers.
  5819. //
  5820. // pvData points to an CRYPT_ALGORITHM_IDENTIFIER struct.
  5821. //--------------------------------------------------------------------------
  5822. //+-------------------------------------------------------------------------
  5823. // CMSG_SIGNER_AUTH_ATTR_PARAM
  5824. //
  5825. // The authenticated attributes for the signer.
  5826. //
  5827. // Set dwIndex to iterate through all the signers.
  5828. //
  5829. // pvData points to a CMSG_ATTR struct.
  5830. //--------------------------------------------------------------------------
  5831. CMSG_ATTR = CRYPT_ATTRIBUTES;
  5832. {$EXTERNALSYM CMSG_ATTR}
  5833. PCMSG_ATTR = ^CRYPT_ATTRIBUTES;
  5834. {$EXTERNALSYM PCMSG_ATTR}
  5835. //+-------------------------------------------------------------------------
  5836. // CMSG_SIGNER_UNAUTH_ATTR_PARAM
  5837. //
  5838. // The unauthenticated attributes for the signer.
  5839. //
  5840. // Set dwIndex to iterate through all the signers.
  5841. //
  5842. // pvData points to a CMSG_ATTR struct.
  5843. //--------------------------------------------------------------------------
  5844. //+-------------------------------------------------------------------------
  5845. // CMSG_CERT_COUNT_PARAM
  5846. //
  5847. // Count of certificates in a SIGNED or SIGNED_AND_ENVELOPED message.
  5848. //
  5849. // CMS, also supports certificates in an ENVELOPED message.
  5850. //
  5851. // pvData points to a DWORD
  5852. //--------------------------------------------------------------------------
  5853. //+-------------------------------------------------------------------------
  5854. // CMSG_CERT_PARAM
  5855. //
  5856. // To get all the certificates, repetitively call CryptMsgGetParam, with
  5857. // dwIndex set to 0 .. CertCount - 1.
  5858. //
  5859. // pvData points to an array of the certificate's encoded bytes.
  5860. //--------------------------------------------------------------------------
  5861. //+-------------------------------------------------------------------------
  5862. // CMSG_CRL_COUNT_PARAM
  5863. //
  5864. // Count of CRLs in a SIGNED or SIGNED_AND_ENVELOPED message.
  5865. //
  5866. // CMS, also supports CRLs in an ENVELOPED message.
  5867. //
  5868. // pvData points to a DWORD
  5869. //--------------------------------------------------------------------------
  5870. //+-------------------------------------------------------------------------
  5871. // CMSG_CRL_PARAM
  5872. //
  5873. // To get all the CRLs, repetitively call CryptMsgGetParam, with
  5874. // dwIndex set to 0 .. CrlCount - 1.
  5875. //
  5876. // pvData points to an array of the CRL's encoded bytes.
  5877. //--------------------------------------------------------------------------
  5878. //+-------------------------------------------------------------------------
  5879. // CMSG_ENVELOPE_ALGORITHM_PARAM
  5880. //
  5881. // The ContentEncryptionAlgorithm that was used in
  5882. // an ENVELOPED or SIGNED_AND_ENVELOPED message.
  5883. //
  5884. // For streaming you must be able to successfully get this parameter before
  5885. // doing a CryptMsgControl decrypt.
  5886. //
  5887. // pvData points to an CRYPT_ALGORITHM_IDENTIFIER struct.
  5888. //--------------------------------------------------------------------------
  5889. //+-------------------------------------------------------------------------
  5890. // CMSG_RECIPIENT_COUNT_PARAM
  5891. //
  5892. // Count of recipients in an ENVELOPED or SIGNED_AND_ENVELOPED message.
  5893. //
  5894. // Count of key transport recepients.
  5895. //
  5896. // The CMSG_CMS_RECIPIENT_COUNT_PARAM has the total count of
  5897. // recipients (it also includes key agree and mail list recipients).
  5898. //
  5899. // pvData points to a DWORD
  5900. //--------------------------------------------------------------------------
  5901. //+-------------------------------------------------------------------------
  5902. // CMSG_RECIPIENT_INDEX_PARAM
  5903. //
  5904. // Index of the recipient used to decrypt an ENVELOPED or SIGNED_AND_ENVELOPED
  5905. // message.
  5906. //
  5907. // Index of a key transport recipient. If a non key transport
  5908. // recipient was used to decrypt, fails with LastError set to
  5909. // CRYPT_E_INVALID_INDEX.
  5910. //
  5911. // pvData points to a DWORD
  5912. //--------------------------------------------------------------------------
  5913. //+-------------------------------------------------------------------------
  5914. // CMSG_RECIPIENT_INFO_PARAM
  5915. //
  5916. // To get all the recipients, repetitively call CryptMsgGetParam, with
  5917. // dwIndex set to 0 .. RecipientCount - 1.
  5918. //
  5919. // Only returns the key transport recepients.
  5920. //
  5921. // The CMSG_CMS_RECIPIENT_INFO_PARAM returns all recipients.
  5922. //
  5923. // pvData points to a CERT_INFO struct.
  5924. //
  5925. // Only the following fields have been updated in the CERT_INFO struct:
  5926. // Issuer, SerialNumber and PublicKeyAlgorithm. The PublicKeyAlgorithm
  5927. // specifies the KeyEncryptionAlgorithm that was used.
  5928. //
  5929. // Note, if the KEYID choice was selected for a key transport recipient, then,
  5930. // the SerialNumber is 0 and the Issuer is encoded containing a single RDN
  5931. // with a single Attribute whose OID is szOID_KEYID_RDN, value type is
  5932. // CERT_RDN_OCTET_STRING and value is the KEYID. When the
  5933. // CertGetSubjectCertificateFromStore and
  5934. // CertFindCertificateInStore(CERT_FIND_SUBJECT_CERT) APIs see this
  5935. // special KEYID Issuer and SerialNumber, they do a KEYID match.
  5936. //--------------------------------------------------------------------------
  5937. //+-------------------------------------------------------------------------
  5938. // CMSG_HASH_ALGORITHM_PARAM
  5939. //
  5940. // The HashAlgorithm in a HASHED message.
  5941. //
  5942. // pvData points to an CRYPT_ALGORITHM_IDENTIFIER struct.
  5943. //--------------------------------------------------------------------------
  5944. //+-------------------------------------------------------------------------
  5945. // CMSG_HASH_DATA_PARAM
  5946. //
  5947. // The hash in a HASHED message.
  5948. //
  5949. // pvData points to an array of bytes.
  5950. //--------------------------------------------------------------------------
  5951. //+-------------------------------------------------------------------------
  5952. // CMSG_COMPUTED_HASH_PARAM
  5953. //
  5954. // The computed hash for a HASHED message.
  5955. // This may be called for either an encoded or decoded message.
  5956. //
  5957. // Also, the computed hash for one of the signer's in a SIGNED message.
  5958. // It may be called for either an encoded or decoded message after the
  5959. // final update. Set dwIndex to iterate through all the signers.
  5960. //
  5961. // pvData points to an array of bytes.
  5962. //--------------------------------------------------------------------------
  5963. //+-------------------------------------------------------------------------
  5964. // CMSG_ENCRYPT_PARAM
  5965. //
  5966. // The ContentEncryptionAlgorithm that was used in an ENCRYPTED message.
  5967. //
  5968. // pvData points to an CRYPT_ALGORITHM_IDENTIFIER struct.
  5969. //--------------------------------------------------------------------------
  5970. //+-------------------------------------------------------------------------
  5971. // CMSG_ENCODED_MESSAGE
  5972. //
  5973. // The full encoded message. This is useful in the case of a decoded
  5974. // message which has been modified (eg. a signed-data or
  5975. // signed-and-enveloped-data message which has been countersigned).
  5976. //
  5977. // pvData points to an array of the message's encoded bytes.
  5978. //--------------------------------------------------------------------------
  5979. //+-------------------------------------------------------------------------
  5980. // CMSG_VERSION_PARAM
  5981. //
  5982. // The version of the decoded message.
  5983. //
  5984. // pvData points to a DWORD
  5985. //--------------------------------------------------------------------------
  5986. const
  5987. CMSG_SIGNED_DATA_V1 = 1;
  5988. {$EXTERNALSYM CMSG_SIGNED_DATA_V1}
  5989. CMSG_SIGNED_DATA_V3 = 3;
  5990. {$EXTERNALSYM CMSG_SIGNED_DATA_V3}
  5991. CMSG_SIGNED_DATA_PKCS_1_5_VERSION = CMSG_SIGNED_DATA_V1;
  5992. {$EXTERNALSYM CMSG_SIGNED_DATA_PKCS_1_5_VERSION}
  5993. CMSG_SIGNED_DATA_CMS_VERSION = CMSG_SIGNED_DATA_V3;
  5994. {$EXTERNALSYM CMSG_SIGNED_DATA_CMS_VERSION}
  5995. CMSG_SIGNER_INFO_V1 = 1;
  5996. {$EXTERNALSYM CMSG_SIGNER_INFO_V1}
  5997. CMSG_SIGNER_INFO_V3 = 3;
  5998. {$EXTERNALSYM CMSG_SIGNER_INFO_V3}
  5999. CMSG_SIGNER_INFO_PKCS_1_5_VERSION = CMSG_SIGNER_INFO_V1;
  6000. {$EXTERNALSYM CMSG_SIGNER_INFO_PKCS_1_5_VERSION}
  6001. CMSG_SIGNER_INFO_CMS_VERSION = CMSG_SIGNER_INFO_V3;
  6002. {$EXTERNALSYM CMSG_SIGNER_INFO_CMS_VERSION}
  6003. CMSG_HASHED_DATA_V0 = 0;
  6004. {$EXTERNALSYM CMSG_HASHED_DATA_V0}
  6005. CMSG_HASHED_DATA_V2 = 2;
  6006. {$EXTERNALSYM CMSG_HASHED_DATA_V2}
  6007. CMSG_HASHED_DATA_PKCS_1_5_VERSION = CMSG_HASHED_DATA_V0;
  6008. {$EXTERNALSYM CMSG_HASHED_DATA_PKCS_1_5_VERSION}
  6009. CMSG_HASHED_DATA_CMS_VERSION = CMSG_HASHED_DATA_V2;
  6010. {$EXTERNALSYM CMSG_HASHED_DATA_CMS_VERSION}
  6011. CMSG_ENVELOPED_DATA_V0 = 0;
  6012. {$EXTERNALSYM CMSG_ENVELOPED_DATA_V0}
  6013. CMSG_ENVELOPED_DATA_V2 = 2;
  6014. {$EXTERNALSYM CMSG_ENVELOPED_DATA_V2}
  6015. CMSG_ENVELOPED_DATA_PKCS_1_5_VERSION = CMSG_ENVELOPED_DATA_V0;
  6016. {$EXTERNALSYM CMSG_ENVELOPED_DATA_PKCS_1_5_VERSION}
  6017. CMSG_ENVELOPED_DATA_CMS_VERSION = CMSG_ENVELOPED_DATA_V2;
  6018. {$EXTERNALSYM CMSG_ENVELOPED_DATA_CMS_VERSION}
  6019. //+-------------------------------------------------------------------------
  6020. // CMSG_ATTR_CERT_COUNT_PARAM
  6021. //
  6022. // Count of attribute certificates in a SIGNED or ENVELOPED message.
  6023. //
  6024. // pvData points to a DWORD
  6025. //--------------------------------------------------------------------------
  6026. //+-------------------------------------------------------------------------
  6027. // CMSG_ATTR_CERT_PARAM
  6028. //
  6029. // To get all the attribute certificates, repetitively call CryptMsgGetParam,
  6030. // with dwIndex set to 0 .. AttrCertCount - 1.
  6031. //
  6032. // pvData points to an array of the attribute certificate's encoded bytes.
  6033. //--------------------------------------------------------------------------
  6034. //+-------------------------------------------------------------------------
  6035. // CMSG_CMS_RECIPIENT_COUNT_PARAM
  6036. //
  6037. // Count of all CMS recipients in an ENVELOPED message.
  6038. //
  6039. // pvData points to a DWORD
  6040. //--------------------------------------------------------------------------
  6041. //+-------------------------------------------------------------------------
  6042. // CMSG_CMS_RECIPIENT_INDEX_PARAM
  6043. //
  6044. // Index of the CMS recipient used to decrypt an ENVELOPED message.
  6045. //
  6046. // pvData points to a DWORD
  6047. //--------------------------------------------------------------------------
  6048. //+-------------------------------------------------------------------------
  6049. // CMSG_CMS_RECIPIENT_ENCRYPTED_KEY_INDEX_PARAM
  6050. //
  6051. // For a CMS key agreement recipient, the index of the encrypted key
  6052. // used to decrypt an ENVELOPED message.
  6053. //
  6054. // pvData points to a DWORD
  6055. //--------------------------------------------------------------------------
  6056. //+-------------------------------------------------------------------------
  6057. // CMSG_CMS_RECIPIENT_INFO_PARAM
  6058. //
  6059. // To get all the CMS recipients, repetitively call CryptMsgGetParam, with
  6060. // dwIndex set to 0 .. CmsRecipientCount - 1.
  6061. //
  6062. // pvData points to a CMSG_CMS_RECIPIENT_INFO struct.
  6063. //--------------------------------------------------------------------------
  6064. type
  6065. PCMSG_KEY_TRANS_RECIPIENT_INFO = ^CMSG_KEY_TRANS_RECIPIENT_INFO;
  6066. {$EXTERNALSYM PCMSG_KEY_TRANS_RECIPIENT_INFO}
  6067. _CMSG_KEY_TRANS_RECIPIENT_INFO = record
  6068. dwVersion: DWORD;
  6069. // Currently, only ISSUER_SERIAL_NUMBER or KEYID choices
  6070. RecipientId: CERT_ID;
  6071. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  6072. EncryptedKey: CRYPT_DATA_BLOB;
  6073. end;
  6074. {$EXTERNALSYM _CMSG_KEY_TRANS_RECIPIENT_INFO}
  6075. CMSG_KEY_TRANS_RECIPIENT_INFO = _CMSG_KEY_TRANS_RECIPIENT_INFO;
  6076. {$EXTERNALSYM CMSG_KEY_TRANS_RECIPIENT_INFO}
  6077. TCmsgKeyTransRecipientInfo = CMSG_KEY_TRANS_RECIPIENT_INFO;
  6078. PCmsgKeyTransRecipientInfo = PCMSG_KEY_TRANS_RECIPIENT_INFO;
  6079. PCMSG_RECIPIENT_ENCRYPTED_KEY_INFO = ^CMSG_RECIPIENT_ENCRYPTED_KEY_INFO;
  6080. {$EXTERNALSYM PCMSG_RECIPIENT_ENCRYPTED_KEY_INFO}
  6081. _CMSG_RECIPIENT_ENCRYPTED_KEY_INFO = record
  6082. // Currently, only ISSUER_SERIAL_NUMBER or KEYID choices
  6083. RecipientId: CERT_ID;
  6084. EncryptedKey: CRYPT_DATA_BLOB;
  6085. // The following optional fields are only applicable to KEYID choice
  6086. Date: FILETIME;
  6087. pOtherAttr: PCRYPT_ATTRIBUTE_TYPE_VALUE;
  6088. end;
  6089. {$EXTERNALSYM _CMSG_RECIPIENT_ENCRYPTED_KEY_INFO}
  6090. CMSG_RECIPIENT_ENCRYPTED_KEY_INFO = _CMSG_RECIPIENT_ENCRYPTED_KEY_INFO;
  6091. {$EXTERNALSYM CMSG_RECIPIENT_ENCRYPTED_KEY_INFO}
  6092. TCmsgRecipientEncryptedKeyInfo = CMSG_RECIPIENT_ENCRYPTED_KEY_INFO;
  6093. PCmsgRecipientEncryptedKeyInfo = PCMSG_RECIPIENT_ENCRYPTED_KEY_INFO;
  6094. PCMSG_KEY_AGREE_RECIPIENT_INFO = ^CMSG_KEY_AGREE_RECIPIENT_INFO;
  6095. {$EXTERNALSYM PCMSG_KEY_AGREE_RECIPIENT_INFO}
  6096. _CMSG_KEY_AGREE_RECIPIENT_INFO = record
  6097. dwVersion: DWORD;
  6098. dwOriginatorChoice: DWORD;
  6099. Union: record
  6100. case Integer of
  6101. // CMSG_KEY_AGREE_ORIGINATOR_CERT
  6102. 0: (OriginatorCertId: CERT_ID);
  6103. // CMSG_KEY_AGREE_ORIGINATOR_PUBLIC_KEY
  6104. 1: (OriginatorPublicKeyInfo: CERT_PUBLIC_KEY_INFO);
  6105. end;
  6106. UserKeyingMaterial: CRYPT_DATA_BLOB;
  6107. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  6108. cRecipientEncryptedKeys: DWORD;
  6109. rgpRecipientEncryptedKeys: PCMSG_RECIPIENT_ENCRYPTED_KEY_INFO;
  6110. end;
  6111. {$EXTERNALSYM _CMSG_KEY_AGREE_RECIPIENT_INFO}
  6112. CMSG_KEY_AGREE_RECIPIENT_INFO = _CMSG_KEY_AGREE_RECIPIENT_INFO;
  6113. {$EXTERNALSYM CMSG_KEY_AGREE_RECIPIENT_INFO}
  6114. TCmsgKeyAgreeRecipientInfo = CMSG_KEY_AGREE_RECIPIENT_INFO;
  6115. PCmsgKeyAgreeRecipientInfo = PCMSG_KEY_AGREE_RECIPIENT_INFO;
  6116. const
  6117. CMSG_KEY_AGREE_ORIGINATOR_CERT = 1;
  6118. {$EXTERNALSYM CMSG_KEY_AGREE_ORIGINATOR_CERT}
  6119. CMSG_KEY_AGREE_ORIGINATOR_PUBLIC_KEY = 2;
  6120. {$EXTERNALSYM CMSG_KEY_AGREE_ORIGINATOR_PUBLIC_KEY}
  6121. type
  6122. PCMSG_MAIL_LIST_RECIPIENT_INFO = ^CMSG_MAIL_LIST_RECIPIENT_INFO;
  6123. {$EXTERNALSYM PCMSG_MAIL_LIST_RECIPIENT_INFO}
  6124. _CMSG_MAIL_LIST_RECIPIENT_INFO = record
  6125. dwVersion: DWORD;
  6126. KeyId: CRYPT_DATA_BLOB;
  6127. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  6128. EncryptedKey: CRYPT_DATA_BLOB;
  6129. // The following fields are optional
  6130. Date: FILETIME;
  6131. pOtherAttr: PCRYPT_ATTRIBUTE_TYPE_VALUE;
  6132. end;
  6133. {$EXTERNALSYM _CMSG_MAIL_LIST_RECIPIENT_INFO}
  6134. CMSG_MAIL_LIST_RECIPIENT_INFO = _CMSG_MAIL_LIST_RECIPIENT_INFO;
  6135. {$EXTERNALSYM CMSG_MAIL_LIST_RECIPIENT_INFO}
  6136. TCmsgMailListRecipientInfo = CMSG_MAIL_LIST_RECIPIENT_INFO;
  6137. PCmsgMailListRecipientInfo = PCMSG_MAIL_LIST_RECIPIENT_INFO;
  6138. PCMSG_CMS_RECIPIENT_INFO = ^CMSG_CMS_RECIPIENT_INFO;
  6139. {$EXTERNALSYM PCMSG_CMS_RECIPIENT_INFO}
  6140. _CMSG_CMS_RECIPIENT_INFO = record
  6141. dwRecipientChoice: DWORD;
  6142. case Integer of
  6143. // CMSG_KEY_TRANS_RECIPIENT
  6144. 0: (pKeyTrans: PCMSG_KEY_TRANS_RECIPIENT_INFO);
  6145. // CMSG_KEY_AGREE_RECIPIENT
  6146. 1: (pKeyAgree: PCMSG_KEY_AGREE_RECIPIENT_INFO);
  6147. // CMSG_MAIL_LIST_RECIPIENT
  6148. 2: (pMailList: PCMSG_MAIL_LIST_RECIPIENT_INFO);
  6149. end;
  6150. {$EXTERNALSYM _CMSG_CMS_RECIPIENT_INFO}
  6151. CMSG_CMS_RECIPIENT_INFO = _CMSG_CMS_RECIPIENT_INFO;
  6152. {$EXTERNALSYM CMSG_CMS_RECIPIENT_INFO}
  6153. TCmsgCmsRecipientInfo = CMSG_CMS_RECIPIENT_INFO;
  6154. PCmsgCmsRecipientInfo = PCMSG_CMS_RECIPIENT_INFO;
  6155. // dwVersion numbers for the KeyTrans, KeyAgree and MailList recipients
  6156. const
  6157. CMSG_ENVELOPED_RECIPIENT_V0 = 0;
  6158. {$EXTERNALSYM CMSG_ENVELOPED_RECIPIENT_V0}
  6159. CMSG_ENVELOPED_RECIPIENT_V2 = 2;
  6160. {$EXTERNALSYM CMSG_ENVELOPED_RECIPIENT_V2}
  6161. CMSG_ENVELOPED_RECIPIENT_V3 = 3;
  6162. {$EXTERNALSYM CMSG_ENVELOPED_RECIPIENT_V3}
  6163. CMSG_ENVELOPED_RECIPIENT_V4 = 4;
  6164. {$EXTERNALSYM CMSG_ENVELOPED_RECIPIENT_V4}
  6165. CMSG_KEY_TRANS_PKCS_1_5_VERSION = CMSG_ENVELOPED_RECIPIENT_V0;
  6166. {$EXTERNALSYM CMSG_KEY_TRANS_PKCS_1_5_VERSION}
  6167. CMSG_KEY_TRANS_CMS_VERSION = CMSG_ENVELOPED_RECIPIENT_V2;
  6168. {$EXTERNALSYM CMSG_KEY_TRANS_CMS_VERSION}
  6169. CMSG_KEY_AGREE_VERSION = CMSG_ENVELOPED_RECIPIENT_V3;
  6170. {$EXTERNALSYM CMSG_KEY_AGREE_VERSION}
  6171. CMSG_MAIL_LIST_VERSION = CMSG_ENVELOPED_RECIPIENT_V4;
  6172. {$EXTERNALSYM CMSG_MAIL_LIST_VERSION}
  6173. //+-------------------------------------------------------------------------
  6174. // CMSG_UNPROTECTED_ATTR_PARAM
  6175. //
  6176. // The unprotected attributes in the envelped message.
  6177. //
  6178. // pvData points to a CMSG_ATTR struct.
  6179. //--------------------------------------------------------------------------
  6180. //+-------------------------------------------------------------------------
  6181. // Perform a special "control" function after the final CryptMsgUpdate of a
  6182. // encoded/decoded cryptographic message.
  6183. //
  6184. // The dwCtrlType parameter specifies the type of operation to be performed.
  6185. //
  6186. // The pvCtrlPara definition depends on the dwCtrlType value.
  6187. //
  6188. // See below for a list of the control operations and their pvCtrlPara
  6189. // type definition.
  6190. //--------------------------------------------------------------------------
  6191. function CryptMsgControl(hCryptMsg: HCRYPTMSG; dwFlags, dwCtrlType: DWORD;
  6192. pvCtrlPara: Pointer): BOOL; stdcall;
  6193. {$EXTERNALSYM CryptMsgControl}
  6194. //+-------------------------------------------------------------------------
  6195. // Message control types
  6196. //--------------------------------------------------------------------------
  6197. const
  6198. CMSG_CTRL_VERIFY_SIGNATURE = 1;
  6199. {$EXTERNALSYM CMSG_CTRL_VERIFY_SIGNATURE}
  6200. CMSG_CTRL_DECRYPT = 2;
  6201. {$EXTERNALSYM CMSG_CTRL_DECRYPT}
  6202. CMSG_CTRL_VERIFY_HASH = 5;
  6203. {$EXTERNALSYM CMSG_CTRL_VERIFY_HASH}
  6204. CMSG_CTRL_ADD_SIGNER = 6;
  6205. {$EXTERNALSYM CMSG_CTRL_ADD_SIGNER}
  6206. CMSG_CTRL_DEL_SIGNER = 7;
  6207. {$EXTERNALSYM CMSG_CTRL_DEL_SIGNER}
  6208. CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR = 8;
  6209. {$EXTERNALSYM CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR}
  6210. CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR = 9;
  6211. {$EXTERNALSYM CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR}
  6212. CMSG_CTRL_ADD_CERT = 10;
  6213. {$EXTERNALSYM CMSG_CTRL_ADD_CERT}
  6214. CMSG_CTRL_DEL_CERT = 11;
  6215. {$EXTERNALSYM CMSG_CTRL_DEL_CERT}
  6216. CMSG_CTRL_ADD_CRL = 12;
  6217. {$EXTERNALSYM CMSG_CTRL_ADD_CRL}
  6218. CMSG_CTRL_DEL_CRL = 13;
  6219. {$EXTERNALSYM CMSG_CTRL_DEL_CRL}
  6220. CMSG_CTRL_ADD_ATTR_CERT = 14;
  6221. {$EXTERNALSYM CMSG_CTRL_ADD_ATTR_CERT}
  6222. CMSG_CTRL_DEL_ATTR_CERT = 15;
  6223. {$EXTERNALSYM CMSG_CTRL_DEL_ATTR_CERT}
  6224. CMSG_CTRL_KEY_TRANS_DECRYPT = 16;
  6225. {$EXTERNALSYM CMSG_CTRL_KEY_TRANS_DECRYPT}
  6226. CMSG_CTRL_KEY_AGREE_DECRYPT = 17;
  6227. {$EXTERNALSYM CMSG_CTRL_KEY_AGREE_DECRYPT}
  6228. CMSG_CTRL_MAIL_LIST_DECRYPT = 18;
  6229. {$EXTERNALSYM CMSG_CTRL_MAIL_LIST_DECRYPT}
  6230. CMSG_CTRL_VERIFY_SIGNATURE_EX = 19;
  6231. {$EXTERNALSYM CMSG_CTRL_VERIFY_SIGNATURE_EX}
  6232. CMSG_CTRL_ADD_CMS_SIGNER_INFO = 20;
  6233. {$EXTERNALSYM CMSG_CTRL_ADD_CMS_SIGNER_INFO}
  6234. //+-------------------------------------------------------------------------
  6235. // CMSG_CTRL_VERIFY_SIGNATURE
  6236. //
  6237. // Verify the signature of a SIGNED or SIGNED_AND_ENVELOPED
  6238. // message after it has been decoded.
  6239. //
  6240. // For a SIGNED_AND_ENVELOPED message, called after
  6241. // CryptMsgControl(CMSG_CTRL_DECRYPT), if CryptMsgOpenToDecode was called
  6242. // with a NULL pRecipientInfo.
  6243. //
  6244. // pvCtrlPara points to a CERT_INFO struct.
  6245. //
  6246. // The CERT_INFO contains the Issuer and SerialNumber identifying
  6247. // the Signer of the message. The CERT_INFO also contains the
  6248. // PublicKeyInfo
  6249. // used to verify the signature. The cryptographic provider specified
  6250. // in CryptMsgOpenToDecode is used.
  6251. //
  6252. // Note, if the message contains CMS signers identified by KEYID, then,
  6253. // the CERT_INFO's Issuer and SerialNumber is ignored and only the public
  6254. // key is used to find a signer whose signature verifies.
  6255. //
  6256. // The following CMSG_CTRL_VERIFY_SIGNATURE_EX should be used instead.
  6257. //--------------------------------------------------------------------------
  6258. //+-------------------------------------------------------------------------
  6259. // CMSG_CTRL_VERIFY_SIGNATURE_EX
  6260. //
  6261. // Verify the signature of a SIGNED message after it has been decoded.
  6262. //
  6263. // pvCtrlPara points to the following CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA.
  6264. //
  6265. // If hCryptProv is NULL, uses the cryptographic provider specified in
  6266. // CryptMsgOpenToDecode. If CryptMsgOpenToDecode's hCryptProv is also NULL,
  6267. // gets default provider according to the signer's public key OID.
  6268. //
  6269. // dwSignerIndex is the index of the signer to use to verify the signature.
  6270. //
  6271. // The signer can be a pointer to a CERT_PUBLIC_KEY_INFO, certificate
  6272. // context or a chain context.
  6273. //--------------------------------------------------------------------------
  6274. type
  6275. PCMSG_CTRL_VERIFY_SIGNATURE_EX_PARA = ^CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA;
  6276. {$EXTERNALSYM PCMSG_CTRL_VERIFY_SIGNATURE_EX_PARA}
  6277. _CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA = record
  6278. cbSize: DWORD;
  6279. hCryptProv: HCRYPTPROV;
  6280. dwSignerIndex: DWORD;
  6281. dwSignerType: DWORD;
  6282. pvSigner: Pointer;
  6283. end;
  6284. {$EXTERNALSYM _CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA}
  6285. CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA = _CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA;
  6286. {$EXTERNALSYM CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA}
  6287. TCmsgCtrlVerifySignatureExPara = CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA;
  6288. PCmsgCtrlVerifySignatureExPara = PCMSG_CTRL_VERIFY_SIGNATURE_EX_PARA;
  6289. // Signer Types
  6290. const
  6291. CMSG_VERIFY_SIGNER_PUBKEY = 1;
  6292. {$EXTERNALSYM CMSG_VERIFY_SIGNER_PUBKEY}
  6293. // pvSigner :: PCERT_PUBLIC_KEY_INFO
  6294. CMSG_VERIFY_SIGNER_CERT = 2;
  6295. {$EXTERNALSYM CMSG_VERIFY_SIGNER_CERT}
  6296. // pvSigner :: PCCERT_CONTEXT
  6297. CMSG_VERIFY_SIGNER_CHAIN = 3;
  6298. {$EXTERNALSYM CMSG_VERIFY_SIGNER_CHAIN}
  6299. // pvSigner :: PCCERT_CHAIN_CONTEXT
  6300. //+-------------------------------------------------------------------------
  6301. // CMSG_CTRL_DECRYPT
  6302. //
  6303. // Decrypt an ENVELOPED or SIGNED_AND_ENVELOPED message after it has been
  6304. // decoded.
  6305. //
  6306. // This decrypt is only applicable to key transport recipients.
  6307. //
  6308. // hCryptProv and dwKeySpec specify the private key to use. For dwKeySpec ==
  6309. // 0, defaults to AT_KEYEXCHANGE.
  6310. //
  6311. // If CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags passed
  6312. // to CryptMsgControl, then, the hCryptProv is released on the final
  6313. // CryptMsgClose. Not released if CryptMsgControl fails.
  6314. //
  6315. // dwRecipientIndex is the index of the recipient in the message associated
  6316. // with the hCryptProv's private key.
  6317. //
  6318. // The dwRecipientIndex is the index of a key transport recipient.
  6319. //
  6320. // Note, the message can only be decrypted once.
  6321. //--------------------------------------------------------------------------
  6322. type
  6323. PCMSG_CTRL_DECRYPT_PARA = ^CMSG_CTRL_DECRYPT_PARA;
  6324. {$EXTERNALSYM PCMSG_CTRL_DECRYPT_PARA}
  6325. _CMSG_CTRL_DECRYPT_PARA = record
  6326. cbSize: DWORD;
  6327. hCryptProv: HCRYPTPROV;
  6328. dwKeySpec: DWORD;
  6329. dwRecipientIndex: DWORD;
  6330. end;
  6331. {$EXTERNALSYM _CMSG_CTRL_DECRYPT_PARA}
  6332. CMSG_CTRL_DECRYPT_PARA = _CMSG_CTRL_DECRYPT_PARA;
  6333. {$EXTERNALSYM CMSG_CTRL_DECRYPT_PARA}
  6334. TCmsgCtrlDecryptPara = CMSG_CTRL_DECRYPT_PARA;
  6335. PCmsgCtrlDecryptPara = PCMSG_CTRL_DECRYPT_PARA;
  6336. //+-------------------------------------------------------------------------
  6337. // CMSG_CTRL_KEY_TRANS_DECRYPT
  6338. //
  6339. // Decrypt an ENVELOPED message after it has been decoded for a key
  6340. // transport recipient.
  6341. //
  6342. // hCryptProv and dwKeySpec specify the private key to use. For dwKeySpec ==
  6343. // 0, defaults to AT_KEYEXCHANGE.
  6344. //
  6345. // If CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags passed
  6346. // to CryptMsgControl, then, the hCryptProv is released on the final
  6347. // CryptMsgClose. Not released if CryptMsgControl fails.
  6348. //
  6349. // pKeyTrans points to the CMSG_KEY_TRANS_RECIPIENT_INFO obtained via
  6350. // CryptMsgGetParam(CMSG_CMS_RECIPIENT_INFO_PARAM)
  6351. //
  6352. // dwRecipientIndex is the index of the recipient in the message associated
  6353. // with the hCryptProv's private key.
  6354. //
  6355. // Note, the message can only be decrypted once.
  6356. //--------------------------------------------------------------------------
  6357. PCMSG_CTRL_KEY_TRANS_DECRYPT_PARA = ^CMSG_CTRL_KEY_TRANS_DECRYPT_PARA;
  6358. {$EXTERNALSYM PCMSG_CTRL_KEY_TRANS_DECRYPT_PARA}
  6359. _CMSG_CTRL_KEY_TRANS_DECRYPT_PARA = record
  6360. cbSize: DWORD;
  6361. hCryptProv: HCRYPTPROV;
  6362. dwKeySpec: DWORD;
  6363. pKeyTrans: PCMSG_KEY_TRANS_RECIPIENT_INFO;
  6364. dwRecipientIndex: DWORD;
  6365. end;
  6366. {$EXTERNALSYM _CMSG_CTRL_KEY_TRANS_DECRYPT_PARA}
  6367. CMSG_CTRL_KEY_TRANS_DECRYPT_PARA = _CMSG_CTRL_KEY_TRANS_DECRYPT_PARA;
  6368. {$EXTERNALSYM CMSG_CTRL_KEY_TRANS_DECRYPT_PARA}
  6369. TCmsgCtrlKeyTransDecryptPara = CMSG_CTRL_KEY_TRANS_DECRYPT_PARA;
  6370. PCmsgCtrlKeyTransDecryptPara = PCMSG_CTRL_KEY_TRANS_DECRYPT_PARA;
  6371. //+-------------------------------------------------------------------------
  6372. // CMSG_CTRL_KEY_AGREE_DECRYPT
  6373. //
  6374. // Decrypt an ENVELOPED message after it has been decoded for a key
  6375. // agreement recipient.
  6376. //
  6377. // hCryptProv and dwKeySpec specify the private key to use. For dwKeySpec ==
  6378. // 0, defaults to AT_KEYEXCHANGE.
  6379. //
  6380. // If CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags passed
  6381. // to CryptMsgControl, then, the hCryptProv is released on the final
  6382. // CryptMsgClose. Not released if CryptMsgControl fails.
  6383. //
  6384. // pKeyAgree points to the CMSG_KEY_AGREE_RECIPIENT_INFO obtained via
  6385. // CryptMsgGetParam(CMSG_CMS_RECIPIENT_INFO_PARAM) for dwRecipientIndex.
  6386. //
  6387. // dwRecipientIndex, dwRecipientEncryptedKeyIndex are the indices of the
  6388. // recipient's encrypted key in the message associated with the hCryptProv's
  6389. // private key.
  6390. //
  6391. // OriginatorPublicKey is the originator's public key obtained from either
  6392. // the originator's certificate or the CMSG_KEY_AGREE_RECIPIENT_INFO obtained
  6393. // via the CMSG_CMS_RECIPIENT_INFO_PARAM.
  6394. //
  6395. // Note, the message can only be decrypted once.
  6396. //--------------------------------------------------------------------------
  6397. PCMSG_CTRL_KEY_AGREE_DECRYPT_PARA = ^CMSG_CTRL_KEY_AGREE_DECRYPT_PARA;
  6398. {$EXTERNALSYM PCMSG_CTRL_KEY_AGREE_DECRYPT_PARA}
  6399. _CMSG_CTRL_KEY_AGREE_DECRYPT_PARA = record
  6400. cbSize: DWORD;
  6401. hCryptProv: HCRYPTPROV;
  6402. dwKeySpec: DWORD;
  6403. pKeyAgree: PCMSG_KEY_AGREE_RECIPIENT_INFO;
  6404. dwRecipientIndex: DWORD;
  6405. dwRecipientEncryptedKeyIndex: DWORD;
  6406. OriginatorPublicKey: CRYPT_BIT_BLOB;
  6407. end;
  6408. {$EXTERNALSYM _CMSG_CTRL_KEY_AGREE_DECRYPT_PARA}
  6409. CMSG_CTRL_KEY_AGREE_DECRYPT_PARA = _CMSG_CTRL_KEY_AGREE_DECRYPT_PARA;
  6410. {$EXTERNALSYM CMSG_CTRL_KEY_AGREE_DECRYPT_PARA}
  6411. TCmsgCtrlKeyAgreeDecryptPara = CMSG_CTRL_KEY_AGREE_DECRYPT_PARA;
  6412. PCmsgCtrlKeyAgreeDecryptPara = PCMSG_CTRL_KEY_AGREE_DECRYPT_PARA;
  6413. //+-------------------------------------------------------------------------
  6414. // CMSG_CTRL_MAIL_LIST_DECRYPT
  6415. //
  6416. // Decrypt an ENVELOPED message after it has been decoded for a mail
  6417. // list recipient.
  6418. //
  6419. // pMailList points to the CMSG_MAIL_LIST_RECIPIENT_INFO obtained via
  6420. // CryptMsgGetParam(CMSG_CMS_RECIPIENT_INFO_PARAM) for dwRecipientIndex.
  6421. //
  6422. // There is 1 choice for the KeyEncryptionKey: an already created CSP key
  6423. // handle. For the key handle choice, hCryptProv must be nonzero. This key
  6424. // handle isn't destroyed.
  6425. //
  6426. // If CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags passed
  6427. // to CryptMsgControl, then, the hCryptProv is released on the final
  6428. // CryptMsgClose. Not released if CryptMsgControl fails.
  6429. //
  6430. // For RC2 wrap, the effective key length is obtained from the
  6431. // KeyEncryptionAlgorithm parameters and set on the hKeyEncryptionKey before
  6432. // decrypting.
  6433. //
  6434. // Note, the message can only be decrypted once.
  6435. //--------------------------------------------------------------------------
  6436. PCMSG_CTRL_MAIL_LIST_DECRYPT_PARA = ^CMSG_CTRL_MAIL_LIST_DECRYPT_PARA;
  6437. {$EXTERNALSYM PCMSG_CTRL_MAIL_LIST_DECRYPT_PARA}
  6438. _CMSG_CTRL_MAIL_LIST_DECRYPT_PARA = record
  6439. cbSize: DWORD;
  6440. hCryptProv: HCRYPTPROV;
  6441. pMailList: PCMSG_MAIL_LIST_RECIPIENT_INFO;
  6442. dwRecipientIndex: DWORD;
  6443. dwKeyChoice: DWORD;
  6444. case Integer of
  6445. // CMSG_MAIL_LIST_HANDLE_KEY_CHOICE
  6446. 0: (hKeyEncryptionKey: HCRYPTKEY);
  6447. // Reserve space for a potential pointer choice
  6448. 1: (pvKeyEncryptionKey: Pointer);
  6449. end;
  6450. {$EXTERNALSYM _CMSG_CTRL_MAIL_LIST_DECRYPT_PARA}
  6451. CMSG_CTRL_MAIL_LIST_DECRYPT_PARA = _CMSG_CTRL_MAIL_LIST_DECRYPT_PARA;
  6452. {$EXTERNALSYM CMSG_CTRL_MAIL_LIST_DECRYPT_PARA}
  6453. TCmsgCtrlMailListDecryptPara = CMSG_CTRL_MAIL_LIST_DECRYPT_PARA;
  6454. PCmsgCtrlMailListDecryptPara = PCMSG_CTRL_MAIL_LIST_DECRYPT_PARA;
  6455. //+-------------------------------------------------------------------------
  6456. // CMSG_CTRL_VERIFY_HASH
  6457. //
  6458. // Verify the hash of a HASHED message after it has been decoded.
  6459. //
  6460. // Only the hCryptMsg parameter is used, to specify the message whose
  6461. // hash is being verified.
  6462. //--------------------------------------------------------------------------
  6463. //+-------------------------------------------------------------------------
  6464. // CMSG_CTRL_ADD_SIGNER
  6465. //
  6466. // Add a signer to a signed-data message.
  6467. //
  6468. // pvCtrlPara points to a CMSG_SIGNER_ENCODE_INFO.
  6469. //--------------------------------------------------------------------------
  6470. //+-------------------------------------------------------------------------
  6471. // CMSG_CTRL_ADD_CMS_SIGNER_INFO
  6472. //
  6473. // Add a signer to a signed-data message.
  6474. //
  6475. // Differs from the above, CMSG_CTRL_ADD_SIGNER, wherein, the signer info
  6476. // already contains the signature.
  6477. //
  6478. // pvCtrlPara points to a CMSG_CMS_SIGNER_INFO.
  6479. //--------------------------------------------------------------------------
  6480. //+-------------------------------------------------------------------------
  6481. // CMSG_CTRL_DEL_SIGNER
  6482. //
  6483. // Remove a signer from a signed-data or signed-and-enveloped-data message.
  6484. //
  6485. // pvCtrlPara points to a DWORD containing the 0-based index of the
  6486. // signer to be removed.
  6487. //--------------------------------------------------------------------------
  6488. //+-------------------------------------------------------------------------
  6489. // CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR
  6490. //
  6491. // Add an unauthenticated attribute to the SignerInfo of a signed-data or
  6492. // signed-and-enveloped-data message.
  6493. //
  6494. // The unauthenticated attribute is input in the form of an encoded blob.
  6495. //--------------------------------------------------------------------------
  6496. PCMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA = ^CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA;
  6497. {$EXTERNALSYM PCMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA}
  6498. _CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA = record
  6499. cbSize: DWORD;
  6500. dwSignerIndex: DWORD;
  6501. blob: CRYPT_DATA_BLOB;
  6502. end;
  6503. {$EXTERNALSYM _CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA}
  6504. CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA = _CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA;
  6505. {$EXTERNALSYM CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA}
  6506. TCmsgCtrlAddSignerUnauthAttrPara = CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA;
  6507. PCmsgCtrlAddSignerUnauthAttrPara = PCMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA;
  6508. //+-------------------------------------------------------------------------
  6509. // CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR
  6510. //
  6511. // Delete an unauthenticated attribute from the SignerInfo of a signed-data
  6512. // or signed-and-enveloped-data message.
  6513. //
  6514. // The unauthenticated attribute to be removed is specified by
  6515. // a 0-based index.
  6516. //--------------------------------------------------------------------------
  6517. PCMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA = ^CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA;
  6518. {$EXTERNALSYM PCMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA}
  6519. _CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA = record
  6520. cbSize: DWORD;
  6521. dwSignerIndex: DWORD;
  6522. dwUnauthAttrIndex: DWORD;
  6523. end;
  6524. {$EXTERNALSYM _CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA}
  6525. CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA = _CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA;
  6526. {$EXTERNALSYM CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA}
  6527. TCmsgCtrlDelSignerUnauthAttrPara = CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA;
  6528. PCmsgCtrlDelSignerUnauthAttrPara = PCMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA;
  6529. //+-------------------------------------------------------------------------
  6530. // CMSG_CTRL_ADD_CERT
  6531. //
  6532. // Add a certificate to a signed-data or signed-and-enveloped-data message.
  6533. //
  6534. // pvCtrlPara points to a CRYPT_DATA_BLOB containing the certificate's
  6535. // encoded bytes.
  6536. //--------------------------------------------------------------------------
  6537. //+-------------------------------------------------------------------------
  6538. // CMSG_CTRL_DEL_CERT
  6539. //
  6540. // Delete a certificate from a signed-data or signed-and-enveloped-data
  6541. // message.
  6542. //
  6543. // pvCtrlPara points to a DWORD containing the 0-based index of the
  6544. // certificate to be removed.
  6545. //--------------------------------------------------------------------------
  6546. //+-------------------------------------------------------------------------
  6547. // CMSG_CTRL_ADD_CRL
  6548. //
  6549. // Add a CRL to a signed-data or signed-and-enveloped-data message.
  6550. //
  6551. // pvCtrlPara points to a CRYPT_DATA_BLOB containing the CRL's
  6552. // encoded bytes.
  6553. //--------------------------------------------------------------------------
  6554. //+-------------------------------------------------------------------------
  6555. // CMSG_CTRL_DEL_CRL
  6556. //
  6557. // Delete a CRL from a signed-data or signed-and-enveloped-data message.
  6558. //
  6559. // pvCtrlPara points to a DWORD containing the 0-based index of the CRL
  6560. // to be removed.
  6561. //--------------------------------------------------------------------------
  6562. //+-------------------------------------------------------------------------
  6563. // CMSG_CTRL_ADD_ATTR_CERT
  6564. //
  6565. // Add an attribute certificate to a signed-data message.
  6566. //
  6567. // pvCtrlPara points to a CRYPT_DATA_BLOB containing the attribute
  6568. // certificate's encoded bytes.
  6569. //--------------------------------------------------------------------------
  6570. //+-------------------------------------------------------------------------
  6571. // CMSG_CTRL_DEL_ATTR_CERT
  6572. //
  6573. // Delete an attribute certificate from a signed-data message.
  6574. //
  6575. // pvCtrlPara points to a DWORD containing the 0-based index of the
  6576. // attribute certificate to be removed.
  6577. //--------------------------------------------------------------------------
  6578. //+-------------------------------------------------------------------------
  6579. // Verify a countersignature, at the SignerInfo level.
  6580. // ie. verify that pbSignerInfoCountersignature contains the encrypted
  6581. // hash of the encryptedDigest field of pbSignerInfo.
  6582. //
  6583. // hCryptProv is used to hash the encryptedDigest field of pbSignerInfo.
  6584. // The only fields referenced from pciCountersigner are SerialNumber, Issuer,
  6585. // and SubjectPublicKeyInfo.
  6586. //--------------------------------------------------------------------------
  6587. function CryptMsgVerifyCountersignatureEncoded(hCryptProv: HCRYPTPROV;
  6588. dwEncodingType: DWORD; pbSignerInfo: PBYTE; cbSignerInfo: DWORD;
  6589. pbSignerInfoCountersignature: PBYTE; cbSignerInfoCountersignature: DWORD;
  6590. pciCountersigner: PCERT_INFO): BOOL; stdcall;
  6591. {$EXTERNALSYM CryptMsgVerifyCountersignatureEncoded}
  6592. //+-------------------------------------------------------------------------
  6593. // Verify a countersignature, at the SignerInfo level.
  6594. // ie. verify that pbSignerInfoCountersignature contains the encrypted
  6595. // hash of the encryptedDigest field of pbSignerInfo.
  6596. //
  6597. // hCryptProv is used to hash the encryptedDigest field of pbSignerInfo.
  6598. //
  6599. // The signer can be a CERT_PUBLIC_KEY_INFO, certificate context or a
  6600. // chain context.
  6601. //--------------------------------------------------------------------------
  6602. function CryptMsgVerifyCountersignatureEncodedEx(hCryptProv: HCRYPTPROV;
  6603. dwEncodingType: DWORD; pbSignerInfo: PBYTE; cbSignerInfo: DWORD;
  6604. pbSignerInfoCountersignature: PBYTE; cbSignerInfoCountersignature: DWORD;
  6605. dwSignerType: DWORD; pvSigner: Pointer; dwFlags: DWORD; pvReserved: Pointer): BOOL; stdcall;
  6606. {$EXTERNALSYM CryptMsgVerifyCountersignatureEncodedEx}
  6607. // See CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA for dwSignerType definitions
  6608. //+-------------------------------------------------------------------------
  6609. // Countersign an already-existing signature in a message
  6610. //
  6611. // dwIndex is a zero-based index of the SignerInfo to be countersigned.
  6612. //--------------------------------------------------------------------------
  6613. function CryptMsgCountersign(hCryptMsg: HCRYPTMSG; dwIndex, cCountersigners: DWORD;
  6614. rgCountersigners: PCMSG_SIGNER_ENCODE_INFO): BOOL; stdcall;
  6615. {$EXTERNALSYM CryptMsgCountersign}
  6616. //+-------------------------------------------------------------------------
  6617. // Countersign an already-existing signature (encoded SignerInfo).
  6618. // Output an encoded SignerInfo blob, suitable for use as a countersignature
  6619. // attribute in the unauthenticated attributes of a signed-data or
  6620. // signed-and-enveloped-data message.
  6621. //--------------------------------------------------------------------------
  6622. function CryptMsgCountersignEncoded(dwEncodingType: DWORD; pbSignerInfo: PBYTE;
  6623. cbSignerInfo: DWORD; cCountersigners: DWORD; rgCountersigners: PCMSG_SIGNER_ENCODE_INFO;
  6624. pbCountersignature: PBYTE; var pcbCountersignature: DWORD): BOOL; stdcall;
  6625. {$EXTERNALSYM CryptMsgCountersignEncoded}
  6626. //+-------------------------------------------------------------------------
  6627. // CryptMsg OID installable functions
  6628. //--------------------------------------------------------------------------
  6629. type
  6630. PFN_CMSG_ALLOC = function(cb: size_t): Pointer; stdcall;
  6631. {$EXTERNALSYM PFN_CMSG_ALLOC}
  6632. PFnCMsgAlloc = PFN_CMSG_ALLOC;
  6633. PFN_CMSG_FREE = procedure(pv: Pointer); stdcall;
  6634. {$EXTERNALSYM PFN_CMSG_FREE}
  6635. PFnCMsgFree = PFN_CMSG_FREE;
  6636. // Note, the following 3 installable functions are obsolete and have been
  6637. // replaced with GenContentEncryptKey, ExportKeyTrans, ExportKeyAgree,
  6638. // ExportMailList, ImportKeyTrans, ImportKeyAgree and ImportMailList
  6639. // installable functions.
  6640. // If *phCryptProv is NULL upon entry, then, if supported, the installable
  6641. // function should acquire a default provider and return. Note, its up
  6642. // to the installable function to release at process detach.
  6643. //
  6644. // If paiEncrypt->Parameters.cbData is 0, then, the callback may optionally
  6645. // return default encoded parameters in *ppbEncryptParameters and
  6646. // *pcbEncryptParameters. pfnAlloc must be called for the allocation.
  6647. const
  6648. CMSG_OID_GEN_ENCRYPT_KEY_FUNC = 'CryptMsgDllGenEncryptKey';
  6649. {$EXTERNALSYM CMSG_OID_GEN_ENCRYPT_KEY_FUNC}
  6650. type
  6651. PFN_CMSG_GEN_ENCRYPT_KEY = function(phCryptProv: PHCRYPTPROV;
  6652. paiEncrypt: PCRYPT_ALGORITHM_IDENTIFIER; pvEncryptAuxInfo: PVOID;
  6653. pPublicKeyInfo: PCERT_PUBLIC_KEY_INFO; pfnAlloc: PFN_CMSG_ALLOC;
  6654. var phEncryptKey: HCRYPTKEY; var ppbEncryptParameters: PBYTE;
  6655. pcbEncryptParameters: PDWORD): BOOL; stdcall;
  6656. {$EXTERNALSYM PFN_CMSG_GEN_ENCRYPT_KEY}
  6657. PfnCmsgGenEncryptKey = PFN_CMSG_GEN_ENCRYPT_KEY;
  6658. const
  6659. CMSG_OID_EXPORT_ENCRYPT_KEY_FUNC = 'CryptMsgDllExportEncryptKey';
  6660. {$EXTERNALSYM CMSG_OID_EXPORT_ENCRYPT_KEY_FUNC}
  6661. type
  6662. PFN_CMSG_EXPORT_ENCRYPT_KEY = function(hCryptProv: HCRYPTPROV;
  6663. hEncryptKey: HCRYPTKEY; pPublicKeyInfo: PCERT_PUBLIC_KEY_INFO;
  6664. pbData: PBYTE; var pcbData: DWORD): BOOL; stdcall;
  6665. {$EXTERNALSYM PFN_CMSG_EXPORT_ENCRYPT_KEY}
  6666. PfnCmsgExportEncryptKey = PFN_CMSG_EXPORT_ENCRYPT_KEY;
  6667. const
  6668. CMSG_OID_IMPORT_ENCRYPT_KEY_FUNC = 'CryptMsgDllImportEncryptKey';
  6669. {$EXTERNALSYM CMSG_OID_IMPORT_ENCRYPT_KEY_FUNC}
  6670. type
  6671. PFN_CMSG_IMPORT_ENCRYPT_KEY = function(hCryptProv: HCRYPTPROV;
  6672. dwKeySpec: DWORD; paiEncrypt: PCRYPT_ALGORITHM_IDENTIFIER;
  6673. paiPubKey: PCRYPT_ALGORITHM_IDENTIFIER; pbEncodedKey: PBYTE;
  6674. cbEncodedKey: DWORD; var phEncryptKey: HCRYPTKEY): BOOL; stdcall;
  6675. {$EXTERNALSYM PFN_CMSG_IMPORT_ENCRYPT_KEY}
  6676. PfnCmsgImportEncryptKey = PFN_CMSG_IMPORT_ENCRYPT_KEY;
  6677. // To get the default installable function for GenContentEncryptKey,
  6678. // ExportKeyTrans, ExportKeyAgree, ExportMailList, ImportKeyTrans,
  6679. // ImportKeyAgree or ImportMailList call CryptGetOIDFunctionAddress()
  6680. // with the pszOID argument set to the following constant. dwEncodingType
  6681. // should be set to CRYPT_ASN_ENCODING or X509_ASN_ENCODING.
  6682. const
  6683. CMSG_DEFAULT_INSTALLABLE_FUNC_OID = LPCSTR(1);
  6684. {$EXTERNALSYM CMSG_DEFAULT_INSTALLABLE_FUNC_OID}
  6685. //+-------------------------------------------------------------------------
  6686. // Content Encrypt Info
  6687. //
  6688. // The following data structure contains the information shared between
  6689. // the GenContentEncryptKey and the ExportKeyTrans, ExportKeyAgree and
  6690. // ExportMailList installable functions.
  6691. //--------------------------------------------------------------------------
  6692. type
  6693. PCMSG_CONTENT_ENCRYPT_INFO = ^CMSG_CONTENT_ENCRYPT_INFO;
  6694. {$EXTERNALSYM PCMSG_CONTENT_ENCRYPT_INFO}
  6695. _CMSG_CONTENT_ENCRYPT_INFO = record
  6696. cbSize: DWORD;
  6697. hCryptProv: HCRYPTPROV;
  6698. ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  6699. pvEncryptionAuxInfo: Pointer;
  6700. cRecipients: DWORD;
  6701. rgCmsRecipients: PCMSG_RECIPIENT_ENCODE_INFO;
  6702. pfnAlloc: PFN_CMSG_ALLOC;
  6703. pfnFree: PFN_CMSG_FREE;
  6704. dwEncryptFlags: DWORD;
  6705. hContentEncryptKey: HCRYPTKEY;
  6706. dwFlags: DWORD;
  6707. end;
  6708. {$EXTERNALSYM _CMSG_CONTENT_ENCRYPT_INFO}
  6709. CMSG_CONTENT_ENCRYPT_INFO = _CMSG_CONTENT_ENCRYPT_INFO;
  6710. {$EXTERNALSYM CMSG_CONTENT_ENCRYPT_INFO}
  6711. TCmsgContentEncryptInfo = CMSG_CONTENT_ENCRYPT_INFO;
  6712. PCmsgContentEncryptInfo = PCMSG_CONTENT_ENCRYPT_INFO;
  6713. const
  6714. CMSG_CONTENT_ENCRYPT_PAD_ENCODED_LEN_FLAG = $00000001;
  6715. {$EXTERNALSYM CMSG_CONTENT_ENCRYPT_PAD_ENCODED_LEN_FLAG}
  6716. CMSG_CONTENT_ENCRYPT_FREE_PARA_FLAG = $00000001;
  6717. {$EXTERNALSYM CMSG_CONTENT_ENCRYPT_FREE_PARA_FLAG}
  6718. CMSG_CONTENT_ENCRYPT_RELEASE_CONTEXT_FLAG = $00008000;
  6719. {$EXTERNALSYM CMSG_CONTENT_ENCRYPT_RELEASE_CONTEXT_FLAG}
  6720. //+-------------------------------------------------------------------------
  6721. // Upon input, ContentEncryptInfo has been initialized from the
  6722. // EnvelopedEncodeInfo.
  6723. //
  6724. // Note, if rgpRecipients instead of rgCmsRecipients are set in the
  6725. // EnvelopedEncodeInfo, then, the rgpRecipients have been converted
  6726. // to rgCmsRecipients in the ContentEncryptInfo.
  6727. //
  6728. // The following fields may be changed in ContentEncryptInfo:
  6729. // hContentEncryptKey
  6730. // hCryptProv
  6731. // ContentEncryptionAlgorithm.Parameters
  6732. // dwFlags
  6733. //
  6734. // All other fields in the ContentEncryptInfo are READONLY.
  6735. //
  6736. // If CMSG_CONTENT_ENCRYPT_PAD_ENCODED_LEN_FLAG is set upon entry
  6737. // in dwEncryptFlags, then, any potentially variable length encoded
  6738. // output should be padded with zeroes to always obtain the
  6739. // same maximum encoded length. This is necessary for
  6740. // CryptMsgCalculateEncodedLength() or CryptMsgOpenToEncode() with
  6741. // definite length streaming.
  6742. //
  6743. // The hContentEncryptKey must be updated.
  6744. //
  6745. // If hCryptProv is NULL upon input, then, it must be updated.
  6746. // If a HCRYPTPROV is acquired that must be released, then, the
  6747. // CMSG_CONTENT_ENCRYPT_RELEASE_CONTEXT_FLAG must be set in dwFlags.
  6748. //
  6749. // If ContentEncryptionAlgorithm.Parameters is updated, then, the
  6750. // CMSG_CONTENT_ENCRYPT_FREE_PARA_FLAG must be set in dwFlags. pfnAlloc and
  6751. // pfnFree must be used for doing the allocation.
  6752. //
  6753. // ContentEncryptionAlgorithm.pszObjId is used to get the OIDFunctionAddress.
  6754. //--------------------------------------------------------------------------
  6755. const
  6756. CMSG_OID_GEN_CONTENT_ENCRYPT_KEY_FUNC = 'CryptMsgDllGenContentEncryptKey';
  6757. {$EXTERNALSYM CMSG_OID_GEN_CONTENT_ENCRYPT_KEY_FUNC}
  6758. type
  6759. PFN_CMSG_GEN_CONTENT_ENCRYPT_KEY = function(pContentEncryptInfo: PCMSG_CONTENT_ENCRYPT_INFO;
  6760. dwFlags: DWORD; pvReserved: PPointer): BOOL; stdcall;
  6761. {$EXTERNALSYM PFN_CMSG_GEN_CONTENT_ENCRYPT_KEY}
  6762. PfnCmsgGenContentEncryptKey = PFN_CMSG_GEN_CONTENT_ENCRYPT_KEY;
  6763. //+-------------------------------------------------------------------------
  6764. // Key Transport Encrypt Info
  6765. //
  6766. // The following data structure contains the information updated by the
  6767. // ExportKeyTrans installable function.
  6768. //--------------------------------------------------------------------------
  6769. type
  6770. PCMSG_KEY_TRANS_ENCRYPT_INFO = ^CMSG_KEY_TRANS_ENCRYPT_INFO;
  6771. {$EXTERNALSYM PCMSG_KEY_TRANS_ENCRYPT_INFO}
  6772. _CMSG_KEY_TRANS_ENCRYPT_INFO = record
  6773. cbSize: DWORD;
  6774. dwRecipientIndex: DWORD;
  6775. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  6776. EncryptedKey: CRYPT_DATA_BLOB;
  6777. dwFlags: DWORD;
  6778. end;
  6779. {$EXTERNALSYM _CMSG_KEY_TRANS_ENCRYPT_INFO}
  6780. CMSG_KEY_TRANS_ENCRYPT_INFO = _CMSG_KEY_TRANS_ENCRYPT_INFO;
  6781. {$EXTERNALSYM CMSG_KEY_TRANS_ENCRYPT_INFO}
  6782. TCmsgKeyTransEncryptInfo = CMSG_KEY_TRANS_ENCRYPT_INFO;
  6783. PCmsgKeyTransEncryptInfo = PCMSG_KEY_TRANS_ENCRYPT_INFO;
  6784. const
  6785. CMSG_KEY_TRANS_ENCRYPT_FREE_PARA_FLAG = $00000001;
  6786. {$EXTERNALSYM CMSG_KEY_TRANS_ENCRYPT_FREE_PARA_FLAG}
  6787. //+-------------------------------------------------------------------------
  6788. // Upon input, KeyTransEncryptInfo has been initialized from the
  6789. // KeyTransEncodeInfo.
  6790. //
  6791. // The following fields may be changed in KeyTransEncryptInfo:
  6792. // EncryptedKey
  6793. // KeyEncryptionAlgorithm.Parameters
  6794. // dwFlags
  6795. //
  6796. // All other fields in the KeyTransEncryptInfo are READONLY.
  6797. //
  6798. // The EncryptedKey must be updated. The pfnAlloc and pfnFree specified in
  6799. // ContentEncryptInfo must be used for doing the allocation.
  6800. //
  6801. // If the KeyEncryptionAlgorithm.Parameters is updated, then, the
  6802. // CMSG_KEY_TRANS_ENCRYPT_FREE_PARA_FLAG must be set in dwFlags.
  6803. // The pfnAlloc and pfnFree specified in ContentEncryptInfo must be used
  6804. // for doing the allocation.
  6805. //
  6806. // KeyEncryptionAlgorithm.pszObjId is used to get the OIDFunctionAddress.
  6807. //--------------------------------------------------------------------------
  6808. const
  6809. CMSG_OID_EXPORT_KEY_TRANS_FUNC = 'CryptMsgDllExportKeyTrans';
  6810. {$EXTERNALSYM CMSG_OID_EXPORT_KEY_TRANS_FUNC}
  6811. type
  6812. PFN_CMSG_EXPORT_KEY_TRANS = function(pContentEncryptInfo: PCMSG_CONTENT_ENCRYPT_INFO;
  6813. pKeyTransEncodeInfo: PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO;
  6814. pKeyTransEncryptInfo: PCMSG_KEY_TRANS_ENCRYPT_INFO; dwFlags: DWORD;
  6815. pvReserved: Pointer): BOOL; stdcall;
  6816. {$EXTERNALSYM PFN_CMSG_EXPORT_KEY_TRANS}
  6817. PfnCmsgExportKeyTrans = PFN_CMSG_EXPORT_KEY_TRANS;
  6818. //+-------------------------------------------------------------------------
  6819. // Key Agree Key Encrypt Info
  6820. //
  6821. // The following data structure contains the information updated by the
  6822. // ExportKeyAgree installable function for each encrypted key agree
  6823. // recipient.
  6824. //--------------------------------------------------------------------------
  6825. type
  6826. PCMSG_KEY_AGREE_KEY_ENCRYPT_INFO = ^CMSG_KEY_AGREE_KEY_ENCRYPT_INFO;
  6827. {$EXTERNALSYM PCMSG_KEY_AGREE_KEY_ENCRYPT_INFO}
  6828. _CMSG_KEY_AGREE_KEY_ENCRYPT_INFO = record
  6829. cbSize: DWORD;
  6830. EncryptedKey: CRYPT_DATA_BLOB;
  6831. end;
  6832. {$EXTERNALSYM _CMSG_KEY_AGREE_KEY_ENCRYPT_INFO}
  6833. CMSG_KEY_AGREE_KEY_ENCRYPT_INFO = _CMSG_KEY_AGREE_KEY_ENCRYPT_INFO;
  6834. {$EXTERNALSYM CMSG_KEY_AGREE_KEY_ENCRYPT_INFO}
  6835. TCmsgKeyAgreeKeyEncryptInfo = CMSG_KEY_AGREE_KEY_ENCRYPT_INFO;
  6836. PCmsgKeyAgreeKeyEncryptInfo = PCMSG_KEY_AGREE_KEY_ENCRYPT_INFO;
  6837. PPCMSG_KEY_AGREE_KEY_ENCRYPT_INFO = ^PCMSG_KEY_AGREE_KEY_ENCRYPT_INFO;
  6838. {$NODEFINE PPCMSG_KEY_AGREE_KEY_ENCRYPT_INFO}
  6839. //+-------------------------------------------------------------------------
  6840. // Key Agree Encrypt Info
  6841. //
  6842. // The following data structure contains the information applicable to
  6843. // all recipients. Its updated by the ExportKeyAgree installable function.
  6844. //--------------------------------------------------------------------------
  6845. PCMSG_KEY_AGREE_ENCRYPT_INFO = ^CMSG_KEY_AGREE_ENCRYPT_INFO;
  6846. {$EXTERNALSYM PCMSG_KEY_AGREE_ENCRYPT_INFO}
  6847. _CMSG_KEY_AGREE_ENCRYPT_INFO = record
  6848. cbSize: DWORD;
  6849. dwRecipientIndex: DWORD;
  6850. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  6851. UserKeyingMaterial: CRYPT_DATA_BLOB;
  6852. dwOriginatorChoice: DWORD;
  6853. Union: record
  6854. case Integer of
  6855. // CMSG_KEY_AGREE_ORIGINATOR_CERT
  6856. 0: (OriginatorCertId: CERT_ID);
  6857. // CMSG_KEY_AGREE_ORIGINATOR_PUBLIC_KEY
  6858. 1: (OriginatorPublicKeyInfo: CERT_PUBLIC_KEY_INFO);
  6859. end;
  6860. cKeyAgreeKeyEncryptInfo: DWORD;
  6861. rgpKeyAgreeKeyEncryptInfo: PPCMSG_KEY_AGREE_KEY_ENCRYPT_INFO;
  6862. dwFlags: DWORD;
  6863. end;
  6864. {$EXTERNALSYM _CMSG_KEY_AGREE_ENCRYPT_INFO}
  6865. CMSG_KEY_AGREE_ENCRYPT_INFO = _CMSG_KEY_AGREE_ENCRYPT_INFO;
  6866. {$EXTERNALSYM CMSG_KEY_AGREE_ENCRYPT_INFO}
  6867. TCmsgKeyAgreeEncryptInfo = CMSG_KEY_AGREE_ENCRYPT_INFO;
  6868. PCmsgKeyAgreeEncryptInfo = PCMSG_KEY_AGREE_ENCRYPT_INFO;
  6869. const
  6870. CMSG_KEY_AGREE_ENCRYPT_FREE_PARA_FLAG = $00000001;
  6871. {$EXTERNALSYM CMSG_KEY_AGREE_ENCRYPT_FREE_PARA_FLAG}
  6872. CMSG_KEY_AGREE_ENCRYPT_FREE_MATERIAL_FLAG = $00000002;
  6873. {$EXTERNALSYM CMSG_KEY_AGREE_ENCRYPT_FREE_MATERIAL_FLAG}
  6874. CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_ALG_FLAG = $00000004;
  6875. {$EXTERNALSYM CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_ALG_FLAG}
  6876. CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_PARA_FLAG = $00000008;
  6877. {$EXTERNALSYM CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_PARA_FLAG}
  6878. CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_BITS_FLAG = $00000010;
  6879. {$EXTERNALSYM CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_BITS_FLAG}
  6880. //+-------------------------------------------------------------------------
  6881. // Upon input, KeyAgreeEncryptInfo has been initialized from the
  6882. // KeyAgreeEncodeInfo.
  6883. //
  6884. // The following fields may be changed in KeyAgreeEncryptInfo:
  6885. // KeyEncryptionAlgorithm.Parameters
  6886. // UserKeyingMaterial
  6887. // dwOriginatorChoice
  6888. // OriginatorCertId
  6889. // OriginatorPublicKeyInfo
  6890. // dwFlags
  6891. //
  6892. // All other fields in the KeyAgreeEncryptInfo are READONLY.
  6893. //
  6894. // If the KeyEncryptionAlgorithm.Parameters is updated, then, the
  6895. // CMSG_KEY_AGREE_ENCRYPT_FREE_PARA_FLAG must be set in dwFlags.
  6896. // The pfnAlloc and pfnFree specified in ContentEncryptInfo must be used
  6897. // for doing the allocation.
  6898. //
  6899. // If the UserKeyingMaterial is updated, then, the
  6900. // CMSG_KEY_AGREE_ENCRYPT_FREE_MATERIAL_FLAG must be set in dwFlags.
  6901. // pfnAlloc and pfnFree must be used for doing the allocation.
  6902. //
  6903. // The dwOriginatorChoice must be updated to either
  6904. // CMSG_KEY_AGREE_ORIGINATOR_CERT or CMSG_KEY_AGREE_ORIGINATOR_PUBLIC_KEY.
  6905. //
  6906. // If the OriginatorPublicKeyInfo is updated, then, the appropriate
  6907. // CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_*_FLAG must be set in dwFlags and
  6908. // pfnAlloc and pfnFree must be used for doing the allocation.
  6909. //
  6910. // If CMSG_CONTENT_ENCRYPT_PAD_ENCODED_LEN_FLAG is set upon entry
  6911. // in pContentEncryptInfo->dwEncryptFlags, then, the OriginatorPublicKeyInfo's
  6912. // Ephemeral PublicKey should be padded with zeroes to always obtain the
  6913. // same maximum encoded length. Note, the length of the generated ephemeral Y
  6914. // public key can vary depending on the number of leading zero bits.
  6915. //
  6916. // Upon input, the array of *rgpKeyAgreeKeyEncryptInfo has been initialized.
  6917. // The EncryptedKey must be updated for each recipient key.
  6918. // The pfnAlloc and pfnFree specified in
  6919. // ContentEncryptInfo must be used for doing the allocation.
  6920. //
  6921. // KeyEncryptionAlgorithm.pszObjId is used to get the OIDFunctionAddress.
  6922. //--------------------------------------------------------------------------
  6923. const
  6924. CMSG_OID_EXPORT_KEY_AGREE_FUNC = 'CryptMsgDllExportKeyAgree';
  6925. {$EXTERNALSYM CMSG_OID_EXPORT_KEY_AGREE_FUNC}
  6926. type
  6927. PFN_CMSG_EXPORT_KEY_AGREE = function(pContentEncryptInfo: PCMSG_CONTENT_ENCRYPT_INFO;
  6928. pKeyAgreeEncodeInfo: PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO;
  6929. pKeyAgreeEncryptInfo: PCMSG_KEY_AGREE_ENCRYPT_INFO; dwFlags: DWORD;
  6930. pvReserved: Pointer): BOOL; stdcall;
  6931. {$EXTERNALSYM PFN_CMSG_EXPORT_KEY_AGREE}
  6932. PfnCmsgExportKeyAgree = PFN_CMSG_EXPORT_KEY_AGREE;
  6933. //+-------------------------------------------------------------------------
  6934. // Mail List Encrypt Info
  6935. //
  6936. // The following data structure contains the information updated by the
  6937. // ExportMailList installable function.
  6938. //--------------------------------------------------------------------------
  6939. type
  6940. PCMSG_MAIL_LIST_ENCRYPT_INFO = ^CMSG_MAIL_LIST_ENCRYPT_INFO;
  6941. {$EXTERNALSYM PCMSG_MAIL_LIST_ENCRYPT_INFO}
  6942. _CMSG_MAIL_LIST_ENCRYPT_INFO = record
  6943. cbSize: DWORD;
  6944. dwRecipientIndex: DWORD;
  6945. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  6946. EncryptedKey: CRYPT_DATA_BLOB;
  6947. dwFlags: DWORD;
  6948. end;
  6949. {$EXTERNALSYM _CMSG_MAIL_LIST_ENCRYPT_INFO}
  6950. CMSG_MAIL_LIST_ENCRYPT_INFO = _CMSG_MAIL_LIST_ENCRYPT_INFO;
  6951. {$EXTERNALSYM CMSG_MAIL_LIST_ENCRYPT_INFO}
  6952. TCmsgMailListEncryptInfo = CMSG_MAIL_LIST_ENCRYPT_INFO;
  6953. PCmsgMailListEncryptInfo = PCMSG_MAIL_LIST_ENCRYPT_INFO;
  6954. const
  6955. CMSG_MAIL_LIST_ENCRYPT_FREE_PARA_FLAG = $00000001;
  6956. {$EXTERNALSYM CMSG_MAIL_LIST_ENCRYPT_FREE_PARA_FLAG}
  6957. //+-------------------------------------------------------------------------
  6958. // Upon input, MailListEncryptInfo has been initialized from the
  6959. // MailListEncodeInfo.
  6960. //
  6961. // The following fields may be changed in MailListEncryptInfo:
  6962. // EncryptedKey
  6963. // KeyEncryptionAlgorithm.Parameters
  6964. // dwFlags
  6965. //
  6966. // All other fields in the MailListEncryptInfo are READONLY.
  6967. //
  6968. // The EncryptedKey must be updated. The pfnAlloc and pfnFree specified in
  6969. // ContentEncryptInfo must be used for doing the allocation.
  6970. //
  6971. // If the KeyEncryptionAlgorithm.Parameters is updated, then, the
  6972. // CMSG_MAIL_LIST_ENCRYPT_FREE_PARA_FLAG must be set in dwFlags.
  6973. // The pfnAlloc and pfnFree specified in ContentEncryptInfo must be used
  6974. // for doing the allocation.
  6975. //
  6976. // KeyEncryptionAlgorithm.pszObjId is used to get the OIDFunctionAddress.
  6977. //--------------------------------------------------------------------------
  6978. const
  6979. CMSG_OID_EXPORT_MAIL_LIST_FUNC = 'CryptMsgDllExportMailList';
  6980. {$EXTERNALSYM CMSG_OID_EXPORT_MAIL_LIST_FUNC}
  6981. type
  6982. PFN_CMSG_EXPORT_MAIL_LIST = function(pContentEncryptInfo: PCMSG_CONTENT_ENCRYPT_INFO;
  6983. pMailListEncodeInfo: PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO;
  6984. pMailListEncryptInfo: PCMSG_MAIL_LIST_ENCRYPT_INFO; dwFlags: DWORD;
  6985. pvReserved: Pointer): BOOL; stdcall;
  6986. {$EXTERNALSYM PFN_CMSG_EXPORT_MAIL_LIST}
  6987. PfnCmsgExportMailList = PFN_CMSG_EXPORT_MAIL_LIST;
  6988. //+-------------------------------------------------------------------------
  6989. // OID Installable functions for importing an encoded and encrypted content
  6990. // encryption key.
  6991. //
  6992. // There's a different installable function for each CMS Recipient choice:
  6993. // ImportKeyTrans
  6994. // ImportKeyAgree
  6995. // ImportMailList
  6996. //
  6997. // Iterates through the following OIDs to get the OID installable function:
  6998. // KeyEncryptionOID!ContentEncryptionOID
  6999. // KeyEncryptionOID
  7000. // ContentEncryptionOID
  7001. //
  7002. // If the OID installable function doesn't support the specified
  7003. // KeyEncryption and ContentEncryption OIDs, then, return FALSE with
  7004. // LastError set to E_NOTIMPL.
  7005. //--------------------------------------------------------------------------
  7006. const
  7007. CMSG_OID_IMPORT_KEY_TRANS_FUNC = 'CryptMsgDllImportKeyTrans';
  7008. {$EXTERNALSYM CMSG_OID_IMPORT_KEY_TRANS_FUNC}
  7009. type
  7010. PFN_CMSG_IMPORT_KEY_TRANS = function(pContentEncryptionAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER;
  7011. pKeyTransDecryptPara: PCMSG_CTRL_KEY_TRANS_DECRYPT_PARA; dwFlags: DWORD;
  7012. pvReserved: Pointer; var phContentEncryptKey: HCRYPTKEY): BOOL; stdcall;
  7013. {$EXTERNALSYM PFN_CMSG_IMPORT_KEY_TRANS}
  7014. PfnCmsgImportKeyTrans = PFN_CMSG_IMPORT_KEY_TRANS;
  7015. const
  7016. CMSG_OID_IMPORT_KEY_AGREE_FUNC = 'CryptMsgDllImportKeyAgree';
  7017. {$EXTERNALSYM CMSG_OID_IMPORT_KEY_AGREE_FUNC}
  7018. type
  7019. PFN_CMSG_IMPORT_KEY_AGREE = function(pContentEncryptionAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER;
  7020. pKeyAgreeDecryptPara: PCMSG_CTRL_KEY_AGREE_DECRYPT_PARA; dwFlags: DWORD;
  7021. pvReserved: Pointer; var phContentEncryptKey: HCRYPTKEY): BOOL; stdcall;
  7022. {$EXTERNALSYM PFN_CMSG_IMPORT_KEY_AGREE}
  7023. PfnCmsgImportKeyAgree = PFN_CMSG_IMPORT_KEY_AGREE;
  7024. const
  7025. CMSG_OID_IMPORT_MAIL_LIST_FUNC = 'CryptMsgDllImportMailList';
  7026. {$EXTERNALSYM CMSG_OID_IMPORT_MAIL_LIST_FUNC}
  7027. type
  7028. PFN_CMSG_IMPORT_MAIL_LIST = function(pContentEncryptionAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER;
  7029. pMailListDecryptPara: PCMSG_CTRL_MAIL_LIST_DECRYPT_PARA; dwFlags: DWORD;
  7030. pvReserved: Pointer; var phContentEncryptKey: HCRYPTKEY): BOOL; stdcall;
  7031. {$EXTERNALSYM PFN_CMSG_IMPORT_MAIL_LIST}
  7032. PfnCmsgImportMailList = PFN_CMSG_IMPORT_MAIL_LIST;
  7033. //+=========================================================================
  7034. // Certificate Store Data Structures and APIs
  7035. //==========================================================================
  7036. //+-------------------------------------------------------------------------
  7037. // In its most basic implementation, a cert store is simply a
  7038. // collection of certificates and/or CRLs. This is the case when
  7039. // a cert store is opened with all of its certificates and CRLs
  7040. // coming from a PKCS #7 encoded cryptographic message.
  7041. //
  7042. // Nonetheless, all cert stores have the following properties:
  7043. // - A public key may have more than one certificate in the store.
  7044. // For example, a private/public key used for signing may have a
  7045. // certificate issued for VISA and another issued for
  7046. // Mastercard. Also, when a certificate is renewed there might
  7047. // be more than one certificate with the same subject and
  7048. // issuer.
  7049. // - However, each certificate in the store is uniquely
  7050. // identified by its Issuer and SerialNumber.
  7051. // - There's an issuer of subject certificate relationship. A
  7052. // certificate's issuer is found by doing a match of
  7053. // pSubjectCert->Issuer with pIssuerCert->Subject.
  7054. // The relationship is verified by using
  7055. // the issuer's public key to verify the subject certificate's
  7056. // signature. Note, there might be X.509 v3 extensions
  7057. // to assist in finding the issuer certificate.
  7058. // - Since issuer certificates might be renewed, a subject
  7059. // certificate might have more than one issuer certificate.
  7060. // - There's an issuer of CRL relationship. An
  7061. // issuer's CRL is found by doing a match of
  7062. // pIssuerCert->Subject with pCrl->Issuer.
  7063. // The relationship is verified by using
  7064. // the issuer's public key to verify the CRL's
  7065. // signature. Note, there might be X.509 v3 extensions
  7066. // to assist in finding the CRL.
  7067. // - Since some issuers might support the X.509 v3 delta CRL
  7068. // extensions, an issuer might have more than one CRL.
  7069. // - The store shouldn't have any redundant certificates or
  7070. // CRLs. There shouldn't be two certificates with the same
  7071. // Issuer and SerialNumber. There shouldn't be two CRLs with
  7072. // the same Issuer, ThisUpdate and NextUpdate.
  7073. // - The store has NO policy or trust information. No
  7074. // certificates are tagged as being "root". Its up to
  7075. // the application to maintain a list of CertIds (Issuer +
  7076. // SerialNumber) for certificates it trusts.
  7077. // - The store might contain bad certificates and/or CRLs.
  7078. // The issuer's signature of a subject certificate or CRL may
  7079. // not verify. Certificates or CRLs may not satisfy their
  7080. // time validity requirements. Certificates may be
  7081. // revoked.
  7082. //
  7083. // In addition to the certificates and CRLs, properties can be
  7084. // stored. There are two predefined property IDs for a user
  7085. // certificate: CERT_KEY_PROV_HANDLE_PROP_ID and
  7086. // CERT_KEY_PROV_INFO_PROP_ID. The CERT_KEY_PROV_HANDLE_PROP_ID
  7087. // is a HCRYPTPROV handle to the private key assoicated
  7088. // with the certificate. The CERT_KEY_PROV_INFO_PROP_ID contains
  7089. // information to be used to call
  7090. // CryptAcquireContext and CryptSetProvParam to get a handle
  7091. // to the private key associated with the certificate.
  7092. //
  7093. // There exists two more predefined property IDs for certificates
  7094. // and CRLs, CERT_SHA1_HASH_PROP_ID and CERT_MD5_HASH_PROP_ID.
  7095. // If these properties don't already exist, then, a hash of the
  7096. // content is computed. (CERT_HASH_PROP_ID maps to the default
  7097. // hash algorithm, currently, CERT_SHA1_HASH_PROP_ID).
  7098. //
  7099. // There are additional APIs for creating certificate and CRL
  7100. // contexts not in a store (CertCreateCertificateContext and
  7101. // CertCreateCRLContext).
  7102. //
  7103. //--------------------------------------------------------------------------
  7104. type
  7105. HCERTSTORE = Pointer;
  7106. {$EXTERNALSYM HCERTSTORE}
  7107. PHCERTSTORE = ^HCERTSTORE;
  7108. {$NODEFINE PHCERTSTORE}
  7109. //+-------------------------------------------------------------------------
  7110. // Certificate context.
  7111. //
  7112. // A certificate context contains both the encoded and decoded representation
  7113. // of a certificate. A certificate context returned by a cert store function
  7114. // must be freed by calling the CertFreeCertificateContext function. The
  7115. // CertDuplicateCertificateContext function can be called to make a duplicate
  7116. // copy (which also must be freed by calling CertFreeCertificateContext).
  7117. //--------------------------------------------------------------------------
  7118. PCERT_CONTEXT = ^CERT_CONTEXT;
  7119. {$EXTERNALSYM CERT_CONTEXT}
  7120. _CERT_CONTEXT = record
  7121. dwCertEncodingType: DWORD;
  7122. pbCertEncoded: LPBYTE;
  7123. cbCertEncoded: DWORD;
  7124. pCertInfo: PCERT_INFO;
  7125. hCertStore: HCERTSTORE;
  7126. end;
  7127. {$EXTERNALSYM _CERT_CONTEXT}
  7128. CERT_CONTEXT = _CERT_CONTEXT;
  7129. {$EXTERNALSYM CERT_CONTEXT}
  7130. TCertContext = CERT_CONTEXT;
  7131. PCertContext = PCERT_CONTEXT;
  7132. PCCERT_CONTEXT = PCERT_CONTEXT;
  7133. {$EXTERNALSYM PCCERT_CONTEXT}
  7134. PPCCERT_CONTEXT = ^PCCERT_CONTEXT;
  7135. {$NODEFINE PCCERT_CONTEXT}
  7136. //+-------------------------------------------------------------------------
  7137. // CRL context.
  7138. //
  7139. // A CRL context contains both the encoded and decoded representation
  7140. // of a CRL. A CRL context returned by a cert store function
  7141. // must be freed by calling the CertFreeCRLContext function. The
  7142. // CertDuplicateCRLContext function can be called to make a duplicate
  7143. // copy (which also must be freed by calling CertFreeCRLContext).
  7144. //--------------------------------------------------------------------------
  7145. PCRL_CONTEXT = ^CRL_CONTEXT;
  7146. {$EXTERNALSYM PCRL_CONTEXT}
  7147. _CRL_CONTEXT = record
  7148. dwCertEncodingType: DWORD;
  7149. pbCrlEncoded: LPBYTE;
  7150. cbCrlEncoded: DWORD;
  7151. pCrlInfo: PCRL_INFO;
  7152. hCertStore: HCERTSTORE;
  7153. end;
  7154. {$EXTERNALSYM _CRL_CONTEXT}
  7155. CRL_CONTEXT = _CRL_CONTEXT;
  7156. {$EXTERNALSYM CRL_CONTEXT}
  7157. TCrlContext = CRL_CONTEXT;
  7158. PCrlContext = PCRL_CONTEXT;
  7159. PCCRL_CONTEXT = PCRL_CONTEXT;
  7160. {$EXTERNALSYM PCCRL_CONTEXT}
  7161. PPCCRL_CONTEXT = ^PCCRL_CONTEXT;
  7162. {$NODEFINE PPCCRL_CONTEXT}
  7163. //+-------------------------------------------------------------------------
  7164. // Certificate Trust List (CTL) context.
  7165. //
  7166. // A CTL context contains both the encoded and decoded representation
  7167. // of a CTL. Also contains an opened HCRYPTMSG handle to the decoded
  7168. // cryptographic signed message containing the CTL_INFO as its inner content.
  7169. // pbCtlContent is the encoded inner content of the signed message.
  7170. //
  7171. // The CryptMsg APIs can be used to extract additional signer information.
  7172. //--------------------------------------------------------------------------
  7173. PCTL_CONTEXT = ^CTL_CONTEXT;
  7174. {$EXTERNALSYM PCTL_CONTEXT}
  7175. _CTL_CONTEXT = record
  7176. dwMsgAndCertEncodingType: DWORD;
  7177. pbCtlEncoded: LPBYTE;
  7178. cbCtlEncoded: DWORD;
  7179. pCtlInfo: PCTL_INFO;
  7180. hCertStore: HCERTSTORE;
  7181. hCryptMsg: HCRYPTMSG;
  7182. pbCtlContent: LPBYTE;
  7183. cbCtlContent: DWORD;
  7184. end;
  7185. {$EXTERNALSYM _CTL_CONTEXT}
  7186. CTL_CONTEXT = _CTL_CONTEXT;
  7187. {$EXTERNALSYM CTL_CONTEXT}
  7188. TCtlContext = CTL_CONTEXT;
  7189. PCtlContext = PCTL_CONTEXT;
  7190. PCCTL_CONTEXT = PCTL_CONTEXT;
  7191. {$EXTERNALSYM PCCTL_CONTEXT}
  7192. PPCCTL_CONTEXT = ^PCCTL_CONTEXT;
  7193. {$EXTERNALSYM PPCCTL_CONTEXT}
  7194. //+-------------------------------------------------------------------------
  7195. // Certificate, CRL and CTL property IDs
  7196. //
  7197. // See CertSetCertificateContextProperty or CertGetCertificateContextProperty
  7198. // for usage information.
  7199. //--------------------------------------------------------------------------
  7200. const
  7201. CERT_KEY_PROV_HANDLE_PROP_ID = 1;
  7202. {$EXTERNALSYM CERT_KEY_PROV_HANDLE_PROP_ID}
  7203. CERT_KEY_PROV_INFO_PROP_ID = 2;
  7204. {$EXTERNALSYM CERT_KEY_PROV_INFO_PROP_ID}
  7205. CERT_SHA1_HASH_PROP_ID = 3;
  7206. {$EXTERNALSYM CERT_SHA1_HASH_PROP_ID}
  7207. CERT_MD5_HASH_PROP_ID = 4;
  7208. {$EXTERNALSYM CERT_MD5_HASH_PROP_ID}
  7209. CERT_HASH_PROP_ID = CERT_SHA1_HASH_PROP_ID;
  7210. {$EXTERNALSYM CERT_HASH_PROP_ID}
  7211. CERT_KEY_CONTEXT_PROP_ID = 5;
  7212. {$EXTERNALSYM CERT_KEY_CONTEXT_PROP_ID}
  7213. CERT_KEY_SPEC_PROP_ID = 6;
  7214. {$EXTERNALSYM CERT_KEY_SPEC_PROP_ID}
  7215. CERT_IE30_RESERVED_PROP_ID = 7;
  7216. {$EXTERNALSYM CERT_IE30_RESERVED_PROP_ID}
  7217. CERT_PUBKEY_HASH_RESERVED_PROP_ID = 8;
  7218. {$EXTERNALSYM CERT_PUBKEY_HASH_RESERVED_PROP_ID}
  7219. CERT_ENHKEY_USAGE_PROP_ID = 9;
  7220. {$EXTERNALSYM CERT_ENHKEY_USAGE_PROP_ID}
  7221. CERT_CTL_USAGE_PROP_ID = CERT_ENHKEY_USAGE_PROP_ID;
  7222. {$EXTERNALSYM CERT_CTL_USAGE_PROP_ID}
  7223. CERT_NEXT_UPDATE_LOCATION_PROP_ID = 10;
  7224. {$EXTERNALSYM CERT_NEXT_UPDATE_LOCATION_PROP_ID}
  7225. CERT_FRIENDLY_NAME_PROP_ID = 11;
  7226. {$EXTERNALSYM CERT_FRIENDLY_NAME_PROP_ID}
  7227. CERT_PVK_FILE_PROP_ID = 12;
  7228. {$EXTERNALSYM CERT_PVK_FILE_PROP_ID}
  7229. CERT_DESCRIPTION_PROP_ID = 13;
  7230. {$EXTERNALSYM CERT_DESCRIPTION_PROP_ID}
  7231. CERT_ACCESS_STATE_PROP_ID = 14;
  7232. {$EXTERNALSYM CERT_ACCESS_STATE_PROP_ID}
  7233. CERT_SIGNATURE_HASH_PROP_ID = 15;
  7234. {$EXTERNALSYM CERT_SIGNATURE_HASH_PROP_ID}
  7235. CERT_SMART_CARD_DATA_PROP_ID = 16;
  7236. {$EXTERNALSYM CERT_SMART_CARD_DATA_PROP_ID}
  7237. CERT_EFS_PROP_ID = 17;
  7238. {$EXTERNALSYM CERT_EFS_PROP_ID}
  7239. CERT_FORTEZZA_DATA_PROP_ID = 18;
  7240. {$EXTERNALSYM CERT_FORTEZZA_DATA_PROP_ID}
  7241. CERT_ARCHIVED_PROP_ID = 19;
  7242. {$EXTERNALSYM CERT_ARCHIVED_PROP_ID}
  7243. CERT_KEY_IDENTIFIER_PROP_ID = 20;
  7244. {$EXTERNALSYM CERT_KEY_IDENTIFIER_PROP_ID}
  7245. CERT_AUTO_ENROLL_PROP_ID = 21;
  7246. {$EXTERNALSYM CERT_AUTO_ENROLL_PROP_ID}
  7247. CERT_PUBKEY_ALG_PARA_PROP_ID = 22;
  7248. {$EXTERNALSYM CERT_PUBKEY_ALG_PARA_PROP_ID}
  7249. CERT_FIRST_RESERVED_PROP_ID = 23;
  7250. {$EXTERNALSYM CERT_FIRST_RESERVED_PROP_ID}
  7251. // Note, 32 - 35 are reserved for the CERT, CRL, CTL and KeyId file element IDs.
  7252. CERT_LAST_RESERVED_PROP_ID = $00007FFF;
  7253. {$EXTERNALSYM CERT_LAST_RESERVED_PROP_ID}
  7254. CERT_FIRST_USER_PROP_ID = $00008000;
  7255. {$EXTERNALSYM CERT_FIRST_USER_PROP_ID}
  7256. CERT_LAST_USER_PROP_ID = $0000FFFF;
  7257. {$EXTERNALSYM CERT_LAST_USER_PROP_ID}
  7258. function IS_CERT_HASH_PROP_ID(X: DWORD): Boolean;
  7259. {$EXTERNALSYM IS_CERT_HASH_PROP_ID}
  7260. //+-------------------------------------------------------------------------
  7261. // Access State flags returned by CERT_ACCESS_STATE_PROP_ID. Note,
  7262. // CERT_ACCESS_PROP_ID is read only.
  7263. //--------------------------------------------------------------------------
  7264. // Set if context property writes are persisted. For instance, not set for
  7265. // memory store contexts. Set for registry based stores opened as read or write.
  7266. // Not set for registry based stores opened as read only.
  7267. const
  7268. CERT_ACCESS_STATE_WRITE_PERSIST_FLAG = $1;
  7269. {$EXTERNALSYM CERT_ACCESS_STATE_WRITE_PERSIST_FLAG}
  7270. // Set if context resides in a SYSTEM or SYSTEM_REGISTRY store.
  7271. CERT_ACCESS_STATE_SYSTEM_STORE_FLAG = $2;
  7272. {$EXTERNALSYM CERT_ACCESS_STATE_SYSTEM_STORE_FLAG}
  7273. //+-------------------------------------------------------------------------
  7274. // Cryptographic Key Provider Information
  7275. //
  7276. // CRYPT_KEY_PROV_INFO defines the CERT_KEY_PROV_INFO_PROP_ID's pvData.
  7277. //
  7278. // The CRYPT_KEY_PROV_INFO fields are passed to CryptAcquireContext
  7279. // to get a HCRYPTPROV handle. The optional CRYPT_KEY_PROV_PARAM fields are
  7280. // passed to CryptSetProvParam to further initialize the provider.
  7281. //
  7282. // The dwKeySpec field identifies the private key to use from the container
  7283. // For example, AT_KEYEXCHANGE or AT_SIGNATURE.
  7284. //--------------------------------------------------------------------------
  7285. type
  7286. PCRYPT_KEY_PROV_PARAM = ^CRYPT_KEY_PROV_PARAM;
  7287. {$EXTERNALSYM PCRYPT_KEY_PROV_PARAM}
  7288. _CRYPT_KEY_PROV_PARAM = record
  7289. dwParam: DWORD;
  7290. pbData: LPBYTE;
  7291. cbData: DWORD;
  7292. dwFlags: DWORD;
  7293. end;
  7294. {$EXTERNALSYM _CRYPT_KEY_PROV_PARAM}
  7295. CRYPT_KEY_PROV_PARAM = _CRYPT_KEY_PROV_PARAM;
  7296. {$EXTERNALSYM CRYPT_KEY_PROV_PARAM}
  7297. TCryptKeyProvParam = CRYPT_KEY_PROV_PARAM;
  7298. PCryptKeyProvParam = PCRYPT_KEY_PROV_PARAM;
  7299. PCRYPT_KEY_PROV_INFO = ^CRYPT_KEY_PROV_INFO;
  7300. {$EXTERNALSYM PCRYPT_KEY_PROV_INFO}
  7301. _CRYPT_KEY_PROV_INFO = record
  7302. pwszContainerName: LPWSTR;
  7303. pwszProvName: LPWSTR;
  7304. dwProvType: DWORD;
  7305. dwFlags: DWORD;
  7306. cProvParam: DWORD;
  7307. rgProvParam: PCRYPT_KEY_PROV_PARAM;
  7308. dwKeySpec: DWORD;
  7309. end;
  7310. {$EXTERNALSYM _CRYPT_KEY_PROV_INFO}
  7311. CRYPT_KEY_PROV_INFO = _CRYPT_KEY_PROV_INFO;
  7312. {$EXTERNALSYM CRYPT_KEY_PROV_INFO}
  7313. TCryptKeyProvInfo = CRYPT_KEY_PROV_INFO;
  7314. PCryptKeyProvInfo = PCRYPT_KEY_PROV_INFO;
  7315. //+-------------------------------------------------------------------------
  7316. // The following flag should be set in the above dwFlags to enable
  7317. // a CertSetCertificateContextProperty(CERT_KEY_CONTEXT_PROP_ID) after a
  7318. // CryptAcquireContext is done in the Sign or Decrypt Message functions.
  7319. //
  7320. // The following define must not collide with any of the
  7321. // CryptAcquireContext dwFlag defines.
  7322. //--------------------------------------------------------------------------
  7323. const
  7324. CERT_SET_KEY_PROV_HANDLE_PROP_ID = $00000001;
  7325. {$EXTERNALSYM CERT_SET_KEY_PROV_HANDLE_PROP_ID}
  7326. CERT_SET_KEY_CONTEXT_PROP_ID = $00000001;
  7327. {$EXTERNALSYM CERT_SET_KEY_CONTEXT_PROP_ID}
  7328. //+-------------------------------------------------------------------------
  7329. // Certificate Key Context
  7330. //
  7331. // CERT_KEY_CONTEXT defines the CERT_KEY_CONTEXT_PROP_ID's pvData.
  7332. //--------------------------------------------------------------------------
  7333. type
  7334. PCERT_KEY_CONTEXT = ^CERT_KEY_CONTEXT;
  7335. {$EXTERNALSYM PCERT_KEY_CONTEXT}
  7336. _CERT_KEY_CONTEXT = record
  7337. cbSize: DWORD; // sizeof(CERT_KEY_CONTEXT)
  7338. hCryptProv: HCRYPTPROV;
  7339. dwKeySpec: DWORD;
  7340. end;
  7341. {$EXTERNALSYM _CERT_KEY_CONTEXT}
  7342. CERT_KEY_CONTEXT = _CERT_KEY_CONTEXT;
  7343. {$EXTERNALSYM CERT_KEY_CONTEXT}
  7344. TCertKeyContext = CERT_KEY_CONTEXT;
  7345. PCertKeyContext = PCERT_KEY_CONTEXT;
  7346. //+-------------------------------------------------------------------------
  7347. // Certificate Store Provider Types
  7348. //--------------------------------------------------------------------------
  7349. const
  7350. CERT_STORE_PROV_MSG = LPCSTR(1);
  7351. {$EXTERNALSYM CERT_STORE_PROV_MSG}
  7352. CERT_STORE_PROV_MEMORY = LPCSTR(2);
  7353. {$EXTERNALSYM CERT_STORE_PROV_MEMORY}
  7354. CERT_STORE_PROV_FILE = LPCSTR(3);
  7355. {$EXTERNALSYM CERT_STORE_PROV_FILE}
  7356. CERT_STORE_PROV_REG = LPCSTR(4);
  7357. {$EXTERNALSYM CERT_STORE_PROV_REG}
  7358. CERT_STORE_PROV_PKCS7 = LPCSTR(5);
  7359. {$EXTERNALSYM CERT_STORE_PROV_PKCS7}
  7360. CERT_STORE_PROV_SERIALIZED = LPCSTR(6);
  7361. {$EXTERNALSYM CERT_STORE_PROV_SERIALIZED}
  7362. CERT_STORE_PROV_FILENAME_A = LPCSTR(7);
  7363. {$EXTERNALSYM CERT_STORE_PROV_FILENAME_A}
  7364. CERT_STORE_PROV_FILENAME_W = LPCSTR(8);
  7365. {$EXTERNALSYM CERT_STORE_PROV_FILENAME_W}
  7366. CERT_STORE_PROV_FILENAME = CERT_STORE_PROV_FILENAME_W;
  7367. {$EXTERNALSYM CERT_STORE_PROV_FILENAME}
  7368. CERT_STORE_PROV_SYSTEM_A = LPCSTR(9);
  7369. {$EXTERNALSYM CERT_STORE_PROV_SYSTEM_A}
  7370. CERT_STORE_PROV_SYSTEM_W = LPCSTR(10);
  7371. {$EXTERNALSYM CERT_STORE_PROV_SYSTEM_W}
  7372. CERT_STORE_PROV_SYSTEM = CERT_STORE_PROV_SYSTEM_W;
  7373. {$EXTERNALSYM CERT_STORE_PROV_SYSTEM}
  7374. CERT_STORE_PROV_COLLECTION = LPCSTR(11);
  7375. {$EXTERNALSYM CERT_STORE_PROV_COLLECTION}
  7376. CERT_STORE_PROV_SYSTEM_REGISTRY_A = LPCSTR(12);
  7377. {$EXTERNALSYM CERT_STORE_PROV_SYSTEM_REGISTRY_A}
  7378. CERT_STORE_PROV_SYSTEM_REGISTRY_W = LPCSTR(13);
  7379. {$EXTERNALSYM CERT_STORE_PROV_SYSTEM_REGISTRY_W}
  7380. CERT_STORE_PROV_SYSTEM_REGISTRY = CERT_STORE_PROV_SYSTEM_REGISTRY_W;
  7381. {$EXTERNALSYM CERT_STORE_PROV_SYSTEM_REGISTRY}
  7382. CERT_STORE_PROV_PHYSICAL_W = LPCSTR(14);
  7383. {$EXTERNALSYM CERT_STORE_PROV_PHYSICAL_W}
  7384. CERT_STORE_PROV_PHYSICAL = CERT_STORE_PROV_PHYSICAL_W;
  7385. {$EXTERNALSYM CERT_STORE_PROV_PHYSICAL}
  7386. CERT_STORE_PROV_SMART_CARD_W = LPCSTR(15);
  7387. {$EXTERNALSYM CERT_STORE_PROV_SMART_CARD_W}
  7388. CERT_STORE_PROV_SMART_CARD = CERT_STORE_PROV_SMART_CARD_W;
  7389. {$EXTERNALSYM CERT_STORE_PROV_SMART_CARD}
  7390. CERT_STORE_PROV_LDAP_W = LPCSTR(16);
  7391. {$EXTERNALSYM CERT_STORE_PROV_LDAP_W}
  7392. CERT_STORE_PROV_LDAP = CERT_STORE_PROV_LDAP_W;
  7393. {$EXTERNALSYM CERT_STORE_PROV_LDAP}
  7394. sz_CERT_STORE_PROV_MEMORY = 'Memory';
  7395. {$EXTERNALSYM sz_CERT_STORE_PROV_MEMORY}
  7396. sz_CERT_STORE_PROV_FILENAME_W = 'File';
  7397. {$EXTERNALSYM sz_CERT_STORE_PROV_FILENAME_W}
  7398. sz_CERT_STORE_PROV_FILENAME = sz_CERT_STORE_PROV_FILENAME_W;
  7399. {$EXTERNALSYM sz_CERT_STORE_PROV_FILENAME}
  7400. sz_CERT_STORE_PROV_SYSTEM_W = 'System';
  7401. {$EXTERNALSYM sz_CERT_STORE_PROV_SYSTEM_W}
  7402. sz_CERT_STORE_PROV_SYSTEM = sz_CERT_STORE_PROV_SYSTEM_W;
  7403. {$EXTERNALSYM sz_CERT_STORE_PROV_SYSTEM}
  7404. sz_CERT_STORE_PROV_PKCS7 = 'PKCS7';
  7405. {$EXTERNALSYM sz_CERT_STORE_PROV_PKCS7}
  7406. sz_CERT_STORE_PROV_SERIALIZED = 'Serialized';
  7407. {$EXTERNALSYM sz_CERT_STORE_PROV_SERIALIZED}
  7408. sz_CERT_STORE_PROV_COLLECTION = 'Collection';
  7409. {$EXTERNALSYM sz_CERT_STORE_PROV_COLLECTION}
  7410. sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W = 'SystemRegistry';
  7411. {$EXTERNALSYM sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W}
  7412. sz_CERT_STORE_PROV_SYSTEM_REGISTRY = sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W;
  7413. {$EXTERNALSYM sz_CERT_STORE_PROV_SYSTEM_REGISTRY}
  7414. sz_CERT_STORE_PROV_PHYSICAL_W = 'Physical';
  7415. {$EXTERNALSYM sz_CERT_STORE_PROV_PHYSICAL_W}
  7416. sz_CERT_STORE_PROV_PHYSICAL = sz_CERT_STORE_PROV_PHYSICAL_W;
  7417. {$EXTERNALSYM sz_CERT_STORE_PROV_PHYSICAL}
  7418. sz_CERT_STORE_PROV_SMART_CARD_W = 'SmartCard';
  7419. {$EXTERNALSYM sz_CERT_STORE_PROV_SMART_CARD_W}
  7420. sz_CERT_STORE_PROV_SMART_CARD = sz_CERT_STORE_PROV_SMART_CARD_W;
  7421. {$EXTERNALSYM sz_CERT_STORE_PROV_SMART_CARD}
  7422. sz_CERT_STORE_PROV_LDAP_W = 'Ldap';
  7423. {$EXTERNALSYM sz_CERT_STORE_PROV_LDAP_W}
  7424. sz_CERT_STORE_PROV_LDAP = sz_CERT_STORE_PROV_LDAP_W;
  7425. {$EXTERNALSYM sz_CERT_STORE_PROV_LDAP}
  7426. //+-------------------------------------------------------------------------
  7427. // Certificate Store verify/results flags
  7428. //--------------------------------------------------------------------------
  7429. CERT_STORE_SIGNATURE_FLAG = $00000001;
  7430. {$EXTERNALSYM CERT_STORE_SIGNATURE_FLAG}
  7431. CERT_STORE_TIME_VALIDITY_FLAG = $00000002;
  7432. {$EXTERNALSYM CERT_STORE_TIME_VALIDITY_FLAG}
  7433. CERT_STORE_REVOCATION_FLAG = $00000004;
  7434. {$EXTERNALSYM CERT_STORE_REVOCATION_FLAG}
  7435. CERT_STORE_NO_CRL_FLAG = $00010000;
  7436. {$EXTERNALSYM CERT_STORE_NO_CRL_FLAG}
  7437. CERT_STORE_NO_ISSUER_FLAG = $00020000;
  7438. {$EXTERNALSYM CERT_STORE_NO_ISSUER_FLAG}
  7439. //+-------------------------------------------------------------------------
  7440. // Certificate Store open/property flags
  7441. //--------------------------------------------------------------------------
  7442. CERT_STORE_NO_CRYPT_RELEASE_FLAG = $00000001;
  7443. {$EXTERNALSYM CERT_STORE_NO_CRYPT_RELEASE_FLAG}
  7444. CERT_STORE_SET_LOCALIZED_NAME_FLAG = $00000002;
  7445. {$EXTERNALSYM CERT_STORE_SET_LOCALIZED_NAME_FLAG}
  7446. CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG = $00000004;
  7447. {$EXTERNALSYM CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG}
  7448. CERT_STORE_DELETE_FLAG = $00000010;
  7449. {$EXTERNALSYM CERT_STORE_DELETE_FLAG}
  7450. CERT_STORE_MANIFOLD_FLAG = $00000100;
  7451. {$EXTERNALSYM CERT_STORE_MANIFOLD_FLAG}
  7452. CERT_STORE_ENUM_ARCHIVED_FLAG = $00000200;
  7453. {$EXTERNALSYM CERT_STORE_ENUM_ARCHIVED_FLAG}
  7454. CERT_STORE_UPDATE_KEYID_FLAG = $00000400;
  7455. {$EXTERNALSYM CERT_STORE_UPDATE_KEYID_FLAG}
  7456. CERT_STORE_READONLY_FLAG = $00008000;
  7457. {$EXTERNALSYM CERT_STORE_READONLY_FLAG}
  7458. CERT_STORE_OPEN_EXISTING_FLAG = $00004000;
  7459. {$EXTERNALSYM CERT_STORE_OPEN_EXISTING_FLAG}
  7460. CERT_STORE_CREATE_NEW_FLAG = $00002000;
  7461. {$EXTERNALSYM CERT_STORE_CREATE_NEW_FLAG}
  7462. CERT_STORE_MAXIMUM_ALLOWED_FLAG = $00001000;
  7463. {$EXTERNALSYM CERT_STORE_MAXIMUM_ALLOWED_FLAG}
  7464. //+-------------------------------------------------------------------------
  7465. // Certificate Store Provider flags are in the HiWord (0xFFFF0000)
  7466. //--------------------------------------------------------------------------
  7467. //+-------------------------------------------------------------------------
  7468. // Certificate System Store Flag Values
  7469. //--------------------------------------------------------------------------
  7470. // Includes flags and location
  7471. CERT_SYSTEM_STORE_MASK = DWORD($FFFF0000);
  7472. {$EXTERNALSYM CERT_SYSTEM_STORE_MASK}
  7473. // Set if pvPara points to a CERT_SYSTEM_STORE_RELOCATE_PARA structure
  7474. CERT_SYSTEM_STORE_RELOCATE_FLAG = DWORD($80000000);
  7475. {$EXTERNALSYM CERT_SYSTEM_STORE_RELOCATE_FLAG}
  7476. type
  7477. PCERT_SYSTEM_STORE_RELOCATE_PARA = ^CERT_SYSTEM_STORE_RELOCATE_PARA;
  7478. {$EXTERNALSYM PCERT_SYSTEM_STORE_RELOCATE_PARA}
  7479. _CERT_SYSTEM_STORE_RELOCATE_PARA = record
  7480. Union1: record
  7481. case Integer of
  7482. 0: (hKeyBase: HKEY);
  7483. 1: (pvBase: Pointer);
  7484. end;
  7485. case Integer of
  7486. 0: (pvSystemStore: Pointer);
  7487. 1: (pszSystemStore: LPCSTR);
  7488. 2: (pwszSystemStore: LPCWSTR);
  7489. end;
  7490. {$EXTERNALSYM _CERT_SYSTEM_STORE_RELOCATE_PARA}
  7491. CERT_SYSTEM_STORE_RELOCATE_PARA = _CERT_SYSTEM_STORE_RELOCATE_PARA;
  7492. {$EXTERNALSYM CERT_SYSTEM_STORE_RELOCATE_PARA}
  7493. TCertSystemStoreRelocatePara = CERT_SYSTEM_STORE_RELOCATE_PARA;
  7494. PCertSystemStoreRelocatePara = PCERT_SYSTEM_STORE_RELOCATE_PARA;
  7495. // By default, when the CurrentUser "Root" store is opened, any SystemRegistry
  7496. // roots not also on the protected root list are deleted from the cache before
  7497. // CertOpenStore() returns. Set the following flag to return all the roots
  7498. // in the SystemRegistry without checking the protected root list.
  7499. const
  7500. CERT_SYSTEM_STORE_UNPROTECTED_FLAG = $40000000;
  7501. {$EXTERNALSYM CERT_SYSTEM_STORE_UNPROTECTED_FLAG}
  7502. // Location of the system store:
  7503. CERT_SYSTEM_STORE_LOCATION_MASK = $00FF0000;
  7504. {$EXTERNALSYM CERT_SYSTEM_STORE_LOCATION_MASK}
  7505. CERT_SYSTEM_STORE_LOCATION_SHIFT = 16;
  7506. {$EXTERNALSYM CERT_SYSTEM_STORE_LOCATION_SHIFT}
  7507. // Registry: HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE
  7508. CERT_SYSTEM_STORE_CURRENT_USER_ID = 1;
  7509. {$EXTERNALSYM CERT_SYSTEM_STORE_CURRENT_USER_ID}
  7510. CERT_SYSTEM_STORE_LOCAL_MACHINE_ID = 2;
  7511. {$EXTERNALSYM CERT_SYSTEM_STORE_LOCAL_MACHINE_ID}
  7512. // Registry: HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Services
  7513. CERT_SYSTEM_STORE_CURRENT_SERVICE_ID = 4;
  7514. {$EXTERNALSYM CERT_SYSTEM_STORE_CURRENT_SERVICE_ID}
  7515. CERT_SYSTEM_STORE_SERVICES_ID = 5;
  7516. {$EXTERNALSYM CERT_SYSTEM_STORE_SERVICES_ID}
  7517. // Registry: HKEY_USERS
  7518. CERT_SYSTEM_STORE_USERS_ID = 6;
  7519. {$EXTERNALSYM CERT_SYSTEM_STORE_USERS_ID}
  7520. // Registry: HKEY_CURRENT_USER\Software\Policies\Microsoft\SystemCertificates
  7521. CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID = 7;
  7522. {$EXTERNALSYM CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID}
  7523. // Registry: HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\SystemCertificates
  7524. CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID = 8;
  7525. {$EXTERNALSYM CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID}
  7526. // Registry: HKEY_LOCAL_MACHINE\Software\Microsoft\EnterpriseCertificates
  7527. CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID = 9;
  7528. {$EXTERNALSYM CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID}
  7529. CERT_SYSTEM_STORE_CURRENT_USER = CERT_SYSTEM_STORE_CURRENT_USER_ID shl CERT_SYSTEM_STORE_LOCATION_SHIFT;
  7530. {$EXTERNALSYM CERT_SYSTEM_STORE_CURRENT_USER}
  7531. CERT_SYSTEM_STORE_LOCAL_MACHINE = CERT_SYSTEM_STORE_LOCAL_MACHINE_ID shl CERT_SYSTEM_STORE_LOCATION_SHIFT;
  7532. {$EXTERNALSYM CERT_SYSTEM_STORE_LOCAL_MACHINE}
  7533. CERT_SYSTEM_STORE_CURRENT_SERVICE = CERT_SYSTEM_STORE_CURRENT_SERVICE_ID shl CERT_SYSTEM_STORE_LOCATION_SHIFT;
  7534. {$EXTERNALSYM CERT_SYSTEM_STORE_CURRENT_SERVICE}
  7535. CERT_SYSTEM_STORE_SERVICES = CERT_SYSTEM_STORE_SERVICES_ID shl CERT_SYSTEM_STORE_LOCATION_SHIFT;
  7536. {$EXTERNALSYM CERT_SYSTEM_STORE_SERVICES}
  7537. CERT_SYSTEM_STORE_USERS = CERT_SYSTEM_STORE_USERS_ID shl CERT_SYSTEM_STORE_LOCATION_SHIFT;
  7538. {$EXTERNALSYM CERT_SYSTEM_STORE_USERS}
  7539. CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY = CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID shl CERT_SYSTEM_STORE_LOCATION_SHIFT;
  7540. {$EXTERNALSYM CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY}
  7541. CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY = CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID shl CERT_SYSTEM_STORE_LOCATION_SHIFT;
  7542. {$EXTERNALSYM CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY}
  7543. CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE = CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID shl CERT_SYSTEM_STORE_LOCATION_SHIFT;
  7544. {$EXTERNALSYM CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE}
  7545. //+-------------------------------------------------------------------------
  7546. // Group Policy Store Defines
  7547. //--------------------------------------------------------------------------
  7548. // Registry path to the Group Policy system stores
  7549. CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH = 'Software\Policies\Microsoft\SystemCertificates';
  7550. {$EXTERNALSYM CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH}
  7551. //+-------------------------------------------------------------------------
  7552. // EFS Defines
  7553. //--------------------------------------------------------------------------
  7554. // Registry path to the EFS EFSBlob SubKey - Value type is REG_BINARY
  7555. CERT_EFSBLOB_REGPATH = CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH + '\EFS';
  7556. {$EXTERNALSYM CERT_EFSBLOB_REGPATH}
  7557. CERT_EFSBLOB_VALUE_NAME = 'EFSBlob';
  7558. {$EXTERNALSYM CERT_EFSBLOB_VALUE_NAME}
  7559. //+-------------------------------------------------------------------------
  7560. // Protected Root Defines
  7561. //--------------------------------------------------------------------------
  7562. // Registry path to the Protected Roots Flags SubKey
  7563. CERT_PROT_ROOT_FLAGS_REGPATH = CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH + '\Root\ProtectedRoots';
  7564. {$EXTERNALSYM CERT_PROT_ROOT_FLAGS_REGPATH}
  7565. CERT_PROT_ROOT_FLAGS_VALUE_NAME = 'Flags';
  7566. {$EXTERNALSYM CERT_PROT_ROOT_FLAGS_VALUE_NAME}
  7567. // Set the following flag to inhibit the opening of the CurrentUser's
  7568. // .Default physical store when opening the CurrentUser's "Root" system store.
  7569. // The .Default physical store open's the CurrentUser SystemRegistry "Root"
  7570. // store.
  7571. CERT_PROT_ROOT_DISABLE_CURRENT_USER_FLAG = $1;
  7572. {$EXTERNALSYM CERT_PROT_ROOT_DISABLE_CURRENT_USER_FLAG}
  7573. // Set the following flag to inhibit the adding of roots from the
  7574. // CurrentUser SystemRegistry "Root" store to the protected root list
  7575. // when the "Root" store is initially protected.
  7576. CERT_PROT_ROOT_INHIBIT_ADD_AT_INIT_FLAG = $2;
  7577. {$EXTERNALSYM CERT_PROT_ROOT_INHIBIT_ADD_AT_INIT_FLAG}
  7578. // Set the following flag to inhibit the purging of protected roots from the
  7579. // CurrentUser SystemRegistry "Root" store that are
  7580. // also in the LocalMachine SystemRegistry "Root" store. Note, when not
  7581. // disabled, the purging is done silently without UI.
  7582. CERT_PROT_ROOT_INHIBIT_PURGE_LM_FLAG = $4;
  7583. {$EXTERNALSYM CERT_PROT_ROOT_INHIBIT_PURGE_LM_FLAG}
  7584. // Set the following flag to only open the .LocalMachineGroupPolicy
  7585. // physical store when opening the CurrentUser's "Root" system store.
  7586. CERT_PROT_ROOT_ONLY_LM_GPT_FLAG = $8;
  7587. {$EXTERNALSYM CERT_PROT_ROOT_ONLY_LM_GPT_FLAG}
  7588. //+-------------------------------------------------------------------------
  7589. // Certificate Registry Store Flag Values (CERT_STORE_REG)
  7590. //--------------------------------------------------------------------------
  7591. // Set this flag if the HKEY passed in pvPara points to a remote computer
  7592. // registry key.
  7593. CERT_REGISTRY_STORE_REMOTE_FLAG = $10000;
  7594. {$EXTERNALSYM CERT_REGISTRY_STORE_REMOTE_FLAG}
  7595. // Set this flag if the contexts are to be persisted as a single serialized
  7596. // store in the registry. Mainly used for stores downloaded from the GPT.
  7597. // Such as the CurrentUserGroupPolicy or LocalMachineGroupPolicy stores.
  7598. CERT_REGISTRY_STORE_SERIALIZED_FLAG = $20000;
  7599. {$EXTERNALSYM CERT_REGISTRY_STORE_SERIALIZED_FLAG}
  7600. // The following flags are for internal use. When set, the
  7601. // pvPara parameter passed to CertOpenStore is a pointer to the following
  7602. // data structure and not the HKEY. The above CERT_REGISTRY_STORE_REMOTE_FLAG
  7603. // is also set if hKeyBase was obtained via RegConnectRegistry().
  7604. CERT_REGISTRY_STORE_CLIENT_GPT_FLAG = DWORD($80000000);
  7605. {$EXTERNALSYM CERT_REGISTRY_STORE_CLIENT_GPT_FLAG}
  7606. CERT_REGISTRY_STORE_LM_GPT_FLAG = $01000000;
  7607. {$EXTERNALSYM CERT_REGISTRY_STORE_LM_GPT_FLAG}
  7608. type
  7609. PCERT_REGISTRY_STORE_CLIENT_GPT_PARA = ^CERT_REGISTRY_STORE_CLIENT_GPT_PARA;
  7610. {$EXTERNALSYM PCERT_REGISTRY_STORE_CLIENT_GPT_PARA}
  7611. _CERT_REGISTRY_STORE_CLIENT_GPT_PARA = record
  7612. hKeyBase: HKEY;
  7613. pwszRegPath: LPWSTR;
  7614. end;
  7615. {$EXTERNALSYM _CERT_REGISTRY_STORE_CLIENT_GPT_PARA}
  7616. CERT_REGISTRY_STORE_CLIENT_GPT_PARA = _CERT_REGISTRY_STORE_CLIENT_GPT_PARA;
  7617. {$EXTERNALSYM CERT_REGISTRY_STORE_CLIENT_GPT_PARA}
  7618. TCertRegistryStoreClientGptPara = CERT_REGISTRY_STORE_CLIENT_GPT_PARA;
  7619. PCertRegistryStoreClientGptPara = PCERT_REGISTRY_STORE_CLIENT_GPT_PARA;
  7620. // The following flag is for internal use. When set, the contexts are
  7621. // persisted into roaming files instead of the registry. Such as, the
  7622. // CurrentUser "My" store. When this flag is set, the following data structure
  7623. // is passed to CertOpenStore instead of HKEY.
  7624. const
  7625. CERT_REGISTRY_STORE_ROAMING_FLAG = $40000;
  7626. {$EXTERNALSYM CERT_REGISTRY_STORE_ROAMING_FLAG}
  7627. // hKey may be NULL or non-NULL. When non-NULL, existing contexts are
  7628. // moved from the registry to roaming files.
  7629. type
  7630. PCERT_REGISTRY_STORE_ROAMING_PARA = ^CERT_REGISTRY_STORE_ROAMING_PARA;
  7631. {$EXTERNALSYM PCERT_REGISTRY_STORE_ROAMING_PARA}
  7632. _CERT_REGISTRY_STORE_ROAMING_PARA = record
  7633. hKey: HKEY;
  7634. pwszStoreDirectory: LPWSTR;
  7635. end;
  7636. {$EXTERNALSYM _CERT_REGISTRY_STORE_ROAMING_PARA}
  7637. CERT_REGISTRY_STORE_ROAMING_PARA = _CERT_REGISTRY_STORE_ROAMING_PARA;
  7638. {$EXTERNALSYM CERT_REGISTRY_STORE_ROAMING_PARA}
  7639. TCertRegistryStoreRoamingPara = CERT_REGISTRY_STORE_ROAMING_PARA;
  7640. PCertRegistryStoreRoamingPara = PCERT_REGISTRY_STORE_ROAMING_PARA;
  7641. // The following flag is for internal use. When set, the "My" DWORD value
  7642. // at HKLM\Software\Microsoft\Cryptography\IEDirtyFlags is set to 0x1
  7643. // whenever a certificate is added to the registry store.
  7644. const
  7645. CERT_REGISTRY_STORE_MY_IE_DIRTY_FLAG = $80000;
  7646. {$EXTERNALSYM CERT_REGISTRY_STORE_MY_IE_DIRTY_FLAG}
  7647. // Registry path to the subkey containing the "My" DWORD value to be set
  7648. CERT_IE_DIRTY_FLAGS_REGPATH = 'Software\Microsoft\Cryptography\IEDirtyFlags';
  7649. {$EXTERNALSYM CERT_IE_DIRTY_FLAGS_REGPATH}
  7650. //+-------------------------------------------------------------------------
  7651. // Certificate File Store Flag Values for the providers:
  7652. // CERT_STORE_PROV_FILE
  7653. // CERT_STORE_PROV_FILENAME
  7654. // CERT_STORE_PROV_FILENAME_A
  7655. // CERT_STORE_PROV_FILENAME_W
  7656. // sz_CERT_STORE_PROV_FILENAME_W
  7657. //--------------------------------------------------------------------------
  7658. // Set this flag if any store changes are to be committed to the file.
  7659. // The changes are committed at CertCloseStore or by calling
  7660. // CertControlStore(CERT_STORE_CTRL_COMMIT).
  7661. //
  7662. // The open fails with E_INVALIDARG if both CERT_FILE_STORE_COMMIT_ENABLE_FLAG
  7663. // and CERT_STORE_READONLY_FLAG are set in dwFlags.
  7664. //
  7665. // For the FILENAME providers: if the file contains an X509 encoded
  7666. // certificate, the open fails with ERROR_ACCESS_DENIED.
  7667. //
  7668. // For the FILENAME providers: if CERT_STORE_CREATE_NEW_FLAG is set, the
  7669. // CreateFile uses CREATE_NEW. If CERT_STORE_OPEN_EXISTING is set, uses
  7670. // OPEN_EXISTING. Otherwise, defaults to OPEN_ALWAYS.
  7671. //
  7672. // For the FILENAME providers: the file is committed as either a PKCS7 or
  7673. // serialized store depending on the type read at open. However, if the
  7674. // file is empty then, if the filename has either a ".p7c" or ".spc"
  7675. // extension its committed as a PKCS7. Otherwise, its committed as a
  7676. // serialized store.
  7677. //
  7678. // For CERT_STORE_PROV_FILE, the file handle is duplicated. Its always
  7679. // committed as a serialized store.
  7680. //
  7681. CERT_FILE_STORE_COMMIT_ENABLE_FLAG = $10000;
  7682. {$EXTERNALSYM CERT_FILE_STORE_COMMIT_ENABLE_FLAG}
  7683. //+-------------------------------------------------------------------------
  7684. // Open the cert store using the specified store provider.
  7685. //
  7686. // If CERT_STORE_DELETE_FLAG is set, then, the store is deleted. NULL is
  7687. // returned for both success and failure. However, GetLastError() returns 0
  7688. // for success and nonzero for failure.
  7689. //
  7690. // If CERT_STORE_SET_LOCALIZED_NAME_FLAG is set, then, if supported, the
  7691. // provider sets the store's CERT_STORE_LOCALIZED_NAME_PROP_ID property.
  7692. // The store's localized name can be retrieved by calling
  7693. // CertSetStoreProperty(dwPropID = CERT_STORE_LOCALIZED_NAME_PROP_ID).
  7694. // This flag is supported by the following providers (and their sz_
  7695. // equivalent):
  7696. // CERT_STORE_PROV_FILENAME_A
  7697. // CERT_STORE_PROV_FILENAME_W
  7698. // CERT_STORE_PROV_SYSTEM_A
  7699. // CERT_STORE_PROV_SYSTEM_W
  7700. // CERT_STORE_PROV_SYSTEM_REGISTRY_A
  7701. // CERT_STORE_PROV_SYSTEM_REGISTRY_W
  7702. // CERT_STORE_PROV_PHYSICAL_W
  7703. //
  7704. // If CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG is set, then, the
  7705. // closing of the store's provider is deferred until all certificate,
  7706. // CRL and CTL contexts obtained from the store are freed. Also,
  7707. // if a non NULL HCRYPTPROV was passed, then, it will continue to be used.
  7708. // By default, the store's provider is closed on the final CertCloseStore.
  7709. // If this flag isn't set, then, any property changes made to previously
  7710. // duplicated contexts after the final CertCloseStore will not be persisted.
  7711. // By setting this flag, property changes made
  7712. // after the CertCloseStore will be persisted. Note, setting this flag
  7713. // causes extra overhead in doing context duplicates and frees.
  7714. // If CertCloseStore is called with CERT_CLOSE_STORE_FORCE_FLAG, then,
  7715. // the CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG flag is ignored.
  7716. //
  7717. // CERT_STORE_MANIFOLD_FLAG can be set to check for certificates having the
  7718. // manifold extension and archive the "older" certificates with the same
  7719. // manifold extension value. A certificate is archived by setting the
  7720. // CERT_ARCHIVED_PROP_ID.
  7721. //
  7722. // By default, contexts having the CERT_ARCHIVED_PROP_ID, are skipped
  7723. // during enumeration. CERT_STORE_ENUM_ARCHIVED_FLAG can be set to include
  7724. // archived contexts when enumerating. Note, contexts having the
  7725. // CERT_ARCHIVED_PROP_ID are still found for explicit finds, such as,
  7726. // finding a context with a specific hash or finding a certificate having
  7727. // a specific issuer and serial number.
  7728. //
  7729. // CERT_STORE_UPDATE_KEYID_FLAG can be set to also update the Key Identifier's
  7730. // CERT_KEY_PROV_INFO_PROP_ID property whenever a certificate's
  7731. // CERT_KEY_IDENTIFIER_PROP_ID or CERT_KEY_PROV_INFO_PROP_ID property is set
  7732. // and the other property already exists. If the Key Identifier's
  7733. // CERT_KEY_PROV_INFO_PROP_ID already exists, it isn't updated. Any
  7734. // errors encountered are silently ignored.
  7735. //
  7736. // By default, this flag is implicitly set for the "My\.Default" CurrentUser
  7737. // and LocalMachine physical stores.
  7738. //
  7739. // CERT_STORE_READONLY_FLAG can be set to open the store as read only.
  7740. // Otherwise, the store is opened as read/write.
  7741. //
  7742. // CERT_STORE_OPEN_EXISTING_FLAG can be set to only open an existing
  7743. // store. CERT_STORE_CREATE_NEW_FLAG can be set to create a new store and
  7744. // fail if the store already exists. Otherwise, the default is to open
  7745. // an existing store or create a new store if it doesn't already exist.
  7746. //
  7747. // hCryptProv specifies the crypto provider to use to create the hash
  7748. // properties or verify the signature of a subject certificate or CRL.
  7749. // The store doesn't need to use a private
  7750. // key. If the CERT_STORE_NO_CRYPT_RELEASE_FLAG isn't set, hCryptProv is
  7751. // CryptReleaseContext'ed on the final CertCloseStore.
  7752. //
  7753. // Note, if the open fails, hCryptProv is released if it would have been
  7754. // released when the store was closed.
  7755. //
  7756. // If hCryptProv is zero, then, the default provider and container for the
  7757. // PROV_RSA_FULL provider type is CryptAcquireContext'ed with
  7758. // CRYPT_VERIFYCONTEXT access. The CryptAcquireContext is deferred until
  7759. // the first create hash or verify signature. In addition, once acquired,
  7760. // the default provider isn't released until process exit when crypt32.dll
  7761. // is unloaded. The acquired default provider is shared across all stores
  7762. // and threads.
  7763. //
  7764. // After initializing the store's data structures and optionally acquiring a
  7765. // default crypt provider, CertOpenStore calls CryptGetOIDFunctionAddress to
  7766. // get the address of the CRYPT_OID_OPEN_STORE_PROV_FUNC specified by
  7767. // lpszStoreProvider. Since a store can contain certificates with different
  7768. // encoding types, CryptGetOIDFunctionAddress is called with dwEncodingType
  7769. // set to 0 and not the dwEncodingType passed to CertOpenStore.
  7770. // PFN_CERT_DLL_OPEN_STORE_FUNC specifies the signature of the provider's
  7771. // open function. This provider open function is called to load the
  7772. // store's certificates and CRLs. Optionally, the provider may return an
  7773. // array of functions called before a certificate or CRL is added or deleted
  7774. // or has a property that is set.
  7775. //
  7776. // Use of the dwEncodingType parameter is provider dependent. The type
  7777. // definition for pvPara also depends on the provider.
  7778. //
  7779. // Store providers are installed or registered via
  7780. // CryptInstallOIDFunctionAddress or CryptRegisterOIDFunction, where,
  7781. // dwEncodingType is 0 and pszFuncName is CRYPT_OID_OPEN_STORE_PROV_FUNC.
  7782. //
  7783. // Here's a list of the predefined provider types (implemented in crypt32.dll):
  7784. //
  7785. // CERT_STORE_PROV_MSG:
  7786. // Gets the certificates and CRLs from the specified cryptographic message.
  7787. // dwEncodingType contains the message and certificate encoding types.
  7788. // The message's handle is passed in pvPara. Given,
  7789. // HCRYPTMSG hCryptMsg; pvPara = (const void *) hCryptMsg;
  7790. //
  7791. // CERT_STORE_PROV_MEMORY
  7792. // sz_CERT_STORE_PROV_MEMORY:
  7793. // Opens a store without any initial certificates or CRLs. pvPara
  7794. // isn't used.
  7795. //
  7796. // CERT_STORE_PROV_FILE:
  7797. // Reads the certificates and CRLs from the specified file. The file's
  7798. // handle is passed in pvPara. Given,
  7799. // HANDLE hFile; pvPara = (const void *) hFile;
  7800. //
  7801. // For a successful open, the file pointer is advanced past
  7802. // the certificates and CRLs and their properties read from the file.
  7803. // Note, only expects a serialized store and not a file containing
  7804. // either a PKCS #7 signed message or a single encoded certificate.
  7805. //
  7806. // The hFile isn't closed.
  7807. //
  7808. // CERT_STORE_PROV_REG:
  7809. // Reads the certificates and CRLs from the registry. The registry's
  7810. // key handle is passed in pvPara. Given,
  7811. // HKEY hKey; pvPara = (const void *) hKey;
  7812. //
  7813. // The input hKey isn't closed by the provider. Before returning, the
  7814. // provider opens it own copy of the hKey.
  7815. //
  7816. // If CERT_STORE_READONLY_FLAG is set, then, the registry subkeys are
  7817. // RegOpenKey'ed with KEY_READ_ACCESS. Otherwise, the registry subkeys
  7818. // are RegCreateKey'ed with KEY_ALL_ACCESS.
  7819. //
  7820. // This provider returns the array of functions for reading, writing,
  7821. // deleting and property setting certificates and CRLs.
  7822. // Any changes to the opened store are immediately pushed through to
  7823. // the registry. However, if CERT_STORE_READONLY_FLAG is set, then,
  7824. // writing, deleting or property setting results in a
  7825. // SetLastError(E_ACCESSDENIED).
  7826. //
  7827. // Note, all the certificates and CRLs are read from the registry
  7828. // when the store is opened. The opened store serves as a write through
  7829. // cache.
  7830. //
  7831. // If CERT_REGISTRY_STORE_SERIALIZED_FLAG is set, then, the
  7832. // contexts are persisted as a single serialized store subkey in the
  7833. // registry.
  7834. //
  7835. // CERT_STORE_PROV_PKCS7:
  7836. // sz_CERT_STORE_PROV_PKCS7:
  7837. // Gets the certificates and CRLs from the encoded PKCS #7 signed message.
  7838. // dwEncodingType specifies the message and certificate encoding types.
  7839. // The pointer to the encoded message's blob is passed in pvPara. Given,
  7840. // CRYPT_DATA_BLOB EncodedMsg; pvPara = (const void *) &EncodedMsg;
  7841. //
  7842. // Note, also supports the IE3.0 special version of a
  7843. // PKCS #7 signed message referred to as a "SPC" formatted message.
  7844. //
  7845. // CERT_STORE_PROV_SERIALIZED:
  7846. // sz_CERT_STORE_PROV_SERIALIZED:
  7847. // Gets the certificates and CRLs from memory containing a serialized
  7848. // store. The pointer to the serialized memory blob is passed in pvPara.
  7849. // Given,
  7850. // CRYPT_DATA_BLOB Serialized; pvPara = (const void *) &Serialized;
  7851. //
  7852. // CERT_STORE_PROV_FILENAME_A:
  7853. // CERT_STORE_PROV_FILENAME_W:
  7854. // CERT_STORE_PROV_FILENAME:
  7855. // sz_CERT_STORE_PROV_FILENAME_W:
  7856. // sz_CERT_STORE_PROV_FILENAME:
  7857. // Opens the file and first attempts to read as a serialized store. Then,
  7858. // as a PKCS #7 signed message. Finally, as a single encoded certificate.
  7859. // The filename is passed in pvPara. The filename is UNICODE for the
  7860. // "_W" provider and ASCII for the "_A" provider. For "_W": given,
  7861. // LPCWSTR pwszFilename; pvPara = (const void *) pwszFilename;
  7862. // For "_A": given,
  7863. // LPCSTR pszFilename; pvPara = (const void *) pszFilename;
  7864. //
  7865. // Note, the default (without "_A" or "_W") is unicode.
  7866. //
  7867. // Note, also supports the reading of the IE3.0 special version of a
  7868. // PKCS #7 signed message file referred to as a "SPC" formatted file.
  7869. //
  7870. // CERT_STORE_PROV_SYSTEM_A:
  7871. // CERT_STORE_PROV_SYSTEM_W:
  7872. // CERT_STORE_PROV_SYSTEM:
  7873. // sz_CERT_STORE_PROV_SYSTEM_W:
  7874. // sz_CERT_STORE_PROV_SYSTEM:
  7875. // Opens the specified logical "System" store. The upper word of the
  7876. // dwFlags parameter is used to specify the location of the system store.
  7877. //
  7878. // A "System" store is a collection consisting of one or more "Physical"
  7879. // stores. A "Physical" store is registered via the
  7880. // CertRegisterPhysicalStore API. Each of the registered physical stores
  7881. // is CertStoreOpen'ed and added to the collection via
  7882. // CertAddStoreToCollection.
  7883. //
  7884. // The CERT_SYSTEM_STORE_CURRENT_USER, CERT_SYSTEM_STORE_LOCAL_MACHINE,
  7885. // CERT_SYSTEM_STORE_CURRENT_SERVICE, CERT_SYSTEM_STORE_SERVICES,
  7886. // CERT_SYSTEM_STORE_USERS, CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY,
  7887. // CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY and
  7888. // CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRSE
  7889. // system stores by default have a "SystemRegistry" store that is
  7890. // opened and added to the collection.
  7891. //
  7892. // The system store name is passed in pvPara. The name is UNICODE for the
  7893. // "_W" provider and ASCII for the "_A" provider. For "_W": given,
  7894. // LPCWSTR pwszSystemName; pvPara = (const void *) pwszSystemName;
  7895. // For "_A": given,
  7896. // LPCSTR pszSystemName; pvPara = (const void *) pszSystemName;
  7897. //
  7898. // Note, the default (without "_A" or "_W") is UNICODE.
  7899. //
  7900. // The system store name can't contain any backslashes.
  7901. //
  7902. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvPara
  7903. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure instead
  7904. // of pointing to a null terminated UNICODE or ASCII string.
  7905. // Sibling physical stores are also opened as relocated using
  7906. // pvPara's hKeyBase.
  7907. //
  7908. // The CERT_SYSTEM_STORE_SERVICES or CERT_SYSTEM_STORE_USERS system
  7909. // store name must be prefixed with the ServiceName or UserName.
  7910. // For example, "ServiceName\Trust".
  7911. //
  7912. // Stores on remote computers can be accessed for the
  7913. // CERT_SYSTEM_STORE_LOCAL_MACHINE, CERT_SYSTEM_STORE_SERVICES,
  7914. // CERT_SYSTEM_STORE_USERS, CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
  7915. // or CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
  7916. // locations by prepending the computer name. For example, a remote
  7917. // local machine store is accessed via "\\ComputerName\Trust" or
  7918. // "ComputerName\Trust". A remote service store is accessed via
  7919. // "\\ComputerName\ServiceName\Trust". The leading "\\" backslashes are
  7920. // optional in the ComputerName.
  7921. //
  7922. // If CERT_STORE_READONLY_FLAG is set, then, the registry is
  7923. // RegOpenKey'ed with KEY_READ_ACCESS. Otherwise, the registry is
  7924. // RegCreateKey'ed with KEY_ALL_ACCESS.
  7925. //
  7926. // The "root" store is treated differently from the other system
  7927. // stores. Before a certificate is added to or deleted from the "root"
  7928. // store, a pop up message box is displayed. The certificate's subject,
  7929. // issuer, serial number, time validity, sha1 and md5 thumbprints are
  7930. // displayed. The user is given the option to do the add or delete.
  7931. // If they don't allow the operation, LastError is set to E_ACCESSDENIED.
  7932. //
  7933. // CERT_STORE_PROV_SYSTEM_REGISTRY_A
  7934. // CERT_STORE_PROV_SYSTEM_REGISTRY_W
  7935. // CERT_STORE_PROV_SYSTEM_REGISTRY
  7936. // sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W
  7937. // sz_CERT_STORE_PROV_SYSTEM_REGISTRY
  7938. // Opens the "System" store's default "Physical" store residing in the
  7939. // registry. The upper word of the dwFlags
  7940. // parameter is used to specify the location of the system store.
  7941. //
  7942. // After opening the registry key associated with the system name,
  7943. // the CERT_STORE_PROV_REG provider is called to complete the open.
  7944. //
  7945. // The system store name is passed in pvPara. The name is UNICODE for the
  7946. // "_W" provider and ASCII for the "_A" provider. For "_W": given,
  7947. // LPCWSTR pwszSystemName; pvPara = (const void *) pwszSystemName;
  7948. // For "_A": given,
  7949. // LPCSTR pszSystemName; pvPara = (const void *) pszSystemName;
  7950. //
  7951. // Note, the default (without "_A" or "_W") is UNICODE.
  7952. //
  7953. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvPara
  7954. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure instead
  7955. // of pointing to a null terminated UNICODE or ASCII string.
  7956. //
  7957. // See above for details on prepending a ServiceName and/or ComputerName
  7958. // to the store name.
  7959. //
  7960. // If CERT_STORE_READONLY_FLAG is set, then, the registry is
  7961. // RegOpenKey'ed with KEY_READ_ACCESS. Otherwise, the registry is
  7962. // RegCreateKey'ed with KEY_ALL_ACCESS.
  7963. //
  7964. // The "root" store is treated differently from the other system
  7965. // stores. Before a certificate is added to or deleted from the "root"
  7966. // store, a pop up message box is displayed. The certificate's subject,
  7967. // issuer, serial number, time validity, sha1 and md5 thumbprints are
  7968. // displayed. The user is given the option to do the add or delete.
  7969. // If they don't allow the operation, LastError is set to E_ACCESSDENIED.
  7970. //
  7971. // CERT_STORE_PROV_PHYSICAL_W
  7972. // CERT_STORE_PROV_PHYSICAL
  7973. // sz_CERT_STORE_PROV_PHYSICAL_W
  7974. // sz_CERT_STORE_PROV_PHYSICAL
  7975. // Opens the specified "Physical" store in the "System" store.
  7976. //
  7977. // Both the system store and physical names are passed in pvPara. The
  7978. // names are separated with an intervening "\". For example,
  7979. // "Root\.Default". The string is UNICODE.
  7980. //
  7981. // The system and physical store names can't contain any backslashes.
  7982. //
  7983. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvPara
  7984. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure instead
  7985. // of pointing to a null terminated UNICODE string.
  7986. // The specified physical store is opened as relocated using pvPara's
  7987. // hKeyBase.
  7988. //
  7989. // For CERT_SYSTEM_STORE_SERVICES or CERT_SYSTEM_STORE_USERS,
  7990. // the system and physical store names
  7991. // must be prefixed with the ServiceName or UserName. For example,
  7992. // "ServiceName\Root\.Default".
  7993. //
  7994. // Physical stores on remote computers can be accessed for the
  7995. // CERT_SYSTEM_STORE_LOCAL_MACHINE, CERT_SYSTEM_STORE_SERVICES,
  7996. // CERT_SYSTEM_STORE_USERS, CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
  7997. // or CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
  7998. // locations by prepending the computer name. For example, a remote
  7999. // local machine store is accessed via "\\ComputerName\Root\.Default"
  8000. // or "ComputerName\Root\.Default". A remote service store is
  8001. // accessed via "\\ComputerName\ServiceName\Root\.Default". The
  8002. // leading "\\" backslashes are optional in the ComputerName.
  8003. //
  8004. // CERT_STORE_PROV_COLLECTION
  8005. // sz_CERT_STORE_PROV_COLLECTION
  8006. // Opens a store that is a collection of other stores. Stores are
  8007. // added or removed to/from the collection via the CertAddStoreToCollection
  8008. // and CertRemoveStoreFromCollection APIs.
  8009. //
  8010. // CERT_STORE_PROV_SMART_CARD_W
  8011. // CERT_STORE_PROV_SMART_CARD
  8012. // sz_CERT_STORE_PROV_SMART_CARD_W
  8013. // sz_CERT_STORE_PROV_SMART_CARD
  8014. // Opens a store instantiated over a particular smart card storage. pvPara
  8015. // identifies where on the card the store is located and is of the
  8016. // following format:
  8017. //
  8018. // Card Name\Provider Name\Provider Type[\Container Name]
  8019. //
  8020. // Container Name is optional and if NOT specified the Card Name is used
  8021. // as the Container Name. Future versions of the provider will support
  8022. // instantiating the store over the entire card in which case just
  8023. // Card Name ( or id ) will be sufficient.
  8024. //
  8025. // Here's a list of the predefined provider types (implemented in
  8026. // cryptnet.dll):
  8027. //
  8028. // CERT_STORE_PROV_LDAP_W
  8029. // CERT_STORE_PROV_LDAP
  8030. // sz_CERT_STORE_PROV_LDAP_W
  8031. // sz_CERT_STORE_PROV_LDAP
  8032. // Opens a store over the results of the query specified by and LDAP
  8033. // URL which is passed in via pvPara. In order to do writes to the
  8034. // store the URL must specify a BASE query, no filter and a single
  8035. // attribute.
  8036. //
  8037. //--------------------------------------------------------------------------
  8038. function CertOpenStore(lpszStoreProvider: LPCSTR; dwEncodingType: DWORD;
  8039. hCryptProv: HCRYPTPROV; dwFlags: DWORD; pvPara: Pointer): HCERTSTORE; stdcall;
  8040. {$EXTERNALSYM CertOpenStore}
  8041. //+-------------------------------------------------------------------------
  8042. // OID Installable Certificate Store Provider Data Structures
  8043. //--------------------------------------------------------------------------
  8044. // Handle returned by the store provider when opened.
  8045. type
  8046. HCERTSTOREPROV = Pointer;
  8047. {$EXTERNALSYM HCERTSTOREPROV}
  8048. // Store Provider OID function's pszFuncName.
  8049. const
  8050. CRYPT_OID_OPEN_STORE_PROV_FUNC = 'CertDllOpenStoreProv';
  8051. {$EXTERNALSYM CRYPT_OID_OPEN_STORE_PROV_FUNC}
  8052. // Note, the Store Provider OID function's dwEncodingType is always 0.
  8053. // The following information is returned by the provider when opened. Its
  8054. // zeroed with cbSize set before the provider is called. If the provider
  8055. // doesn't need to be called again after the open it doesn't need to
  8056. // make any updates to the CERT_STORE_PROV_INFO.
  8057. type
  8058. PCERT_STORE_PROV_INFO = ^CERT_STORE_PROV_INFO;
  8059. {$EXTERNALSYM PCERT_STORE_PROV_INFO}
  8060. _CERT_STORE_PROV_INFO = record
  8061. cbSize: DWORD;
  8062. cStoreProvFunc: DWORD;
  8063. rgpvStoreProvFunc: Pointer;
  8064. hStoreProv: HCERTSTOREPROV;
  8065. dwStoreProvFlags: DWORD;
  8066. hStoreProvFuncAddr2: HCRYPTOIDFUNCADDR;
  8067. end;
  8068. {$EXTERNALSYM _CERT_STORE_PROV_INFO}
  8069. CERT_STORE_PROV_INFO = _CERT_STORE_PROV_INFO;
  8070. {$EXTERNALSYM CERT_STORE_PROV_INFO}
  8071. TCertStoreProvInfo = CERT_STORE_PROV_INFO;
  8072. PCertStoreProvInfo = PCERT_STORE_PROV_INFO;
  8073. // Definition of the store provider's open function.
  8074. //
  8075. // *pStoreProvInfo has been zeroed before the call.
  8076. //
  8077. // Note, pStoreProvInfo->cStoreProvFunc should be set last. Once set,
  8078. // all subsequent store calls, such as CertAddSerializedElementToStore will
  8079. // call the appropriate provider callback function.
  8080. type
  8081. PFN_CERT_DLL_OPEN_STORE_PROV_FUNC = function(
  8082. lpszStoreProvider: LPCSTR;
  8083. dwEncodingType: DWORD;
  8084. hCryptProv: HCRYPTPROV;
  8085. dwFlags: DWORD;
  8086. pvPara: Pointer;
  8087. hCertStore: HCERTSTORE;
  8088. var pStoreProvInfo: PCERT_STORE_PROV_INFO): BOOL; stdcall;
  8089. {$EXTERNALSYM PFN_CERT_DLL_OPEN_STORE_PROV_FUNC}
  8090. PFnCertDllOpenStoreProvFunc = PFN_CERT_DLL_OPEN_STORE_PROV_FUNC;
  8091. // The open callback sets the following flag, if it maintains its
  8092. // contexts externally and not in the cached store.
  8093. const
  8094. CERT_STORE_PROV_EXTERNAL_FLAG = $1;
  8095. {$EXTERNALSYM CERT_STORE_PROV_EXTERNAL_FLAG}
  8096. // The open callback sets the following flag for a successful delete.
  8097. // When set, the close callback isn't called.
  8098. CERT_STORE_PROV_DELETED_FLAG = $2;
  8099. {$EXTERNALSYM CERT_STORE_PROV_DELETED_FLAG}
  8100. // The open callback sets the following flag if it doesn't persist store
  8101. // changes.
  8102. CERT_STORE_PROV_NO_PERSIST_FLAG = $4;
  8103. {$EXTERNALSYM CERT_STORE_PROV_NO_PERSIST_FLAG}
  8104. // The open callback sets the following flag if the contexts are persisted
  8105. // to a system store.
  8106. CERT_STORE_PROV_SYSTEM_STORE_FLAG = $8;
  8107. {$EXTERNALSYM CERT_STORE_PROV_SYSTEM_STORE_FLAG}
  8108. // Indices into the store provider's array of callback functions.
  8109. //
  8110. // The provider can implement any subset of the following functions. It
  8111. // sets pStoreProvInfo->cStoreProvFunc to the last index + 1 and any
  8112. // preceding not implemented functions to NULL.
  8113. CERT_STORE_PROV_CLOSE_FUNC = 0;
  8114. {$EXTERNALSYM CERT_STORE_PROV_CLOSE_FUNC}
  8115. CERT_STORE_PROV_READ_CERT_FUNC = 1;
  8116. {$EXTERNALSYM CERT_STORE_PROV_READ_CERT_FUNC}
  8117. CERT_STORE_PROV_WRITE_CERT_FUNC = 2;
  8118. {$EXTERNALSYM CERT_STORE_PROV_WRITE_CERT_FUNC}
  8119. CERT_STORE_PROV_DELETE_CERT_FUNC = 3;
  8120. {$EXTERNALSYM CERT_STORE_PROV_DELETE_CERT_FUNC}
  8121. CERT_STORE_PROV_SET_CERT_PROPERTY_FUNC = 4;
  8122. {$EXTERNALSYM CERT_STORE_PROV_SET_CERT_PROPERTY_FUNC}
  8123. CERT_STORE_PROV_READ_CRL_FUNC = 5;
  8124. {$EXTERNALSYM CERT_STORE_PROV_READ_CRL_FUNC}
  8125. CERT_STORE_PROV_WRITE_CRL_FUNC = 6;
  8126. {$EXTERNALSYM CERT_STORE_PROV_WRITE_CRL_FUNC}
  8127. CERT_STORE_PROV_DELETE_CRL_FUNC = 7;
  8128. {$EXTERNALSYM CERT_STORE_PROV_DELETE_CRL_FUNC}
  8129. CERT_STORE_PROV_SET_CRL_PROPERTY_FUNC = 8;
  8130. {$EXTERNALSYM CERT_STORE_PROV_SET_CRL_PROPERTY_FUNC}
  8131. CERT_STORE_PROV_READ_CTL_FUNC = 9;
  8132. {$EXTERNALSYM CERT_STORE_PROV_READ_CTL_FUNC}
  8133. CERT_STORE_PROV_WRITE_CTL_FUNC = 10;
  8134. {$EXTERNALSYM CERT_STORE_PROV_WRITE_CTL_FUNC}
  8135. CERT_STORE_PROV_DELETE_CTL_FUNC = 11;
  8136. {$EXTERNALSYM CERT_STORE_PROV_DELETE_CTL_FUNC}
  8137. CERT_STORE_PROV_SET_CTL_PROPERTY_FUNC = 12;
  8138. {$EXTERNALSYM CERT_STORE_PROV_SET_CTL_PROPERTY_FUNC}
  8139. CERT_STORE_PROV_CONTROL_FUNC = 13;
  8140. {$EXTERNALSYM CERT_STORE_PROV_CONTROL_FUNC}
  8141. CERT_STORE_PROV_FIND_CERT_FUNC = 14;
  8142. {$EXTERNALSYM CERT_STORE_PROV_FIND_CERT_FUNC}
  8143. CERT_STORE_PROV_FREE_FIND_CERT_FUNC = 15;
  8144. {$EXTERNALSYM CERT_STORE_PROV_FREE_FIND_CERT_FUNC}
  8145. CERT_STORE_PROV_GET_CERT_PROPERTY_FUNC = 16;
  8146. {$EXTERNALSYM CERT_STORE_PROV_GET_CERT_PROPERTY_FUNC}
  8147. CERT_STORE_PROV_FIND_CRL_FUNC = 17;
  8148. {$EXTERNALSYM CERT_STORE_PROV_FIND_CRL_FUNC}
  8149. CERT_STORE_PROV_FREE_FIND_CRL_FUNC = 18;
  8150. {$EXTERNALSYM CERT_STORE_PROV_FREE_FIND_CRL_FUNC}
  8151. CERT_STORE_PROV_GET_CRL_PROPERTY_FUNC = 19;
  8152. {$EXTERNALSYM CERT_STORE_PROV_GET_CRL_PROPERTY_FUNC}
  8153. CERT_STORE_PROV_FIND_CTL_FUNC = 20;
  8154. {$EXTERNALSYM CERT_STORE_PROV_FIND_CTL_FUNC}
  8155. CERT_STORE_PROV_FREE_FIND_CTL_FUNC = 21;
  8156. {$EXTERNALSYM CERT_STORE_PROV_FREE_FIND_CTL_FUNC}
  8157. CERT_STORE_PROV_GET_CTL_PROPERTY_FUNC = 22;
  8158. {$EXTERNALSYM CERT_STORE_PROV_GET_CTL_PROPERTY_FUNC}
  8159. // Called by CertCloseStore when the store's reference count is
  8160. // decremented to 0.
  8161. type
  8162. PFN_CERT_STORE_PROV_CLOSE = procedure(hStoreProv: HCERTSTOREPROV; dwFlags: DWORD); stdcall;
  8163. {$EXTERNALSYM PFN_CERT_STORE_PROV_CLOSE}
  8164. PFnCertStoreProvClose = PFN_CERT_STORE_PROV_CLOSE;
  8165. // Currently not called directly by the store APIs. However, may be exported
  8166. // to support other providers based on it.
  8167. //
  8168. // Reads the provider's copy of the certificate context. If it exists,
  8169. // creates a new certificate context.
  8170. PFN_CERT_STORE_PROV_READ_CERT = function(hStoreProv: HCERTSTOREPROV;
  8171. pStoreCertContext: PCCERT_CONTEXT; dwFlags: DWORD;
  8172. var ppProvCertContext: PCCERT_CONTEXT): BOOL; stdcall;
  8173. {$EXTERNALSYM PFN_CERT_STORE_PROV_READ_CERT}
  8174. PfnCertStoreProvReadCert = PFN_CERT_STORE_PROV_READ_CERT;
  8175. const
  8176. CERT_STORE_PROV_WRITE_ADD_FLAG = $1;
  8177. {$EXTERNALSYM CERT_STORE_PROV_WRITE_ADD_FLAG}
  8178. // Called by CertAddEncodedCertificateToStore,
  8179. // CertAddCertificateContextToStore or CertAddSerializedElementToStore before
  8180. // adding to the store. The CERT_STORE_PROV_WRITE_ADD_FLAG is set. In
  8181. // addition to the encoded certificate, the added pCertContext might also
  8182. // have properties.
  8183. //
  8184. // Returns TRUE if its OK to update the the store.
  8185. type
  8186. PFN_CERT_STORE_PROV_WRITE_CERT = function(hStoreProv: HCERTSTOREPROV;
  8187. pCertContext: PCCERT_CONTEXT; dwFlags: DWORD): BOOL; stdcall;
  8188. {$EXTERNALSYM PFN_CERT_STORE_PROV_WRITE_CERT}
  8189. PfnCertStoreProvWriteCert = PFN_CERT_STORE_PROV_WRITE_CERT;
  8190. // Called by CertDeleteCertificateFromStore before deleting from the
  8191. // store.
  8192. //
  8193. // Returns TRUE if its OK to delete from the store.
  8194. PFN_CERT_STORE_PROV_DELETE_CERT = function(hStoreProv: HCERTSTOREPROV;
  8195. pCertContext: PCCERT_CONTEXT; dwFlags: DWORD): BOOL; stdcall;
  8196. {$EXTERNALSYM PFN_CERT_STORE_PROV_DELETE_CERT}
  8197. PfnCertStoreProvDeleteCert = PFN_CERT_STORE_PROV_DELETE_CERT;
  8198. // Called by CertSetCertificateContextProperty before setting the
  8199. // certificate's property. Also called by CertGetCertificateContextProperty,
  8200. // when getting a hash property that needs to be created and then persisted
  8201. // via the set.
  8202. //
  8203. // Upon input, the property hasn't been set for the pCertContext parameter.
  8204. //
  8205. // Returns TRUE if its OK to set the property.
  8206. type
  8207. PFN_CERT_STORE_PROV_SET_CERT_PROPERTY = function(hStoreProv: HCERTSTOREPROV;
  8208. pCertContext: PCCERT_CONTEXT; dwPropId: DWORD; dwFlags: DWORD;
  8209. pvData: Pointer): BOOL; stdcall;
  8210. {$EXTERNALSYM PFN_CERT_STORE_PROV_SET_CERT_PROPERTY}
  8211. PfnCertStoreProvSetCertProperty = PFN_CERT_STORE_PROV_SET_CERT_PROPERTY;
  8212. // Currently not called directly by the store APIs. However, may be exported
  8213. // to support other providers based on it.
  8214. //
  8215. // Reads the provider's copy of the CRL context. If it exists,
  8216. // creates a new CRL context.
  8217. PFN_CERT_STORE_PROV_READ_CRL = function(hStoreProv: HCERTSTOREPROV;
  8218. pStoreCrlContext: PCCRL_CONTEXT; dwFlags: DWORD;
  8219. var ppProvCrlContext: PCCRL_CONTEXT): BOOL; stdcall;
  8220. {$EXTERNALSYM PFN_CERT_STORE_PROV_READ_CRL}
  8221. PfnCertStoreProvReadCrl = PFN_CERT_STORE_PROV_READ_CRL;
  8222. // Called by CertAddEncodedCRLToStore,
  8223. // CertAddCRLContextToStore or CertAddSerializedElementToStore before
  8224. // adding to the store. The CERT_STORE_PROV_WRITE_ADD_FLAG is set. In
  8225. // addition to the encoded CRL, the added pCertContext might also
  8226. // have properties.
  8227. //
  8228. // Returns TRUE if its OK to update the the store.
  8229. PFN_CERT_STORE_PROV_WRITE_CRL = function(hStoreProv: HCERTSTOREPROV;
  8230. pCrlContext: PCCRL_CONTEXT; dwFlags: DWORD): BOOL; stdcall;
  8231. {$EXTERNALSYM PFN_CERT_STORE_PROV_WRITE_CRL}
  8232. PfnCertStoreProvWriteCrl = PFN_CERT_STORE_PROV_WRITE_CRL;
  8233. // Called by CertDeleteCRLFromStore before deleting from the store.
  8234. //
  8235. // Returns TRUE if its OK to delete from the store.
  8236. PFN_CERT_STORE_PROV_DELETE_CRL = function(hStoreProv: HCERTSTOREPROV;
  8237. pCrlContext: PCCRL_CONTEXT; dwFlags: DWORD): BOOL; stdcall;
  8238. {$EXTERNALSYM PFN_CERT_STORE_PROV_DELETE_CRL}
  8239. PfnCertStoreProvDeleteCrl = PFN_CERT_STORE_PROV_DELETE_CRL;
  8240. // Called by CertSetCRLContextProperty before setting the
  8241. // CRL's property. Also called by CertGetCRLContextProperty,
  8242. // when getting a hash property that needs to be created and then persisted
  8243. // via the set.
  8244. //
  8245. // Upon input, the property hasn't been set for the pCrlContext parameter.
  8246. //
  8247. // Returns TRUE if its OK to set the property.
  8248. PFN_CERT_STORE_PROV_SET_CRL_PROPERTY = function(hStoreProv: HCERTSTOREPROV;
  8249. pCrlContext: PCCRL_CONTEXT; dwPropId: DWORD; dwFlags: DWORD;
  8250. pvData: Pointer): BOOL; stdcall;
  8251. {$EXTERNALSYM PFN_CERT_STORE_PROV_SET_CRL_PROPERTY}
  8252. PfnCertStoreProvSetCrlProperty = PFN_CERT_STORE_PROV_SET_CRL_PROPERTY;
  8253. // Currently not called directly by the store APIs. However, may be exported
  8254. // to support other providers based on it.
  8255. //
  8256. // Reads the provider's copy of the CTL context. If it exists,
  8257. // creates a new CTL context.
  8258. PFN_CERT_STORE_PROV_READ_CTL = function(hStoreProv: HCERTSTOREPROV;
  8259. pStoreCtlContext: PCCTL_CONTEXT; dwFlags: DWORD;
  8260. var ppProvCtlContext: PCCTL_CONTEXT): BOOL; stdcall;
  8261. {$EXTERNALSYM PFN_CERT_STORE_PROV_READ_CTL}
  8262. PfnCertStoreProvReadCtl = PFN_CERT_STORE_PROV_READ_CTL;
  8263. // Called by CertAddEncodedCTLToStore,
  8264. // CertAddCTLContextToStore or CertAddSerializedElementToStore before
  8265. // adding to the store. The CERT_STORE_PROV_WRITE_ADD_FLAG is set. In
  8266. // addition to the encoded CTL, the added pCertContext might also
  8267. // have properties.
  8268. //
  8269. // Returns TRUE if its OK to update the the store.
  8270. PFN_CERT_STORE_PROV_WRITE_CTL = function(hStoreProv: HCERTSTOREPROV;
  8271. pCtlContext: PCCTL_CONTEXT; dwFlags: DWORD): BOOL; stdcall;
  8272. {$EXTERNALSYM PFN_CERT_STORE_PROV_WRITE_CTL}
  8273. PfnCertStoreProvWriteCtl = PFN_CERT_STORE_PROV_WRITE_CTL;
  8274. // Called by CertDeleteCTLFromStore before deleting from the store.
  8275. //
  8276. // Returns TRUE if its OK to delete from the store.
  8277. PFN_CERT_STORE_PROV_DELETE_CTL = function(hStoreProv: HCERTSTOREPROV;
  8278. pCtlContext: PCCTL_CONTEXT; dwFlags: DWORD): BOOL; stdcall;
  8279. {$EXTERNALSYM PFN_CERT_STORE_PROV_DELETE_CTL}
  8280. PfnCertStoreProvDeleteCtl = PFN_CERT_STORE_PROV_DELETE_CTL;
  8281. // Called by CertSetCTLContextProperty before setting the
  8282. // CTL's property. Also called by CertGetCTLContextProperty,
  8283. // when getting a hash property that needs to be created and then persisted
  8284. // via the set.
  8285. //
  8286. // Upon input, the property hasn't been set for the pCtlContext parameter.
  8287. //
  8288. // Returns TRUE if its OK to set the property.
  8289. PFN_CERT_STORE_PROV_SET_CTL_PROPERTY = function(hStoreProv: HCERTSTOREPROV;
  8290. pCtlContext: PCCTL_CONTEXT; dwPropId, dwFlags: DWORD; pvData: Pointer): BOOL; stdcall;
  8291. {$EXTERNALSYM PFN_CERT_STORE_PROV_SET_CTL_PROPERTY}
  8292. PfnCertStoreProvSetCtlProperty = PFN_CERT_STORE_PROV_SET_CTL_PROPERTY;
  8293. PFN_CERT_STORE_PROV_CONTROL = function(hStoreProv: HCERTSTOREPROV;
  8294. dwFlags: DWORD; dwCtrlType: DWORD; pvCtrlPara: Pointer): BOOL; stdcall;
  8295. {$EXTERNALSYM PFN_CERT_STORE_PROV_CONTROL}
  8296. PfnCertStoreProvControl = PFN_CERT_STORE_PROV_CONTROL;
  8297. PCERT_STORE_PROV_FIND_INFO = ^CERT_STORE_PROV_FIND_INFO;
  8298. {$EXTERNALSYM PCERT_STORE_PROV_FIND_INFO}
  8299. _CERT_STORE_PROV_FIND_INFO = record
  8300. cbSize: DWORD;
  8301. dwMsgAndCertEncodingType: DWORD;
  8302. dwFindFlags: DWORD;
  8303. dwFindType: DWORD;
  8304. pvFindPara: Pointer;
  8305. end;
  8306. {$EXTERNALSYM _CERT_STORE_PROV_FIND_INFO}
  8307. CERT_STORE_PROV_FIND_INFO = _CERT_STORE_PROV_FIND_INFO;
  8308. {$EXTERNALSYM CERT_STORE_PROV_FIND_INFO}
  8309. TCertStoreProvFindInfo = CERT_STORE_PROV_FIND_INFO;
  8310. PCertStoreProvFindInfo = PCERT_STORE_PROV_FIND_INFO;
  8311. CCERT_STORE_PROV_FIND_INFO = CERT_STORE_PROV_FIND_INFO;
  8312. {$EXTERNALSYM CCERT_STORE_PROV_FIND_INFO}
  8313. PCCERT_STORE_PROV_FIND_INFO = PCERT_STORE_PROV_FIND_INFO;
  8314. {$EXTERNALSYM PCCERT_STORE_PROV_FIND_INFO}
  8315. PFN_CERT_STORE_PROV_FIND_CERT = function(hStoreProv: HCERTSTOREPROV;
  8316. pFindInfo: PCCERT_STORE_PROV_FIND_INFO; pPrevCertContext: PCCERT_CONTEXT;
  8317. dwFlags: DWORD; var ppvStoreProvFindInfo: Pointer;
  8318. var ppProvCertContext: PCCERT_CONTEXT): BOOL; stdcall;
  8319. {$EXTERNALSYM PFN_CERT_STORE_PROV_FIND_CERT}
  8320. PfnCertStoreProvFindCert = PFN_CERT_STORE_PROV_FIND_CERT;
  8321. PFN_CERT_STORE_PROV_FREE_FIND_CERT = function(hStoreProv: HCERTSTOREPROV;
  8322. pCertContext: PCCERT_CONTEXT; pvStoreProvFindInfo: Pointer; dwFlags: DWORD): BOOL; stdcall;
  8323. {$EXTERNALSYM PFN_CERT_STORE_PROV_FREE_FIND_CERT}
  8324. PfnCertStoreProvFreeFindCert = PFN_CERT_STORE_PROV_FREE_FIND_CERT;
  8325. PFN_CERT_STORE_PROV_GET_CERT_PROPERTY = function(hStoreProv: HCERTSTOREPROV;
  8326. pCertContext: PCCERT_CONTEXT; dwPropId: DWORD; dwFlags: DWORD; pvData: Pointer;
  8327. var pcbData: DWORD): BOOL; stdcall;
  8328. {$EXTERNALSYM PFN_CERT_STORE_PROV_GET_CERT_PROPERTY}
  8329. PfnCertStoreProvGetCertProperty = PFN_CERT_STORE_PROV_GET_CERT_PROPERTY;
  8330. PFN_CERT_STORE_PROV_FIND_CRL = function(hStoreProv: HCERTSTOREPROV;
  8331. pFindInfo: PCCERT_STORE_PROV_FIND_INFO; pPrevCrlContext: PCCRL_CONTEXT;
  8332. dwFlags: DWORD; var ppvStoreProvFindInfo: Pointer;
  8333. var ppProvCrlContext: PCCRL_CONTEXT): BOOL; stdcall;
  8334. {$EXTERNALSYM PFN_CERT_STORE_PROV_FIND_CRL}
  8335. PfnCertStoreProvFindCrl = PFN_CERT_STORE_PROV_FIND_CRL;
  8336. PFN_CERT_STORE_PROV_FREE_FIND_CRL = function(hStoreProv: HCERTSTOREPROV;
  8337. pCrlContext: PCCRL_CONTEXT; pvStoreProvFindInfo: Pointer; dwFlags: DWORD): BOOL; stdcall;
  8338. {$EXTERNALSYM PFN_CERT_STORE_PROV_FREE_FIND_CRL}
  8339. PfnCertStoreProvFreeFindCrl = PFN_CERT_STORE_PROV_FREE_FIND_CRL;
  8340. PFN_CERT_STORE_PROV_GET_CRL_PROPERTY = function(hStoreProv: HCERTSTOREPROV;
  8341. pCrlContext: PCCRL_CONTEXT; dwPropId: DWORD; dwFlags: DWORD; pvData: Pointer;
  8342. var pcbData: DWORD): BOOL; stdcall;
  8343. {$EXTERNALSYM PFN_CERT_STORE_PROV_GET_CRL_PROPERTY}
  8344. PfnCertStoreProvGetCrlProperty = PFN_CERT_STORE_PROV_GET_CRL_PROPERTY;
  8345. PFN_CERT_STORE_PROV_FIND_CTL = function(hStoreProv: HCERTSTOREPROV;
  8346. pFindInfo: PCCERT_STORE_PROV_FIND_INFO; pPrevCtlContext: PCCTL_CONTEXT;
  8347. dwFlags: DWORD; var ppvStoreProvFindInfo: Pointer;
  8348. var ppProvCtlContext: PCCTL_CONTEXT): BOOL; stdcall;
  8349. {$EXTERNALSYM PFN_CERT_STORE_PROV_FIND_CTL}
  8350. PfnCertStoreProvFindCtl = PFN_CERT_STORE_PROV_FIND_CTL;
  8351. PFN_CERT_STORE_PROV_FREE_FIND_CTL = function(hStoreProv: HCERTSTOREPROV;
  8352. pCtlContext: PCCTL_CONTEXT; pvStoreProvFindInfo: Pointer; dwFlags: DWORD): BOOL; stdcall;
  8353. {$EXTERNALSYM PFN_CERT_STORE_PROV_FREE_FIND_CTL}
  8354. PfnCertStoreProvFreeFindCtl = PFN_CERT_STORE_PROV_FREE_FIND_CTL;
  8355. PFN_CERT_STORE_PROV_GET_CTL_PROPERTY = function(hStoreProv: HCERTSTOREPROV;
  8356. pCtlContext: PCCTL_CONTEXT; dwPropId: DWORD; dwFlags: DWORD; pvData: Pointer;
  8357. var pcbData: DWORD): BOOL; stdcall;
  8358. {$EXTERNALSYM PFN_CERT_STORE_PROV_GET_CTL_PROPERTY}
  8359. PfnCertStoreProvGetCtlProperty = PFN_CERT_STORE_PROV_GET_CTL_PROPERTY;
  8360. //+-------------------------------------------------------------------------
  8361. // Duplicate a cert store handle
  8362. //--------------------------------------------------------------------------
  8363. function CertDuplicateStore(hCertStore: HCERTSTORE): HCERTSTORE; stdcall;
  8364. {$EXTERNALSYM CertDuplicateStore}
  8365. const
  8366. CERT_STORE_SAVE_AS_STORE = 1;
  8367. {$EXTERNALSYM CERT_STORE_SAVE_AS_STORE}
  8368. CERT_STORE_SAVE_AS_PKCS7 = 2;
  8369. {$EXTERNALSYM CERT_STORE_SAVE_AS_PKCS7}
  8370. CERT_STORE_SAVE_TO_FILE = 1;
  8371. {$EXTERNALSYM CERT_STORE_SAVE_TO_FILE}
  8372. CERT_STORE_SAVE_TO_MEMORY = 2;
  8373. {$EXTERNALSYM CERT_STORE_SAVE_TO_MEMORY}
  8374. CERT_STORE_SAVE_TO_FILENAME_A = 3;
  8375. {$EXTERNALSYM CERT_STORE_SAVE_TO_FILENAME_A}
  8376. CERT_STORE_SAVE_TO_FILENAME_W = 4;
  8377. {$EXTERNALSYM CERT_STORE_SAVE_TO_FILENAME_W}
  8378. CERT_STORE_SAVE_TO_FILENAME = CERT_STORE_SAVE_TO_FILENAME_W;
  8379. {$EXTERNALSYM CERT_STORE_SAVE_TO_FILENAME}
  8380. //+-------------------------------------------------------------------------
  8381. // Save the cert store. Extended version with lots of options.
  8382. //
  8383. // According to the dwSaveAs parameter, the store can be saved as a
  8384. // serialized store (CERT_STORE_SAVE_AS_STORE) containing properties in
  8385. // addition to encoded certificates, CRLs and CTLs or the store can be saved
  8386. // as a PKCS #7 signed message (CERT_STORE_SAVE_AS_PKCS7) which doesn't
  8387. // include the properties or CTLs.
  8388. //
  8389. // Note, the CERT_KEY_CONTEXT_PROP_ID property (and its
  8390. // CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_SPEC_PROP_ID) isn't saved into
  8391. // a serialized store.
  8392. //
  8393. // For CERT_STORE_SAVE_AS_PKCS7, the dwEncodingType specifies the message
  8394. // encoding type. The dwEncodingType parameter isn't used for
  8395. // CERT_STORE_SAVE_AS_STORE.
  8396. //
  8397. // The dwFlags parameter currently isn't used and should be set to 0.
  8398. //
  8399. // The dwSaveTo and pvSaveToPara parameters specify where to save the
  8400. // store as follows:
  8401. // CERT_STORE_SAVE_TO_FILE:
  8402. // Saves to the specified file. The file's handle is passed in
  8403. // pvSaveToPara. Given,
  8404. // HANDLE hFile; pvSaveToPara = (void *) hFile;
  8405. //
  8406. // For a successful save, the file pointer is positioned after the
  8407. // last write.
  8408. //
  8409. // CERT_STORE_SAVE_TO_MEMORY:
  8410. // Saves to the specified memory blob. The pointer to
  8411. // the memory blob is passed in pvSaveToPara. Given,
  8412. // CRYPT_DATA_BLOB SaveBlob; pvSaveToPara = (void *) &SaveBlob;
  8413. // Upon entry, the SaveBlob's pbData and cbData need to be initialized.
  8414. // Upon return, cbData is updated with the actual length.
  8415. // For a length only calculation, pbData should be set to NULL. If
  8416. // pbData is non-NULL and cbData isn't large enough, FALSE is returned
  8417. // with a last error of ERRROR_MORE_DATA.
  8418. //
  8419. // CERT_STORE_SAVE_TO_FILENAME_A:
  8420. // CERT_STORE_SAVE_TO_FILENAME_W:
  8421. // CERT_STORE_SAVE_TO_FILENAME:
  8422. // Opens the file and saves to it. The filename is passed in pvSaveToPara.
  8423. // The filename is UNICODE for the "_W" option and ASCII for the "_A"
  8424. // option. For "_W": given,
  8425. // LPCWSTR pwszFilename; pvSaveToPara = (void *) pwszFilename;
  8426. // For "_A": given,
  8427. // LPCSTR pszFilename; pvSaveToPara = (void *) pszFilename;
  8428. //
  8429. // Note, the default (without "_A" or "_W") is UNICODE.
  8430. //
  8431. //--------------------------------------------------------------------------
  8432. function CertSaveStore(hCertStore: HCERTSTORE; dwEncodingType, dwSaveAs: DWORD;
  8433. dwSaveTo: DWORD; pvSaveToPara: Pointer; dwFlags: DWORD): BOOL; stdcall;
  8434. {$EXTERNALSYM CertSaveStore}
  8435. //+-------------------------------------------------------------------------
  8436. // Certificate Store close flags
  8437. //--------------------------------------------------------------------------
  8438. const
  8439. CERT_CLOSE_STORE_FORCE_FLAG = $00000001;
  8440. {$EXTERNALSYM CERT_CLOSE_STORE_FORCE_FLAG}
  8441. CERT_CLOSE_STORE_CHECK_FLAG = $00000002;
  8442. {$EXTERNALSYM CERT_CLOSE_STORE_CHECK_FLAG}
  8443. //+-------------------------------------------------------------------------
  8444. // Close a cert store handle.
  8445. //
  8446. // There needs to be a corresponding close for each open and duplicate.
  8447. //
  8448. // Even on the final close, the cert store isn't freed until all of its
  8449. // certificate and CRL contexts have also been freed.
  8450. //
  8451. // On the final close, the hCryptProv passed to CertStoreOpen is
  8452. // CryptReleaseContext'ed.
  8453. //
  8454. // To force the closure of the store with all of its memory freed, set the
  8455. // CERT_STORE_CLOSE_FORCE_FLAG. This flag should be set when the caller does
  8456. // its own reference counting and wants everything to vanish.
  8457. //
  8458. // To check if all the store's certificates and CRLs have been freed and that
  8459. // this is the last CertCloseStore, set the CERT_CLOSE_STORE_CHECK_FLAG. If
  8460. // set and certs, CRLs or stores still need to be freed/closed, FALSE is
  8461. // returned with LastError set to CRYPT_E_PENDING_CLOSE. Note, for FALSE,
  8462. // the store is still closed. This is a diagnostic flag.
  8463. //
  8464. // LastError is preserved unless CERT_CLOSE_STORE_CHECK_FLAG is set and FALSE
  8465. // is returned.
  8466. //--------------------------------------------------------------------------
  8467. function CertCloseStore(hCertStore: HCERTSTORE; dwFlags: DWORD): BOOL; stdcall;
  8468. {$EXTERNALSYM CertCloseStore}
  8469. //+-------------------------------------------------------------------------
  8470. // Get the subject certificate context uniquely identified by its Issuer and
  8471. // SerialNumber from the store.
  8472. //
  8473. // If the certificate isn't found, NULL is returned. Otherwise, a pointer to
  8474. // a read only CERT_CONTEXT is returned. CERT_CONTEXT must be freed by calling
  8475. // CertFreeCertificateContext. CertDuplicateCertificateContext can be called to make a
  8476. // duplicate.
  8477. //
  8478. // The returned certificate might not be valid. Normally, it would be
  8479. // verified when getting its issuer certificate (CertGetIssuerCertificateFromStore).
  8480. //--------------------------------------------------------------------------
  8481. function CertGetSubjectCertificateFromStore(hCertStore: HCERTSTORE;
  8482. dwCertEncodingType: DWORD; pCertId: PCERT_INFO): PCCERT_CONTEXT; stdcall;
  8483. {$EXTERNALSYM CertGetSubjectCertificateFromStore}
  8484. //+-------------------------------------------------------------------------
  8485. // Enumerate the certificate contexts in the store.
  8486. //
  8487. // If a certificate isn't found, NULL is returned.
  8488. // Otherwise, a pointer to a read only CERT_CONTEXT is returned. CERT_CONTEXT
  8489. // must be freed by calling CertFreeCertificateContext or is freed when passed as the
  8490. // pPrevCertContext on a subsequent call. CertDuplicateCertificateContext
  8491. // can be called to make a duplicate.
  8492. //
  8493. // pPrevCertContext MUST BE NULL to enumerate the first
  8494. // certificate in the store. Successive certificates are enumerated by setting
  8495. // pPrevCertContext to the CERT_CONTEXT returned by a previous call.
  8496. //
  8497. // NOTE: a NON-NULL pPrevCertContext is always CertFreeCertificateContext'ed by
  8498. // this function, even for an error.
  8499. //--------------------------------------------------------------------------
  8500. function CertEnumCertificatesInStore(hCertStore: HCERTSTORE;
  8501. pPrevCertContext: PCCERT_CONTEXT): PCCERT_CONTEXT; stdcall;
  8502. {$EXTERNALSYM CertEnumCertificatesInStore}
  8503. //+-------------------------------------------------------------------------
  8504. // Find the first or next certificate context in the store.
  8505. //
  8506. // The certificate is found according to the dwFindType and its pvFindPara.
  8507. // See below for a list of the find types and its parameters.
  8508. //
  8509. // Currently dwFindFlags is only used for CERT_FIND_SUBJECT_ATTR,
  8510. // CERT_FIND_ISSUER_ATTR or CERT_FIND_CTL_USAGE. Otherwise, must be set to 0.
  8511. //
  8512. // Usage of dwCertEncodingType depends on the dwFindType.
  8513. //
  8514. // If the first or next certificate isn't found, NULL is returned.
  8515. // Otherwise, a pointer to a read only CERT_CONTEXT is returned. CERT_CONTEXT
  8516. // must be freed by calling CertFreeCertificateContext or is freed when passed as the
  8517. // pPrevCertContext on a subsequent call. CertDuplicateCertificateContext
  8518. // can be called to make a duplicate.
  8519. //
  8520. // pPrevCertContext MUST BE NULL on the first
  8521. // call to find the certificate. To find the next certificate, the
  8522. // pPrevCertContext is set to the CERT_CONTEXT returned by a previous call.
  8523. //
  8524. // NOTE: a NON-NULL pPrevCertContext is always CertFreeCertificateContext'ed by
  8525. // this function, even for an error.
  8526. //--------------------------------------------------------------------------
  8527. function CertFindCertificateInStore(hCertStore: HCERTSTORE;
  8528. dwCertEncodingType, dwFindFlags, dwFindType: DWORD; pvFindPara: Pointer;
  8529. pPrevCertContext: PCCERT_CONTEXT): PCCERT_CONTEXT; stdcall;
  8530. {$EXTERNALSYM CertFindCertificateInStore}
  8531. //+-------------------------------------------------------------------------
  8532. // Certificate comparison functions
  8533. //--------------------------------------------------------------------------
  8534. const
  8535. CERT_COMPARE_MASK = $FFFF;
  8536. {$EXTERNALSYM CERT_COMPARE_MASK}
  8537. CERT_COMPARE_SHIFT = 16;
  8538. {$EXTERNALSYM CERT_COMPARE_SHIFT}
  8539. CERT_COMPARE_ANY = 0;
  8540. {$EXTERNALSYM CERT_COMPARE_ANY}
  8541. CERT_COMPARE_SHA1_HASH = 1;
  8542. {$EXTERNALSYM CERT_COMPARE_SHA1_HASH}
  8543. CERT_COMPARE_NAME = 2;
  8544. {$EXTERNALSYM CERT_COMPARE_NAME}
  8545. CERT_COMPARE_ATTR = 3;
  8546. {$EXTERNALSYM CERT_COMPARE_ATTR}
  8547. CERT_COMPARE_MD5_HASH = 4;
  8548. {$EXTERNALSYM CERT_COMPARE_MD5_HASH}
  8549. CERT_COMPARE_PROPERTY = 5;
  8550. {$EXTERNALSYM CERT_COMPARE_PROPERTY}
  8551. CERT_COMPARE_PUBLIC_KEY = 6;
  8552. {$EXTERNALSYM CERT_COMPARE_PUBLIC_KEY}
  8553. CERT_COMPARE_HASH = CERT_COMPARE_SHA1_HASH;
  8554. {$EXTERNALSYM CERT_COMPARE_HASH}
  8555. CERT_COMPARE_NAME_STR_A = 7;
  8556. {$EXTERNALSYM CERT_COMPARE_NAME_STR_A}
  8557. CERT_COMPARE_NAME_STR_W = 8;
  8558. {$EXTERNALSYM CERT_COMPARE_NAME_STR_W}
  8559. CERT_COMPARE_KEY_SPEC = 9;
  8560. {$EXTERNALSYM CERT_COMPARE_KEY_SPEC}
  8561. CERT_COMPARE_ENHKEY_USAGE = 10;
  8562. {$EXTERNALSYM CERT_COMPARE_ENHKEY_USAGE}
  8563. CERT_COMPARE_CTL_USAGE = CERT_COMPARE_ENHKEY_USAGE;
  8564. {$EXTERNALSYM CERT_COMPARE_CTL_USAGE}
  8565. CERT_COMPARE_SUBJECT_CERT = 11;
  8566. {$EXTERNALSYM CERT_COMPARE_SUBJECT_CERT}
  8567. CERT_COMPARE_ISSUER_OF = 12;
  8568. {$EXTERNALSYM CERT_COMPARE_ISSUER_OF}
  8569. CERT_COMPARE_EXISTING = 13;
  8570. {$EXTERNALSYM CERT_COMPARE_EXISTING}
  8571. CERT_COMPARE_SIGNATURE_HASH = 14;
  8572. {$EXTERNALSYM CERT_COMPARE_SIGNATURE_HASH}
  8573. CERT_COMPARE_KEY_IDENTIFIER = 15;
  8574. {$EXTERNALSYM CERT_COMPARE_KEY_IDENTIFIER}
  8575. CERT_COMPARE_CERT_ID = 16;
  8576. {$EXTERNALSYM CERT_COMPARE_CERT_ID}
  8577. //+-------------------------------------------------------------------------
  8578. // dwFindType
  8579. //
  8580. // The dwFindType definition consists of two components:
  8581. // - comparison function
  8582. // - certificate information flag
  8583. //--------------------------------------------------------------------------
  8584. CERT_FIND_ANY = CERT_COMPARE_ANY shl CERT_COMPARE_SHIFT;
  8585. {$EXTERNALSYM CERT_FIND_ANY}
  8586. CERT_FIND_SHA1_HASH = CERT_COMPARE_SHA1_HASH shl CERT_COMPARE_SHIFT;
  8587. {$EXTERNALSYM CERT_FIND_SHA1_HASH}
  8588. CERT_FIND_MD5_HASH = CERT_COMPARE_MD5_HASH shl CERT_COMPARE_SHIFT;
  8589. {$EXTERNALSYM CERT_FIND_MD5_HASH}
  8590. CERT_FIND_SIGNATURE_HASH = CERT_COMPARE_SIGNATURE_HASH shl CERT_COMPARE_SHIFT;
  8591. {$EXTERNALSYM CERT_FIND_SIGNATURE_HASH}
  8592. CERT_FIND_KEY_IDENTIFIER = CERT_COMPARE_KEY_IDENTIFIER shl CERT_COMPARE_SHIFT;
  8593. {$EXTERNALSYM CERT_FIND_KEY_IDENTIFIER}
  8594. CERT_FIND_HASH = CERT_FIND_SHA1_HASH;
  8595. {$EXTERNALSYM CERT_FIND_HASH}
  8596. CERT_FIND_PROPERTY = CERT_COMPARE_PROPERTY shl CERT_COMPARE_SHIFT;
  8597. {$EXTERNALSYM CERT_FIND_PROPERTY}
  8598. CERT_FIND_PUBLIC_KEY = CERT_COMPARE_PUBLIC_KEY shl CERT_COMPARE_SHIFT;
  8599. {$EXTERNALSYM CERT_FIND_PUBLIC_KEY}
  8600. CERT_FIND_SUBJECT_NAME = CERT_COMPARE_NAME shl CERT_COMPARE_SHIFT or CERT_INFO_SUBJECT_FLAG;
  8601. {$EXTERNALSYM CERT_FIND_SUBJECT_NAME}
  8602. CERT_FIND_SUBJECT_ATTR = CERT_COMPARE_ATTR shl CERT_COMPARE_SHIFT or CERT_INFO_SUBJECT_FLAG;
  8603. {$EXTERNALSYM CERT_FIND_SUBJECT_ATTR}
  8604. CERT_FIND_ISSUER_NAME = CERT_COMPARE_NAME shl CERT_COMPARE_SHIFT or CERT_INFO_ISSUER_FLAG;
  8605. {$EXTERNALSYM CERT_FIND_ISSUER_NAME}
  8606. CERT_FIND_ISSUER_ATTR = CERT_COMPARE_ATTR shl CERT_COMPARE_SHIFT or CERT_INFO_ISSUER_FLAG;
  8607. {$EXTERNALSYM CERT_FIND_ISSUER_ATTR}
  8608. CERT_FIND_SUBJECT_STR_A = CERT_COMPARE_NAME_STR_A shl CERT_COMPARE_SHIFT or CERT_INFO_SUBJECT_FLAG;
  8609. {$EXTERNALSYM CERT_FIND_SUBJECT_STR_A}
  8610. CERT_FIND_SUBJECT_STR_W = CERT_COMPARE_NAME_STR_W shl CERT_COMPARE_SHIFT or CERT_INFO_SUBJECT_FLAG;
  8611. {$EXTERNALSYM CERT_FIND_SUBJECT_STR_W}
  8612. CERT_FIND_SUBJECT_STR = CERT_FIND_SUBJECT_STR_W;
  8613. {$EXTERNALSYM CERT_FIND_SUBJECT_STR}
  8614. CERT_FIND_ISSUER_STR_A = CERT_COMPARE_NAME_STR_A shl CERT_COMPARE_SHIFT or CERT_INFO_ISSUER_FLAG;
  8615. {$EXTERNALSYM CERT_FIND_ISSUER_STR_A}
  8616. CERT_FIND_ISSUER_STR_W = CERT_COMPARE_NAME_STR_W shl CERT_COMPARE_SHIFT or CERT_INFO_ISSUER_FLAG;
  8617. {$EXTERNALSYM CERT_FIND_ISSUER_STR_W}
  8618. CERT_FIND_ISSUER_STR = CERT_FIND_ISSUER_STR_W;
  8619. {$EXTERNALSYM CERT_FIND_ISSUER_STR}
  8620. CERT_FIND_KEY_SPEC = CERT_COMPARE_KEY_SPEC shl CERT_COMPARE_SHIFT;
  8621. {$EXTERNALSYM CERT_FIND_KEY_SPEC}
  8622. CERT_FIND_ENHKEY_USAGE = CERT_COMPARE_ENHKEY_USAGE shl CERT_COMPARE_SHIFT;
  8623. {$EXTERNALSYM CERT_FIND_ENHKEY_USAGE}
  8624. CERT_FIND_CTL_USAGE = CERT_FIND_ENHKEY_USAGE;
  8625. {$EXTERNALSYM CERT_FIND_CTL_USAGE}
  8626. CERT_FIND_SUBJECT_CERT = CERT_COMPARE_SUBJECT_CERT shl CERT_COMPARE_SHIFT;
  8627. {$EXTERNALSYM CERT_FIND_SUBJECT_CERT}
  8628. CERT_FIND_ISSUER_OF = CERT_COMPARE_ISSUER_OF shl CERT_COMPARE_SHIFT;
  8629. {$EXTERNALSYM CERT_FIND_ISSUER_OF}
  8630. CERT_FIND_EXISTING = CERT_COMPARE_EXISTING shl CERT_COMPARE_SHIFT;
  8631. {$EXTERNALSYM CERT_FIND_EXISTING}
  8632. CERT_FIND_CERT_ID = CERT_COMPARE_CERT_ID shl CERT_COMPARE_SHIFT;
  8633. {$EXTERNALSYM CERT_FIND_CERT_ID}
  8634. //+-------------------------------------------------------------------------
  8635. // CERT_FIND_ANY
  8636. //
  8637. // Find any certificate.
  8638. //
  8639. // pvFindPara isn't used.
  8640. //--------------------------------------------------------------------------
  8641. //+-------------------------------------------------------------------------
  8642. // CERT_FIND_HASH
  8643. //
  8644. // Find a certificate with the specified hash.
  8645. //
  8646. // pvFindPara points to a CRYPT_HASH_BLOB.
  8647. //--------------------------------------------------------------------------
  8648. //+-------------------------------------------------------------------------
  8649. // CERT_FIND_KEY_IDENTIFIER
  8650. //
  8651. // Find a certificate with the specified KeyIdentifier. Gets the
  8652. // CERT_KEY_IDENTIFIER_PROP_ID property and compares with the input
  8653. // CRYPT_HASH_BLOB.
  8654. //
  8655. // pvFindPara points to a CRYPT_HASH_BLOB.
  8656. //--------------------------------------------------------------------------
  8657. //+-------------------------------------------------------------------------
  8658. // CERT_FIND_PROPERTY
  8659. //
  8660. // Find a certificate having the specified property.
  8661. //
  8662. // pvFindPara points to a DWORD containing the PROP_ID
  8663. //--------------------------------------------------------------------------
  8664. //+-------------------------------------------------------------------------
  8665. // CERT_FIND_PUBLIC_KEY
  8666. //
  8667. // Find a certificate matching the specified public key.
  8668. //
  8669. // pvFindPara points to a CERT_PUBLIC_KEY_INFO containing the public key
  8670. //--------------------------------------------------------------------------
  8671. //+-------------------------------------------------------------------------
  8672. // CERT_FIND_SUBJECT_NAME
  8673. // CERT_FIND_ISSUER_NAME
  8674. //
  8675. // Find a certificate with the specified subject/issuer name. Does an exact
  8676. // match of the entire name.
  8677. //
  8678. // Restricts search to certificates matching the dwCertEncodingType.
  8679. //
  8680. // pvFindPara points to a CERT_NAME_BLOB.
  8681. //--------------------------------------------------------------------------
  8682. //+-------------------------------------------------------------------------
  8683. // CERT_FIND_SUBJECT_ATTR
  8684. // CERT_FIND_ISSUER_ATTR
  8685. //
  8686. // Find a certificate with the specified subject/issuer attributes.
  8687. //
  8688. // Compares the attributes in the subject/issuer name with the
  8689. // Relative Distinguished Name's (CERT_RDN) array of attributes specified in
  8690. // pvFindPara. The comparison iterates through the CERT_RDN attributes and looks
  8691. // for an attribute match in any of the subject/issuer's RDNs.
  8692. //
  8693. // The CERT_RDN_ATTR fields can have the following special values:
  8694. // pszObjId == NULL - ignore the attribute object identifier
  8695. // dwValueType == RDN_ANY_TYPE - ignore the value type
  8696. // Value.pbData == NULL - match any value
  8697. //
  8698. // CERT_CASE_INSENSITIVE_IS_RDN_ATTRS_FLAG should be set in dwFindFlags to do
  8699. // a case insensitive match. Otherwise, defaults to an exact, case sensitive
  8700. // match.
  8701. //
  8702. // CERT_UNICODE_IS_RDN_ATTRS_FLAG should be set in dwFindFlags if the RDN was
  8703. // initialized with unicode strings as for
  8704. // CryptEncodeObject(X509_UNICODE_NAME).
  8705. //
  8706. // Restricts search to certificates matching the dwCertEncodingType.
  8707. //
  8708. // pvFindPara points to a CERT_RDN (defined in wincert.h).
  8709. //--------------------------------------------------------------------------
  8710. //+-------------------------------------------------------------------------
  8711. // CERT_FIND_SUBJECT_STR_A
  8712. // CERT_FIND_SUBJECT_STR_W | CERT_FIND_SUBJECT_STR
  8713. // CERT_FIND_ISSUER_STR_A
  8714. // CERT_FIND_ISSUER_STR_W | CERT_FIND_ISSUER_STR
  8715. //
  8716. // Find a certificate containing the specified subject/issuer name string.
  8717. //
  8718. // First, the certificate's subject/issuer is converted to a name string
  8719. // via CertNameToStrA/CertNameToStrW(CERT_SIMPLE_NAME_STR). Then, a
  8720. // case insensitive substring within string match is performed.
  8721. //
  8722. // Restricts search to certificates matching the dwCertEncodingType.
  8723. //
  8724. // For *_STR_A, pvFindPara points to a null terminated character string.
  8725. // For *_STR_W, pvFindPara points to a null terminated wide character string.
  8726. //--------------------------------------------------------------------------
  8727. //+-------------------------------------------------------------------------
  8728. // CERT_FIND_KEY_SPEC
  8729. //
  8730. // Find a certificate having a CERT_KEY_SPEC_PROP_ID property matching
  8731. // the specified KeySpec.
  8732. //
  8733. // pvFindPara points to a DWORD containing the KeySpec.
  8734. //--------------------------------------------------------------------------
  8735. //+-------------------------------------------------------------------------
  8736. // CERT_FIND_ENHKEY_USAGE
  8737. //
  8738. // Find a certificate having the szOID_ENHANCED_KEY_USAGE extension or
  8739. // the CERT_ENHKEY_USAGE_PROP_ID and matching the specified pszUsageIdentifers.
  8740. //
  8741. // pvFindPara points to a CERT_ENHKEY_USAGE data structure. If pvFindPara
  8742. // is NULL or CERT_ENHKEY_USAGE's cUsageIdentifier is 0, then, matches any
  8743. // certificate having enhanced key usage.
  8744. //
  8745. // If the CERT_FIND_VALID_ENHKEY_USAGE_FLAG is set, then, only does a match
  8746. // for certificates that are valid for the specified usages. By default,
  8747. // the ceriticate must be valid for all usages. CERT_FIND_OR_ENHKEY_USAGE_FLAG
  8748. // can be set, if the certificate only needs to be valid for one of the
  8749. // specified usages. Note, CertGetValidUsages() is called to get the
  8750. // certificate's list of valid usages. Only the CERT_FIND_OR_ENHKEY_USAGE_FLAG
  8751. // is applicable when this flag is set.
  8752. //
  8753. // The CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG can be set in dwFindFlags to
  8754. // also match a certificate without either the extension or property.
  8755. //
  8756. // If CERT_FIND_NO_ENHKEY_USAGE_FLAG is set in dwFindFlags, finds
  8757. // certificates without the key usage extension or property. Setting this
  8758. // flag takes precedence over pvFindPara being NULL.
  8759. //
  8760. // If the CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG is set, then, only does a match
  8761. // using the extension. If pvFindPara is NULL or cUsageIdentifier is set to
  8762. // 0, finds certificates having the extension. If
  8763. // CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG is set, also matches a certificate
  8764. // without the extension. If CERT_FIND_NO_ENHKEY_USAGE_FLAG is set, finds
  8765. // certificates without the extension.
  8766. //
  8767. // If the CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG is set, then, only does a match
  8768. // using the property. If pvFindPara is NULL or cUsageIdentifier is set to
  8769. // 0, finds certificates having the property. If
  8770. // CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG is set, also matches a certificate
  8771. // without the property. If CERT_FIND_NO_ENHKEY_USAGE_FLAG is set, finds
  8772. // certificates without the property.
  8773. //
  8774. // If CERT_FIND_OR_ENHKEY_USAGE_FLAG is set, does an "OR" match of any of
  8775. // the specified pszUsageIdentifiers. If not set, then, does an "AND" match
  8776. // of all of the specified pszUsageIdentifiers.
  8777. //--------------------------------------------------------------------------
  8778. const
  8779. CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG = $1;
  8780. {$EXTERNALSYM CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG}
  8781. CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG = $2;
  8782. {$EXTERNALSYM CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG}
  8783. CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG = $4;
  8784. {$EXTERNALSYM CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG}
  8785. CERT_FIND_NO_ENHKEY_USAGE_FLAG = $8;
  8786. {$EXTERNALSYM CERT_FIND_NO_ENHKEY_USAGE_FLAG}
  8787. CERT_FIND_OR_ENHKEY_USAGE_FLAG = $10;
  8788. {$EXTERNALSYM CERT_FIND_OR_ENHKEY_USAGE_FLAG}
  8789. CERT_FIND_VALID_ENHKEY_USAGE_FLAG = $20;
  8790. {$EXTERNALSYM CERT_FIND_VALID_ENHKEY_USAGE_FLAG}
  8791. CERT_FIND_OPTIONAL_CTL_USAGE_FLAG = CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG;
  8792. {$EXTERNALSYM CERT_FIND_OPTIONAL_CTL_USAGE_FLAG}
  8793. CERT_FIND_EXT_ONLY_CTL_USAGE_FLAG = CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG;
  8794. {$EXTERNALSYM CERT_FIND_EXT_ONLY_CTL_USAGE_FLAG}
  8795. CERT_FIND_PROP_ONLY_CTL_USAGE_FLAG = CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG;
  8796. {$EXTERNALSYM CERT_FIND_PROP_ONLY_CTL_USAGE_FLAG}
  8797. CERT_FIND_NO_CTL_USAGE_FLAG = CERT_FIND_NO_ENHKEY_USAGE_FLAG;
  8798. {$EXTERNALSYM CERT_FIND_NO_CTL_USAGE_FLAG}
  8799. CERT_FIND_OR_CTL_USAGE_FLAG = CERT_FIND_OR_ENHKEY_USAGE_FLAG;
  8800. {$EXTERNALSYM CERT_FIND_OR_CTL_USAGE_FLAG}
  8801. CERT_FIND_VALID_CTL_USAGE_FLAG = CERT_FIND_VALID_ENHKEY_USAGE_FLAG;
  8802. {$EXTERNALSYM CERT_FIND_VALID_CTL_USAGE_FLAG}
  8803. //+-------------------------------------------------------------------------
  8804. // CERT_FIND_CERT_ID
  8805. //
  8806. // Find a certificate with the specified CERT_ID.
  8807. //
  8808. // pvFindPara points to a CERT_ID.
  8809. //--------------------------------------------------------------------------
  8810. //+-------------------------------------------------------------------------
  8811. // Get the certificate context from the store for the first or next issuer
  8812. // of the specified subject certificate. Perform the enabled
  8813. // verification checks on the subject. (Note, the checks are on the subject
  8814. // using the returned issuer certificate.)
  8815. //
  8816. // If the first or next issuer certificate isn't found, NULL is returned.
  8817. // Otherwise, a pointer to a read only CERT_CONTEXT is returned. CERT_CONTEXT
  8818. // must be freed by calling CertFreeCertificateContext or is freed when passed as the
  8819. // pPrevIssuerContext on a subsequent call. CertDuplicateCertificateContext
  8820. // can be called to make a duplicate.
  8821. //
  8822. // For a self signed subject certificate, NULL is returned with LastError set
  8823. // to CERT_STORE_SELF_SIGNED. The enabled verification checks are still done.
  8824. //
  8825. // The pSubjectContext may have been obtained from this store, another store
  8826. // or created by the caller application. When created by the caller, the
  8827. // CertCreateCertificateContext function must have been called.
  8828. //
  8829. // An issuer may have multiple certificates. This may occur when the validity
  8830. // period is about to change. pPrevIssuerContext MUST BE NULL on the first
  8831. // call to get the issuer. To get the next certificate for the issuer, the
  8832. // pPrevIssuerContext is set to the CERT_CONTEXT returned by a previous call.
  8833. //
  8834. // NOTE: a NON-NULL pPrevIssuerContext is always CertFreeCertificateContext'ed by
  8835. // this function, even for an error.
  8836. //
  8837. // The following flags can be set in *pdwFlags to enable verification checks
  8838. // on the subject certificate context:
  8839. // CERT_STORE_SIGNATURE_FLAG - use the public key in the returned
  8840. // issuer certificate to verify the
  8841. // signature on the subject certificate.
  8842. // Note, if pSubjectContext->hCertStore ==
  8843. // hCertStore, the store provider might
  8844. // be able to eliminate a redo of
  8845. // the signature verify.
  8846. // CERT_STORE_TIME_VALIDITY_FLAG - get the current time and verify that
  8847. // its within the subject certificate's
  8848. // validity period
  8849. // CERT_STORE_REVOCATION_FLAG - check if the subject certificate is on
  8850. // the issuer's revocation list
  8851. //
  8852. // If an enabled verification check fails, then, its flag is set upon return.
  8853. // If CERT_STORE_REVOCATION_FLAG was enabled and the issuer doesn't have a
  8854. // CRL in the store, then, CERT_STORE_NO_CRL_FLAG is set in addition to
  8855. // the CERT_STORE_REVOCATION_FLAG.
  8856. //
  8857. // If CERT_STORE_SIGNATURE_FLAG or CERT_STORE_REVOCATION_FLAG is set, then,
  8858. // CERT_STORE_NO_ISSUER_FLAG is set if it doesn't have an issuer certificate
  8859. // in the store.
  8860. //
  8861. // For a verification check failure, a pointer to the issuer's CERT_CONTEXT
  8862. // is still returned and SetLastError isn't updated.
  8863. //--------------------------------------------------------------------------
  8864. function CertGetIssuerCertificateFromStore(hCertStore: HCERTSTORE;
  8865. pSubjectContext, pPrevIssuerContext: PCCERT_CONTEXT; var pdwFlags: DWORD): PCCERT_CONTEXT; stdcall;
  8866. {$EXTERNALSYM CertGetIssuerCertificateFromStore}
  8867. //+-------------------------------------------------------------------------
  8868. // Perform the enabled verification checks on the subject certificate
  8869. // using the issuer. Same checks and flags definitions as for the above
  8870. // CertGetIssuerCertificateFromStore.
  8871. //
  8872. // If you are only checking CERT_STORE_TIME_VALIDITY_FLAG, then, the
  8873. // issuer can be NULL.
  8874. //
  8875. // For a verification check failure, SUCCESS is still returned.
  8876. //--------------------------------------------------------------------------
  8877. function CertVerifySubjectCertificateContext(pSubject: PCCERT_CONTEXT;
  8878. pIssuer: PCCERT_CONTEXT; var pdwFlags: DWORD): BOOL; stdcall;
  8879. {$EXTERNALSYM CertVerifySubjectCertificateContext}
  8880. //+-------------------------------------------------------------------------
  8881. // Duplicate a certificate context
  8882. //--------------------------------------------------------------------------
  8883. function CertDuplicateCertificateContext(pCertContext: PCCERT_CONTEXT): PCCERT_CONTEXT; stdcall;
  8884. {$EXTERNALSYM CertDuplicateCertificateContext}
  8885. //+-------------------------------------------------------------------------
  8886. // Create a certificate context from the encoded certificate. The created
  8887. // context isn't put in a store.
  8888. //
  8889. // Makes a copy of the encoded certificate in the created context.
  8890. //
  8891. // If unable to decode and create the certificate context, NULL is returned.
  8892. // Otherwise, a pointer to a read only CERT_CONTEXT is returned.
  8893. // CERT_CONTEXT must be freed by calling CertFreeCertificateContext.
  8894. // CertDuplicateCertificateContext can be called to make a duplicate.
  8895. //
  8896. // CertSetCertificateContextProperty and CertGetCertificateContextProperty can be called
  8897. // to store properties for the certificate.
  8898. //--------------------------------------------------------------------------
  8899. function CertCreateCertificateContext(dwCertEncodingType: DWORD;
  8900. pbCertEncoded: LPBYTE; cbCertEncoded: DWORD): PCCERT_CONTEXT; stdcall;
  8901. {$EXTERNALSYM CertCreateCertificateContext}
  8902. //+-------------------------------------------------------------------------
  8903. // Free a certificate context
  8904. //
  8905. // There needs to be a corresponding free for each context obtained by a
  8906. // get, find, duplicate or create.
  8907. //--------------------------------------------------------------------------
  8908. function CertFreeCertificateContext(pCertContext: PCCERT_CONTEXT): BOOL; stdcall;
  8909. {$EXTERNALSYM CertFreeCertificateContext}
  8910. //+-------------------------------------------------------------------------
  8911. // Set the property for the specified certificate context.
  8912. //
  8913. // The type definition for pvData depends on the dwPropId value. There are
  8914. // five predefined types:
  8915. // CERT_KEY_PROV_HANDLE_PROP_ID - a HCRYPTPROV for the certificate's
  8916. // private key is passed in pvData. Updates the hCryptProv field
  8917. // of the CERT_KEY_CONTEXT_PROP_ID. If the CERT_KEY_CONTEXT_PROP_ID
  8918. // doesn't exist, its created with all the other fields zeroed out. If
  8919. // CERT_STORE_NO_CRYPT_RELEASE_FLAG isn't set, HCRYPTPROV is implicitly
  8920. // released when either the property is set to NULL or on the final
  8921. // free of the CertContext.
  8922. //
  8923. // CERT_KEY_PROV_INFO_PROP_ID - a PCRYPT_KEY_PROV_INFO for the certificate's
  8924. // private key is passed in pvData.
  8925. //
  8926. // CERT_SHA1_HASH_PROP_ID -
  8927. // CERT_MD5_HASH_PROP_ID -
  8928. // CERT_SIGNATURE_HASH_PROP_ID - normally, a hash property is implicitly
  8929. // set by doing a CertGetCertificateContextProperty. pvData points to a
  8930. // CRYPT_HASH_BLOB.
  8931. //
  8932. // CERT_KEY_CONTEXT_PROP_ID - a PCERT_KEY_CONTEXT for the certificate's
  8933. // private key is passed in pvData. The CERT_KEY_CONTEXT contains both the
  8934. // hCryptProv and dwKeySpec for the private key.
  8935. // See the CERT_KEY_PROV_HANDLE_PROP_ID for more information about
  8936. // the hCryptProv field and dwFlags settings. Note, more fields may
  8937. // be added for this property. The cbSize field value will be adjusted
  8938. // accordingly.
  8939. //
  8940. // CERT_KEY_SPEC_PROP_ID - the dwKeySpec for the private key. pvData
  8941. // points to a DWORD containing the KeySpec
  8942. //
  8943. // CERT_ENHKEY_USAGE_PROP_ID - enhanced key usage definition for the
  8944. // certificate. pvData points to a CRYPT_DATA_BLOB containing an
  8945. // ASN.1 encoded CERT_ENHKEY_USAGE (encoded via
  8946. // CryptEncodeObject(X509_ENHANCED_KEY_USAGE).
  8947. //
  8948. // CERT_NEXT_UPDATE_LOCATION_PROP_ID - location of the next update.
  8949. // Currently only applicable to CTLs. pvData points to a CRYPT_DATA_BLOB
  8950. // containing an ASN.1 encoded CERT_ALT_NAME_INFO (encoded via
  8951. // CryptEncodeObject(X509_ALTERNATE_NAME)).
  8952. //
  8953. // CERT_FRIENDLY_NAME_PROP_ID - friendly name for the cert, CRL or CTL.
  8954. // pvData points to a CRYPT_DATA_BLOB. pbData is a pointer to a NULL
  8955. // terminated unicode, wide character string.
  8956. // cbData = (wcslen((LPWSTR) pbData) + 1) * sizeof(WCHAR).
  8957. //
  8958. // CERT_DESCRIPTION_PROP_ID - description for the cert, CRL or CTL.
  8959. // pvData points to a CRYPT_DATA_BLOB. pbData is a pointer to a NULL
  8960. // terminated unicode, wide character string.
  8961. // cbData = (wcslen((LPWSTR) pbData) + 1) * sizeof(WCHAR).
  8962. //
  8963. // CERT_ARCHIVED_PROP_ID - when this property is set, the certificate
  8964. // is skipped during enumeration. Note, certificates having this property
  8965. // are still found for explicit finds, such as, finding a certificate
  8966. // with a specific hash or finding a certificate having a specific issuer
  8967. // and serial number. pvData points to a CRYPT_DATA_BLOB. This blob
  8968. // can be NULL (pbData = NULL, cbData = 0).
  8969. //
  8970. // CERT_PUBKEY_ALG_PARA_PROP_ID - for public keys supporting
  8971. // algorithm parameter inheritance. pvData points to a CRYPT_OBJID_BLOB
  8972. // containing the ASN.1 encoded PublicKey Algorithm Parameters. For
  8973. // DSS this would be the parameters encoded via
  8974. // CryptEncodeObject(X509_DSS_PARAMETERS). This property may be set
  8975. // by CryptVerifyCertificateSignatureEx().
  8976. //
  8977. // For all the other PROP_IDs: an encoded PCRYPT_DATA_BLOB is passed in pvData.
  8978. //
  8979. // If the property already exists, then, the old value is deleted and silently
  8980. // replaced. Setting, pvData to NULL, deletes the property.
  8981. //
  8982. // CERT_SET_PROPERTY_IGNORE_PERSIST_ERROR_FLAG can be set to ignore any
  8983. // provider write errors and always update the cached context's property.
  8984. //--------------------------------------------------------------------------
  8985. function CertSetCertificateContextProperty(pCertContext: PCCERT_CONTEXT;
  8986. dwPropId: DWORD; dwFlags: DWORD; pvData: Pointer): BOOL; stdcall;
  8987. {$EXTERNALSYM CertSetCertificateContextProperty}
  8988. // Set this flag to ignore any store provider write errors and always update
  8989. // the cached context's property
  8990. const
  8991. CERT_SET_PROPERTY_IGNORE_PERSIST_ERROR_FLAG = DWORD($80000000);
  8992. {$EXTERNALSYM CERT_SET_PROPERTY_IGNORE_PERSIST_ERROR_FLAG}
  8993. //+-------------------------------------------------------------------------
  8994. // Get the property for the specified certificate context.
  8995. //
  8996. // For CERT_KEY_PROV_HANDLE_PROP_ID, pvData points to a HCRYPTPROV.
  8997. //
  8998. // For CERT_KEY_PROV_INFO_PROP_ID, pvData points to a CRYPT_KEY_PROV_INFO structure.
  8999. // Elements pointed to by fields in the pvData structure follow the
  9000. // structure. Therefore, *pcbData may exceed the size of the structure.
  9001. //
  9002. // For CERT_KEY_CONTEXT_PROP_ID, pvData points to a CERT_KEY_CONTEXT structure.
  9003. //
  9004. // For CERT_KEY_SPEC_PROP_ID, pvData points to a DWORD containing the KeySpec.
  9005. // If the CERT_KEY_CONTEXT_PROP_ID exists, the KeySpec is obtained from there.
  9006. // Otherwise, if the CERT_KEY_PROV_INFO_PROP_ID exists, its the source
  9007. // of the KeySpec.
  9008. //
  9009. // For CERT_SHA1_HASH_PROP_ID or CERT_MD5_HASH_PROP_ID, if the hash
  9010. // doesn't already exist, then, its computed via CryptHashCertificate()
  9011. // and then set. pvData points to the computed hash. Normally, the length
  9012. // is 20 bytes for SHA and 16 for MD5.
  9013. //
  9014. // For CERT_SIGNATURE_HASH_PROP_ID, if the hash
  9015. // doesn't already exist, then, its computed via CryptHashToBeSigned()
  9016. // and then set. pvData points to the computed hash. Normally, the length
  9017. // is 20 bytes for SHA and 16 for MD5.
  9018. //
  9019. // For CERT_ACCESS_STATE_PROP_ID, pvData points to a DWORD containing the
  9020. // access state flags. The appropriate CERT_ACCESS_STATE_*_FLAG's are set
  9021. // in the returned DWORD. See the CERT_ACCESS_STATE_*_FLAG definitions
  9022. // above. Note, this property is read only. It can't be set.
  9023. //
  9024. // For CERT_KEY_IDENTIFIER_PROP_ID, if property doesn't already exist,
  9025. // first searches for the szOID_SUBJECT_KEY_IDENTIFIER extension. Next,
  9026. // does SHA1 hash of the certficate's SubjectPublicKeyInfo. pvData
  9027. // points to the key identifier bytes. Normally, the length is 20 bytes.
  9028. //
  9029. // For CERT_PUBKEY_ALG_PARA_PROP_ID, pvPara points to the ASN.1 encoded
  9030. // PublicKey Algorithm Parameters. This property will only be set
  9031. // for public keys supporting algorithm parameter inheritance and when the
  9032. // parameters have been omitted from the encoded and signed certificate.
  9033. //
  9034. // For all other PROP_IDs, pvData points to an encoded array of bytes.
  9035. //--------------------------------------------------------------------------
  9036. function CertGetCertificateContextProperty(pCertContext: PCCERT_CONTEXT;
  9037. dwPropId: DWORD; pvData: Pointer; var pcbData: DWORD): BOOL; stdcall;
  9038. {$EXTERNALSYM CertGetCertificateContextProperty}
  9039. //+-------------------------------------------------------------------------
  9040. // Enumerate the properties for the specified certificate context.
  9041. //
  9042. // To get the first property, set dwPropId to 0. The ID of the first
  9043. // property is returned. To get the next property, set dwPropId to the
  9044. // ID returned by the last call. To enumerate all the properties continue
  9045. // until 0 is returned.
  9046. //
  9047. // CertGetCertificateContextProperty is called to get the property's data.
  9048. //
  9049. // Note, since, the CERT_KEY_PROV_HANDLE_PROP_ID and CERT_KEY_SPEC_PROP_ID
  9050. // properties are stored as fields in the CERT_KEY_CONTEXT_PROP_ID
  9051. // property, they aren't enumerated individually.
  9052. //--------------------------------------------------------------------------
  9053. function CertEnumCertificateContextProperties(pCertContext: PCCERT_CONTEXT;
  9054. dwPropId: DWORD): DWORD; stdcall;
  9055. {$EXTERNALSYM CertEnumCertificateContextProperties}
  9056. //+-------------------------------------------------------------------------
  9057. // Get the first or next CRL context from the store for the specified
  9058. // issuer certificate. Perform the enabled verification checks on the CRL.
  9059. //
  9060. // If the first or next CRL isn't found, NULL is returned.
  9061. // Otherwise, a pointer to a read only CRL_CONTEXT is returned. CRL_CONTEXT
  9062. // must be freed by calling CertFreeCRLContext. However, the free must be
  9063. // pPrevCrlContext on a subsequent call. CertDuplicateCRLContext
  9064. // can be called to make a duplicate.
  9065. //
  9066. // The pIssuerContext may have been obtained from this store, another store
  9067. // or created by the caller application. When created by the caller, the
  9068. // CertCreateCertificateContext function must have been called.
  9069. //
  9070. // If pIssuerContext == NULL, finds all the CRLs in the store.
  9071. //
  9072. // An issuer may have multiple CRLs. For example, it generates delta CRLs
  9073. // using a X.509 v3 extension. pPrevCrlContext MUST BE NULL on the first
  9074. // call to get the CRL. To get the next CRL for the issuer, the
  9075. // pPrevCrlContext is set to the CRL_CONTEXT returned by a previous call.
  9076. //
  9077. // NOTE: a NON-NULL pPrevCrlContext is always CertFreeCRLContext'ed by
  9078. // this function, even for an error.
  9079. //
  9080. // The following flags can be set in *pdwFlags to enable verification checks
  9081. // on the returned CRL:
  9082. // CERT_STORE_SIGNATURE_FLAG - use the public key in the
  9083. // issuer's certificate to verify the
  9084. // signature on the returned CRL.
  9085. // Note, if pIssuerContext->hCertStore ==
  9086. // hCertStore, the store provider might
  9087. // be able to eliminate a redo of
  9088. // the signature verify.
  9089. // CERT_STORE_TIME_VALIDITY_FLAG - get the current time and verify that
  9090. // its within the CRL's ThisUpdate and
  9091. // NextUpdate validity period.
  9092. //
  9093. // If an enabled verification check fails, then, its flag is set upon return.
  9094. //
  9095. // If pIssuerContext == NULL, then, an enabled CERT_STORE_SIGNATURE_FLAG
  9096. // always fails and the CERT_STORE_NO_ISSUER_FLAG is also set.
  9097. //
  9098. // For a verification check failure, a pointer to the first or next
  9099. // CRL_CONTEXT is still returned and SetLastError isn't updated.
  9100. //--------------------------------------------------------------------------
  9101. function CertGetCRLFromStore(hCertStore: HCERTSTORE; pIssuerContext: PCCERT_CONTEXT;
  9102. pPrevCrlContext: PCCRL_CONTEXT; var pdwFlags: DWORD): PCCRL_CONTEXT; stdcall;
  9103. {$EXTERNALSYM CertGetCRLFromStore}
  9104. //+-------------------------------------------------------------------------
  9105. // Enumerate the CRL contexts in the store.
  9106. //
  9107. // If a CRL isn't found, NULL is returned.
  9108. // Otherwise, a pointer to a read only CRL_CONTEXT is returned. CRL_CONTEXT
  9109. // must be freed by calling CertFreeCRLContext or is freed when passed as the
  9110. // pPrevCrlContext on a subsequent call. CertDuplicateCRLContext
  9111. // can be called to make a duplicate.
  9112. //
  9113. // pPrevCrlContext MUST BE NULL to enumerate the first
  9114. // CRL in the store. Successive CRLs are enumerated by setting
  9115. // pPrevCrlContext to the CRL_CONTEXT returned by a previous call.
  9116. //
  9117. // NOTE: a NON-NULL pPrevCrlContext is always CertFreeCRLContext'ed by
  9118. // this function, even for an error.
  9119. //--------------------------------------------------------------------------
  9120. function CertEnumCRLsInStore(hCertStore: HCERTSTORE;
  9121. pPrevCrlContext: PCCRL_CONTEXT): PCCRL_CONTEXT; stdcall;
  9122. {$EXTERNALSYM CertEnumCRLsInStore}
  9123. //+-------------------------------------------------------------------------
  9124. // Find the first or next CRL context in the store.
  9125. //
  9126. // The CRL is found according to the dwFindType and its pvFindPara.
  9127. // See below for a list of the find types and its parameters.
  9128. //
  9129. // Currently dwFindFlags isn't used and must be set to 0.
  9130. //
  9131. // Usage of dwCertEncodingType depends on the dwFindType.
  9132. //
  9133. // If the first or next CRL isn't found, NULL is returned.
  9134. // Otherwise, a pointer to a read only CRL_CONTEXT is returned. CRL_CONTEXT
  9135. // must be freed by calling CertFreeCRLContext or is freed when passed as the
  9136. // pPrevCrlContext on a subsequent call. CertDuplicateCRLContext
  9137. // can be called to make a duplicate.
  9138. //
  9139. // pPrevCrlContext MUST BE NULL on the first
  9140. // call to find the CRL. To find the next CRL, the
  9141. // pPrevCrlContext is set to the CRL_CONTEXT returned by a previous call.
  9142. //
  9143. // NOTE: a NON-NULL pPrevCrlContext is always CertFreeCRLContext'ed by
  9144. // this function, even for an error.
  9145. //--------------------------------------------------------------------------
  9146. function CertFindCRLInStore(hCertStore: HCERTSTORE; dwCertEncodingType: DWORD;
  9147. dwFindFlags: DWORD; dwFindType: DWORD; pvFindPara: Pointer;
  9148. pPrevCrlContext: PCCRL_CONTEXT): PCCRL_CONTEXT; stdcall;
  9149. {$EXTERNALSYM CertFindCRLInStore}
  9150. const
  9151. CRL_FIND_ANY = 0;
  9152. {$EXTERNALSYM CRL_FIND_ANY}
  9153. CRL_FIND_ISSUED_BY = 1;
  9154. {$EXTERNALSYM CRL_FIND_ISSUED_BY}
  9155. CRL_FIND_EXISTING = 2;
  9156. {$EXTERNALSYM CRL_FIND_EXISTING}
  9157. //+-------------------------------------------------------------------------
  9158. // CRL_FIND_ANY
  9159. //
  9160. // Find any CRL.
  9161. //
  9162. // pvFindPara isn't used.
  9163. //--------------------------------------------------------------------------
  9164. //+-------------------------------------------------------------------------
  9165. // CRL_FIND_ISSUED_BY
  9166. //
  9167. // Find CRL matching the specified issuer.
  9168. //
  9169. // pvFindPara is the PCCERT_CONTEXT of the CRL issuer.
  9170. //
  9171. // By default, only does issuer name matching. The following flags can be
  9172. // set in dwFindFlags to do additional filtering.
  9173. //
  9174. // If CRL_FIND_ISSUED_BY_AKI_FLAG is set in dwFindFlags, then, checks if the
  9175. // CRL has an Authority Key Identifier (AKI) extension. If the CRL has an
  9176. // AKI, then, only returns a CRL whose AKI matches the issuer.
  9177. //
  9178. // Note, the AKI extension has the following OID:
  9179. // szOID_AUTHORITY_KEY_IDENTIFIER2 and its corresponding data structure.
  9180. //
  9181. // If CRL_FIND_ISSUED_BY_SIGNATURE_FLAG is set in dwFindFlags, then,
  9182. // uses the public key in the issuer's certificate to verify the
  9183. // signature on the CRL. Only returns a CRL having a valid signature.
  9184. //--------------------------------------------------------------------------
  9185. const
  9186. CRL_FIND_ISSUED_BY_AKI_FLAG = $1;
  9187. {$EXTERNALSYM CRL_FIND_ISSUED_BY_AKI_FLAG}
  9188. CRL_FIND_ISSUED_BY_SIGNATURE_FLAG = $2;
  9189. {$EXTERNALSYM CRL_FIND_ISSUED_BY_SIGNATURE_FLAG}
  9190. //+-------------------------------------------------------------------------
  9191. // CRL_FIND_EXISTING
  9192. //
  9193. // Find existing CRL in the store.
  9194. //
  9195. // pvFindPara is the PCCRL_CONTEXT of the CRL to check if it already
  9196. // exists in the store.
  9197. //--------------------------------------------------------------------------
  9198. //+-------------------------------------------------------------------------
  9199. // Duplicate a CRL context
  9200. //--------------------------------------------------------------------------
  9201. function CertDuplicateCRLContext(pCrlContext: PCCRL_CONTEXT): PCCRL_CONTEXT; stdcall;
  9202. {$EXTERNALSYM CertDuplicateCRLContext}
  9203. //+-------------------------------------------------------------------------
  9204. // Create a CRL context from the encoded CRL. The created
  9205. // context isn't put in a store.
  9206. //
  9207. // Makes a copy of the encoded CRL in the created context.
  9208. //
  9209. // If unable to decode and create the CRL context, NULL is returned.
  9210. // Otherwise, a pointer to a read only CRL_CONTEXT is returned.
  9211. // CRL_CONTEXT must be freed by calling CertFreeCRLContext.
  9212. // CertDuplicateCRLContext can be called to make a duplicate.
  9213. //
  9214. // CertSetCRLContextProperty and CertGetCRLContextProperty can be called
  9215. // to store properties for the CRL.
  9216. //--------------------------------------------------------------------------
  9217. function CertCreateCRLContext(dwCertEncodingType: DWORD; pbCrlEncoded: LPBYTE;
  9218. cbCrlEncoded: DWORD): PCCRL_CONTEXT; stdcall;
  9219. {$EXTERNALSYM CertCreateCRLContext}
  9220. //+-------------------------------------------------------------------------
  9221. // Free a CRL context
  9222. //
  9223. // There needs to be a corresponding free for each context obtained by a
  9224. // get, duplicate or create.
  9225. //--------------------------------------------------------------------------
  9226. function CertFreeCRLContext(pCrlContext: PCCRL_CONTEXT): BOOL; stdcall;
  9227. {$EXTERNALSYM CertFreeCRLContext}
  9228. //+-------------------------------------------------------------------------
  9229. // Set the property for the specified CRL context.
  9230. //
  9231. // Same Property Ids and semantics as CertSetCertificateContextProperty.
  9232. //--------------------------------------------------------------------------
  9233. function CertSetCRLContextProperty(pCrlContext: PCCRL_CONTEXT; dwPropId: DWORD;
  9234. dwFlags: DWORD; pvData: Pointer): BOOL; stdcall;
  9235. {$EXTERNALSYM CertSetCRLContextProperty}
  9236. //+-------------------------------------------------------------------------
  9237. // Get the property for the specified CRL context.
  9238. //
  9239. // Same Property Ids and semantics as CertGetCertificateContextProperty.
  9240. //
  9241. // CERT_SHA1_HASH_PROP_ID, CERT_MD5_HASH_PROP_ID or
  9242. // CERT_SIGNATURE_HASH_PROP_ID is the predefined property of most interest.
  9243. //--------------------------------------------------------------------------
  9244. function CertGetCRLContextProperty(pCrlContext: PCCRL_CONTEXT; dwPropId: DWORD;
  9245. pvData: Pointer; var pcbData: DWORD): BOOL; stdcall;
  9246. {$EXTERNALSYM CertGetCRLContextProperty}
  9247. //+-------------------------------------------------------------------------
  9248. // Enumerate the properties for the specified CRL context.
  9249. //
  9250. // To get the first property, set dwPropId to 0. The ID of the first
  9251. // property is returned. To get the next property, set dwPropId to the
  9252. // ID returned by the last call. To enumerate all the properties continue
  9253. // until 0 is returned.
  9254. //
  9255. // CertGetCRLContextProperty is called to get the property's data.
  9256. //--------------------------------------------------------------------------
  9257. function CertEnumCRLContextProperties(pCrlContext: PCCRL_CONTEXT;
  9258. dwPropId: DWORD): DWORD; stdcall;
  9259. {$EXTERNALSYM CertEnumCRLContextProperties}
  9260. //+-------------------------------------------------------------------------
  9261. // Search the CRL's list of entries for the specified certificate.
  9262. //
  9263. // TRUE is returned if we were able to search the list. Otherwise, FALSE is
  9264. // returned,
  9265. //
  9266. // For success, if the certificate was found in the list, *ppCrlEntry is
  9267. // updated with a pointer to the entry. Otherwise, *ppCrlEntry is set to NULL.
  9268. // The returned entry isn't allocated and must not be freed.
  9269. //
  9270. // dwFlags and pvReserved currently aren't used and must be set to 0 or NULL.
  9271. //--------------------------------------------------------------------------
  9272. function CertFindCertificateInCRL(pCert: PCCERT_CONTEXT; pCrlContext: PCCRL_CONTEXT;
  9273. dwFlags: DWORD; pvReserved: Pointer; var ppCrlEntry: PCRL_ENTRY): BOOL; stdcall;
  9274. {$EXTERNALSYM CertFindCertificateInCRL}
  9275. //+-------------------------------------------------------------------------
  9276. // Add certificate/CRL, encoded, context or element disposition values.
  9277. //--------------------------------------------------------------------------
  9278. const
  9279. CERT_STORE_ADD_NEW = 1;
  9280. {$EXTERNALSYM CERT_STORE_ADD_NEW}
  9281. CERT_STORE_ADD_USE_EXISTING = 2;
  9282. {$EXTERNALSYM CERT_STORE_ADD_USE_EXISTING}
  9283. CERT_STORE_ADD_REPLACE_EXISTING = 3;
  9284. {$EXTERNALSYM CERT_STORE_ADD_REPLACE_EXISTING}
  9285. CERT_STORE_ADD_ALWAYS = 4;
  9286. {$EXTERNALSYM CERT_STORE_ADD_ALWAYS}
  9287. CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES = 5;
  9288. {$EXTERNALSYM CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES}
  9289. CERT_STORE_ADD_NEWER = 6;
  9290. {$EXTERNALSYM CERT_STORE_ADD_NEWER}
  9291. CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES = 7;
  9292. {$EXTERNALSYM CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES}
  9293. //+-------------------------------------------------------------------------
  9294. // Add the encoded certificate to the store according to the specified
  9295. // disposition action.
  9296. //
  9297. // Makes a copy of the encoded certificate before adding to the store.
  9298. //
  9299. // dwAddDispostion specifies the action to take if the certificate
  9300. // already exists in the store. This parameter must be one of the following
  9301. // values:
  9302. // CERT_STORE_ADD_NEW
  9303. // Fails if the certificate already exists in the store. LastError
  9304. // is set to CRYPT_E_EXISTS.
  9305. // CERT_STORE_ADD_USE_EXISTING
  9306. // If the certifcate already exists, then, its used and if ppCertContext
  9307. // is non-NULL, the existing context is duplicated.
  9308. // CERT_STORE_ADD_REPLACE_EXISTING
  9309. // If the certificate already exists, then, the existing certificate
  9310. // context is deleted before creating and adding the new context.
  9311. // CERT_STORE_ADD_ALWAYS
  9312. // No check is made to see if the certificate already exists. A
  9313. // new certificate context is always created. This may lead to
  9314. // duplicates in the store.
  9315. // CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES
  9316. // If the certificate already exists, then, its used.
  9317. // CERT_STORE_ADD_NEWER
  9318. // Fails if the certificate already exists in the store AND the NotBefore
  9319. // time of the existing certificate is equal to or greater than the
  9320. // NotBefore time of the new certificate being added. LastError
  9321. // is set to CRYPT_E_EXISTS.
  9322. //
  9323. // If an older certificate is replaced, same as
  9324. // CERT_STORE_ADD_REPLACE_EXISTING.
  9325. //
  9326. // For CRLs or CTLs compares the ThisUpdate times.
  9327. //
  9328. // CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES
  9329. // Same as CERT_STORE_ADD_NEWER. However, if an older certificate is
  9330. // replaced, same as CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES.
  9331. //
  9332. // CertGetSubjectCertificateFromStore is called to determine if the
  9333. // certificate already exists in the store.
  9334. //
  9335. // ppCertContext can be NULL, indicating the caller isn't interested
  9336. // in getting the CERT_CONTEXT of the added or existing certificate.
  9337. //--------------------------------------------------------------------------
  9338. function CertAddEncodedCertificateToStore(hCertStore: HCERTSTORE;
  9339. dwCertEncodingType: DWORD; pbCertEncoded: LPBYTE; cbCertEncoded: DWORD;
  9340. dwAddDisposition: DWORD; ppCertContext: PPCCERT_CONTEXT): BOOL; stdcall;
  9341. {$EXTERNALSYM CertAddEncodedCertificateToStore}
  9342. //+-------------------------------------------------------------------------
  9343. // Add the certificate context to the store according to the specified
  9344. // disposition action.
  9345. //
  9346. // In addition to the encoded certificate, the context's properties are
  9347. // also copied. Note, the CERT_KEY_CONTEXT_PROP_ID property (and its
  9348. // CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_SPEC_PROP_ID) isn't copied.
  9349. //
  9350. // Makes a copy of the certificate context before adding to the store.
  9351. //
  9352. // dwAddDispostion specifies the action to take if the certificate
  9353. // already exists in the store. This parameter must be one of the following
  9354. // values:
  9355. // CERT_STORE_ADD_NEW
  9356. // Fails if the certificate already exists in the store. LastError
  9357. // is set to CRYPT_E_EXISTS.
  9358. // CERT_STORE_ADD_USE_EXISTING
  9359. // If the certifcate already exists, then, its used and if ppStoreContext
  9360. // is non-NULL, the existing context is duplicated. Iterates
  9361. // through pCertContext's properties and only copies the properties
  9362. // that don't already exist. The SHA1 and MD5 hash properties aren't
  9363. // copied.
  9364. // CERT_STORE_ADD_REPLACE_EXISTING
  9365. // If the certificate already exists, then, the existing certificate
  9366. // context is deleted before creating and adding a new context.
  9367. // Properties are copied before doing the add.
  9368. // CERT_STORE_ADD_ALWAYS
  9369. // No check is made to see if the certificate already exists. A
  9370. // new certificate context is always created and added. This may lead to
  9371. // duplicates in the store. Properties are
  9372. // copied before doing the add.
  9373. // CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES
  9374. // If the certificate already exists, then, the existing certificate
  9375. // context is used. Properties from the added context are copied and
  9376. // replace existing properties. However, any existing properties not
  9377. // in the added context remain and aren't deleted.
  9378. // CERT_STORE_ADD_NEWER
  9379. // Fails if the certificate already exists in the store AND the NotBefore
  9380. // time of the existing context is equal to or greater than the
  9381. // NotBefore time of the new context being added. LastError
  9382. // is set to CRYPT_E_EXISTS.
  9383. //
  9384. // If an older context is replaced, same as
  9385. // CERT_STORE_ADD_REPLACE_EXISTING.
  9386. //
  9387. // For CRLs or CTLs compares the ThisUpdate times.
  9388. //
  9389. // CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES
  9390. // Same as CERT_STORE_ADD_NEWER. However, if an older context is
  9391. // replaced, same as CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES.
  9392. //
  9393. // CertGetSubjectCertificateFromStore is called to determine if the
  9394. // certificate already exists in the store.
  9395. //
  9396. // ppStoreContext can be NULL, indicating the caller isn't interested
  9397. // in getting the CERT_CONTEXT of the added or existing certificate.
  9398. //--------------------------------------------------------------------------
  9399. function CertAddCertificateContextToStore(hCertStore: HCERTSTORE;
  9400. pCertContext: PCCERT_CONTEXT; dwAddDisposition: DWORD;
  9401. ppStoreContext: PPCCERT_CONTEXT): BOOL; stdcall;
  9402. {$EXTERNALSYM CertAddCertificateContextToStore}
  9403. //+-------------------------------------------------------------------------
  9404. // Certificate Store Context Types
  9405. //--------------------------------------------------------------------------
  9406. const
  9407. CERT_STORE_CERTIFICATE_CONTEXT = 1;
  9408. {$EXTERNALSYM CERT_STORE_CERTIFICATE_CONTEXT}
  9409. CERT_STORE_CRL_CONTEXT = 2;
  9410. {$EXTERNALSYM CERT_STORE_CRL_CONTEXT}
  9411. CERT_STORE_CTL_CONTEXT = 3;
  9412. {$EXTERNALSYM CERT_STORE_CTL_CONTEXT}
  9413. //+-------------------------------------------------------------------------
  9414. // Certificate Store Context Bit Flags
  9415. //--------------------------------------------------------------------------
  9416. CERT_STORE_ALL_CONTEXT_FLAG = not 0;
  9417. {$EXTERNALSYM CERT_STORE_ALL_CONTEXT_FLAG}
  9418. CERT_STORE_CERTIFICATE_CONTEXT_FLAG = 1 shl CERT_STORE_CERTIFICATE_CONTEXT;
  9419. {$EXTERNALSYM CERT_STORE_CERTIFICATE_CONTEXT_FLAG}
  9420. CERT_STORE_CRL_CONTEXT_FLAG = 1 shl CERT_STORE_CRL_CONTEXT;
  9421. {$EXTERNALSYM CERT_STORE_CRL_CONTEXT_FLAG}
  9422. CERT_STORE_CTL_CONTEXT_FLAG = 1 shl CERT_STORE_CTL_CONTEXT;
  9423. {$EXTERNALSYM CERT_STORE_CTL_CONTEXT_FLAG}
  9424. //+-------------------------------------------------------------------------
  9425. // Add the serialized certificate or CRL element to the store.
  9426. //
  9427. // The serialized element contains the encoded certificate, CRL or CTL and
  9428. // its properties, such as, CERT_KEY_PROV_INFO_PROP_ID.
  9429. //
  9430. // If hCertStore is NULL, creates a certificate, CRL or CTL context not
  9431. // residing in any store.
  9432. //
  9433. // dwAddDispostion specifies the action to take if the certificate or CRL
  9434. // already exists in the store. See CertAddCertificateContextToStore for a
  9435. // list of and actions taken.
  9436. //
  9437. // dwFlags currently isn't used and should be set to 0.
  9438. //
  9439. // dwContextTypeFlags specifies the set of allowable contexts. For example, to
  9440. // add either a certificate or CRL, set dwContextTypeFlags to:
  9441. // CERT_STORE_CERTIFICATE_CONTEXT_FLAG | CERT_STORE_CRL_CONTEXT_FLAG
  9442. //
  9443. // *pdwContextType is updated with the type of the context returned in
  9444. // *ppvContxt. pdwContextType or ppvContext can be NULL, indicating the
  9445. // caller isn't interested in getting the output. If *ppvContext is
  9446. // returned it must be freed by calling CertFreeCertificateContext or
  9447. // CertFreeCRLContext.
  9448. //--------------------------------------------------------------------------
  9449. function CertAddSerializedElementToStore(hCertStore: HCERTSTORE; pbElement: LPBYTE;
  9450. cbElement, dwAddDisposition, dwFlags, dwContextTypeFlags: DWORD;
  9451. pdwContextType: LPDWORD; ppvContext: PPointer): BOOL; stdcall;
  9452. {$EXTERNALSYM CertAddSerializedElementToStore}
  9453. //+-------------------------------------------------------------------------
  9454. // Delete the specified certificate from the store.
  9455. //
  9456. // All subsequent gets or finds for the certificate will fail. However,
  9457. // memory allocated for the certificate isn't freed until all of its contexts
  9458. // have also been freed.
  9459. //
  9460. // The pCertContext is obtained from a get, enum, find or duplicate.
  9461. //
  9462. // Some store provider implementations might also delete the issuer's CRLs
  9463. // if this is the last certificate for the issuer in the store.
  9464. //
  9465. // NOTE: the pCertContext is always CertFreeCertificateContext'ed by
  9466. // this function, even for an error.
  9467. //--------------------------------------------------------------------------
  9468. function CertDeleteCertificateFromStore(pCertContext: PCCERT_CONTEXT): BOOL; stdcall;
  9469. {$EXTERNALSYM CertDeleteCertificateFromStore}
  9470. //+-------------------------------------------------------------------------
  9471. // Add the encoded CRL to the store according to the specified
  9472. // disposition option.
  9473. //
  9474. // Makes a copy of the encoded CRL before adding to the store.
  9475. //
  9476. // dwAddDispostion specifies the action to take if the CRL
  9477. // already exists in the store. See CertAddEncodedCertificateToStore for a
  9478. // list of and actions taken.
  9479. //
  9480. // Compares the CRL's Issuer to determine if the CRL already exists in the
  9481. // store.
  9482. //
  9483. // ppCrlContext can be NULL, indicating the caller isn't interested
  9484. // in getting the CRL_CONTEXT of the added or existing CRL.
  9485. //--------------------------------------------------------------------------
  9486. function CertAddEncodedCRLToStore(hCertStore: HCERTSTORE; dwCertEncodingType: DWORD;
  9487. pbCrlEncoded: LPBYTE; cbCrlEncoded, dwAddDisposition: DWORD;
  9488. ppCrlContext: PPCCRL_CONTEXT): BOOL; stdcall;
  9489. {$EXTERNALSYM CertAddEncodedCRLToStore}
  9490. //+-------------------------------------------------------------------------
  9491. // Add the CRL context to the store according to the specified
  9492. // disposition option.
  9493. //
  9494. // In addition to the encoded CRL, the context's properties are
  9495. // also copied. Note, the CERT_KEY_CONTEXT_PROP_ID property (and its
  9496. // CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_SPEC_PROP_ID) isn't copied.
  9497. //
  9498. // Makes a copy of the encoded CRL before adding to the store.
  9499. //
  9500. // dwAddDispostion specifies the action to take if the CRL
  9501. // already exists in the store. See CertAddCertificateContextToStore for a
  9502. // list of and actions taken.
  9503. //
  9504. // Compares the CRL's Issuer, ThisUpdate and NextUpdate to determine
  9505. // if the CRL already exists in the store.
  9506. //
  9507. // ppStoreContext can be NULL, indicating the caller isn't interested
  9508. // in getting the CRL_CONTEXT of the added or existing CRL.
  9509. //--------------------------------------------------------------------------
  9510. function CertAddCRLContextToStore(hCertStore: HCERTSTORE; pCrlContext: PCCRL_CONTEXT;
  9511. dwAddDisposition: DWORD; ppStoreContext: PPCCRL_CONTEXT): BOOL; stdcall;
  9512. {$EXTERNALSYM CertAddCRLContextToStore}
  9513. //+-------------------------------------------------------------------------
  9514. // Delete the specified CRL from the store.
  9515. //
  9516. // All subsequent gets for the CRL will fail. However,
  9517. // memory allocated for the CRL isn't freed until all of its contexts
  9518. // have also been freed.
  9519. //
  9520. // The pCrlContext is obtained from a get or duplicate.
  9521. //
  9522. // NOTE: the pCrlContext is always CertFreeCRLContext'ed by
  9523. // this function, even for an error.
  9524. //--------------------------------------------------------------------------
  9525. function CertDeleteCRLFromStore(pCrlContext: PCCRL_CONTEXT): BOOL; stdcall;
  9526. {$EXTERNALSYM CertDeleteCRLFromStore}
  9527. //+-------------------------------------------------------------------------
  9528. // Serialize the certificate context's encoded certificate and its
  9529. // properties.
  9530. //--------------------------------------------------------------------------
  9531. function CertSerializeCertificateStoreElement(pCertContext: PCCERT_CONTEXT;
  9532. dwFlags: DWORD; pbElement: LPBYTE; var pcbElement: DWORD): BOOL; stdcall;
  9533. {$EXTERNALSYM CertSerializeCertificateStoreElement}
  9534. //+-------------------------------------------------------------------------
  9535. // Serialize the CRL context's encoded CRL and its properties.
  9536. //--------------------------------------------------------------------------
  9537. function CertSerializeCRLStoreElement(pCrlContext: PCCRL_CONTEXT; dwFlags: DWORD;
  9538. pbElement: LPBYTE; var pcbElement: DWORD): BOOL; stdcall;
  9539. {$EXTERNALSYM CertSerializeCRLStoreElement}
  9540. //+=========================================================================
  9541. // Certificate Trust List (CTL) Store Data Structures and APIs
  9542. //==========================================================================
  9543. //+-------------------------------------------------------------------------
  9544. // Duplicate a CTL context
  9545. //--------------------------------------------------------------------------
  9546. function CertDuplicateCTLContext(pCtlContext: PCCTL_CONTEXT): PCCTL_CONTEXT; stdcall;
  9547. {$EXTERNALSYM CertDuplicateCTLContext}
  9548. //+-------------------------------------------------------------------------
  9549. // Create a CTL context from the encoded CTL. The created
  9550. // context isn't put in a store.
  9551. //
  9552. // Makes a copy of the encoded CTL in the created context.
  9553. //
  9554. // If unable to decode and create the CTL context, NULL is returned.
  9555. // Otherwise, a pointer to a read only CTL_CONTEXT is returned.
  9556. // CTL_CONTEXT must be freed by calling CertFreeCTLContext.
  9557. // CertDuplicateCTLContext can be called to make a duplicate.
  9558. //
  9559. // CertSetCTLContextProperty and CertGetCTLContextProperty can be called
  9560. // to store properties for the CTL.
  9561. //--------------------------------------------------------------------------
  9562. function CertCreateCTLContext(dwMsgAndCertEncodingType: DWORD;
  9563. pbCtlEncoded: LPBYTE; cbCtlEncoded: DWORD): PCCTL_CONTEXT; stdcall;
  9564. {$EXTERNALSYM CertCreateCTLContext}
  9565. //+-------------------------------------------------------------------------
  9566. // Free a CTL context
  9567. //
  9568. // There needs to be a corresponding free for each context obtained by a
  9569. // get, duplicate or create.
  9570. //--------------------------------------------------------------------------
  9571. function CertFreeCTLContext(pCtlContext: PCCTL_CONTEXT): BOOL; stdcall;
  9572. {$EXTERNALSYM CertFreeCTLContext}
  9573. //+-------------------------------------------------------------------------
  9574. // Set the property for the specified CTL context.
  9575. //
  9576. // Same Property Ids and semantics as CertSetCertificateContextProperty.
  9577. //--------------------------------------------------------------------------
  9578. function CertSetCTLContextProperty(pCtlContext: PCCTL_CONTEXT; dwPropId: DWORD;
  9579. dwFlags: DWORD; pvData: Pointer): BOOL; stdcall;
  9580. {$EXTERNALSYM CertSetCTLContextProperty}
  9581. //+-------------------------------------------------------------------------
  9582. // Get the property for the specified CTL context.
  9583. //
  9584. // Same Property Ids and semantics as CertGetCertificateContextProperty.
  9585. //
  9586. // CERT_SHA1_HASH_PROP_ID or CERT_NEXT_UPDATE_LOCATION_PROP_ID are the
  9587. // predefined properties of most interest.
  9588. //--------------------------------------------------------------------------
  9589. function CertGetCTLContextProperty(pCtlContext: PCCTL_CONTEXT; dwPropId: DWORD;
  9590. pvData: Pointer; var pcbData: DWORD): BOOL; stdcall;
  9591. {$EXTERNALSYM CertGetCTLContextProperty}
  9592. //+-------------------------------------------------------------------------
  9593. // Enumerate the properties for the specified CTL context.
  9594. //--------------------------------------------------------------------------
  9595. function CertEnumCTLContextProperties(pCtlContext: PCCTL_CONTEXT; dwPropId: DWORD): DWORD; stdcall;
  9596. {$EXTERNALSYM CertEnumCTLContextProperties}
  9597. //+-------------------------------------------------------------------------
  9598. // Enumerate the CTL contexts in the store.
  9599. //
  9600. // If a CTL isn't found, NULL is returned.
  9601. // Otherwise, a pointer to a read only CTL_CONTEXT is returned. CTL_CONTEXT
  9602. // must be freed by calling CertFreeCTLContext or is freed when passed as the
  9603. // pPrevCtlContext on a subsequent call. CertDuplicateCTLContext
  9604. // can be called to make a duplicate.
  9605. //
  9606. // pPrevCtlContext MUST BE NULL to enumerate the first
  9607. // CTL in the store. Successive CTLs are enumerated by setting
  9608. // pPrevCtlContext to the CTL_CONTEXT returned by a previous call.
  9609. //
  9610. // NOTE: a NON-NULL pPrevCtlContext is always CertFreeCTLContext'ed by
  9611. // this function, even for an error.
  9612. //--------------------------------------------------------------------------
  9613. function CertEnumCTLsInStore(hCertStore: HCERTSTORE; pPrevCtlContext: PCCTL_CONTEXT): PCCTL_CONTEXT; stdcall;
  9614. {$EXTERNALSYM CertEnumCTLsInStore}
  9615. //+-------------------------------------------------------------------------
  9616. // Attempt to find the specified subject in the CTL.
  9617. //
  9618. // For CTL_CERT_SUBJECT_TYPE, pvSubject points to a CERT_CONTEXT. The CTL's
  9619. // SubjectAlgorithm is examined to determine the representation of the
  9620. // subject's identity. Initially, only SHA1 or MD5 hash will be supported.
  9621. // The appropriate hash property is obtained from the CERT_CONTEXT.
  9622. //
  9623. // For CTL_ANY_SUBJECT_TYPE, pvSubject points to the CTL_ANY_SUBJECT_INFO
  9624. // structure which contains the SubjectAlgorithm to be matched in the CTL
  9625. // and the SubjectIdentifer to be matched in one of the CTL entries.
  9626. //
  9627. // The certificate's hash or the CTL_ANY_SUBJECT_INFO's SubjectIdentifier
  9628. // is used as the key in searching the subject entries. A binary
  9629. // memory comparison is done between the key and the entry's SubjectIdentifer.
  9630. //
  9631. // dwEncodingType isn't used for either of the above SubjectTypes.
  9632. //--------------------------------------------------------------------------
  9633. function CertFindSubjectInCTL(dwEncodingType: DWORD; dwSubjectType: DWORD;
  9634. pvSubject: Pointer; pCtlContext: PCCTL_CONTEXT; dwFlags: DWORD): PCTL_ENTRY; stdcall;
  9635. {$EXTERNALSYM CertFindSubjectInCTL}
  9636. // Subject Types:
  9637. // CTL_ANY_SUBJECT_TYPE, pvSubject points to following CTL_ANY_SUBJECT_INFO.
  9638. // CTL_CERT_SUBJECT_TYPE, pvSubject points to CERT_CONTEXT.
  9639. const
  9640. CTL_ANY_SUBJECT_TYPE = 1;
  9641. {$EXTERNALSYM CTL_ANY_SUBJECT_TYPE}
  9642. CTL_CERT_SUBJECT_TYPE = 2;
  9643. {$EXTERNALSYM CTL_CERT_SUBJECT_TYPE}
  9644. type
  9645. PCTL_ANY_SUBJECT_INFO = ^CTL_ANY_SUBJECT_INFO;
  9646. {$EXTERNALSYM PCTL_ANY_SUBJECT_INFO}
  9647. _CTL_ANY_SUBJECT_INFO = record
  9648. SubjectAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  9649. SubjectIdentifier: CRYPT_DATA_BLOB;
  9650. end;
  9651. {$EXTERNALSYM _CTL_ANY_SUBJECT_INFO}
  9652. CTL_ANY_SUBJECT_INFO = _CTL_ANY_SUBJECT_INFO;
  9653. {$EXTERNALSYM CTL_ANY_SUBJECT_INFO}
  9654. TCtlAnySubjectInfo = CTL_ANY_SUBJECT_INFO;
  9655. PCtlAnySubjectInfo = PCTL_ANY_SUBJECT_INFO;
  9656. //+-------------------------------------------------------------------------
  9657. // Find the first or next CTL context in the store.
  9658. //
  9659. // The CTL is found according to the dwFindType and its pvFindPara.
  9660. // See below for a list of the find types and its parameters.
  9661. //
  9662. // Currently dwFindFlags isn't used and must be set to 0.
  9663. //
  9664. // Usage of dwMsgAndCertEncodingType depends on the dwFindType.
  9665. //
  9666. // If the first or next CTL isn't found, NULL is returned.
  9667. // Otherwise, a pointer to a read only CTL_CONTEXT is returned. CTL_CONTEXT
  9668. // must be freed by calling CertFreeCTLContext or is freed when passed as the
  9669. // pPrevCtlContext on a subsequent call. CertDuplicateCTLContext
  9670. // can be called to make a duplicate.
  9671. //
  9672. // pPrevCtlContext MUST BE NULL on the first
  9673. // call to find the CTL. To find the next CTL, the
  9674. // pPrevCtlContext is set to the CTL_CONTEXT returned by a previous call.
  9675. //
  9676. // NOTE: a NON-NULL pPrevCtlContext is always CertFreeCTLContext'ed by
  9677. // this function, even for an error.
  9678. //--------------------------------------------------------------------------
  9679. function CertFindCTLInStore(hCertStore: HCERTSTORE; dwMsgAndCertEncodingType,
  9680. dwFindFlags, dwFindType: DWORD; pvFindPara: Pointer;
  9681. pPrevCtlContext: PCCTL_CONTEXT): PCCTL_CONTEXT; stdcall;
  9682. {$EXTERNALSYM CertFindCTLInStore}
  9683. const
  9684. CTL_FIND_ANY = 0;
  9685. {$EXTERNALSYM CTL_FIND_ANY}
  9686. CTL_FIND_SHA1_HASH = 1;
  9687. {$EXTERNALSYM CTL_FIND_SHA1_HASH}
  9688. CTL_FIND_MD5_HASH = 2;
  9689. {$EXTERNALSYM CTL_FIND_MD5_HASH}
  9690. CTL_FIND_USAGE = 3;
  9691. {$EXTERNALSYM CTL_FIND_USAGE}
  9692. CTL_FIND_SUBJECT = 4;
  9693. {$EXTERNALSYM CTL_FIND_SUBJECT}
  9694. CTL_FIND_EXISTING = 5;
  9695. {$EXTERNALSYM CTL_FIND_EXISTING}
  9696. type
  9697. PCTL_FIND_USAGE_PARA = ^CTL_FIND_USAGE_PARA;
  9698. {$EXTERNALSYM PCTL_FIND_USAGE_PARA}
  9699. _CTL_FIND_USAGE_PARA = record
  9700. cbSize: DWORD;
  9701. SubjectUsage: CTL_USAGE; // optional
  9702. ListIdentifier: CRYPT_DATA_BLOB; // optional
  9703. pSigner: PCERT_INFO; // optional
  9704. end;
  9705. {$EXTERNALSYM _CTL_FIND_USAGE_PARA}
  9706. CTL_FIND_USAGE_PARA = _CTL_FIND_USAGE_PARA;
  9707. {$EXTERNALSYM CTL_FIND_USAGE_PARA}
  9708. TCtlFindUsagePara = CTL_FIND_USAGE_PARA;
  9709. PCtlFindUsagePara = PCTL_FIND_USAGE_PARA;
  9710. const
  9711. CTL_FIND_NO_LIST_ID_CBDATA = DWORD($FFFFFFFF);
  9712. {$EXTERNALSYM CTL_FIND_NO_LIST_ID_CBDATA}
  9713. CTL_FIND_NO_SIGNER_PTR = PCERT_INFO(-1);
  9714. {$EXTERNALSYM CTL_FIND_NO_SIGNER_PTR}
  9715. CTL_FIND_SAME_USAGE_FLAG = $1;
  9716. {$EXTERNALSYM CTL_FIND_SAME_USAGE_FLAG}
  9717. type
  9718. PCTL_FIND_SUBJECT_PARA = ^CTL_FIND_SUBJECT_PARA;
  9719. {$EXTERNALSYM PCTL_FIND_SUBJECT_PARA}
  9720. _CTL_FIND_SUBJECT_PARA = record
  9721. cbSize: DWORD;
  9722. pUsagePara: PCTL_FIND_USAGE_PARA; // optional
  9723. dwSubjectType: DWORD;
  9724. pvSubject: Pointer;
  9725. end;
  9726. {$EXTERNALSYM _CTL_FIND_SUBJECT_PARA}
  9727. CTL_FIND_SUBJECT_PARA = _CTL_FIND_SUBJECT_PARA;
  9728. {$EXTERNALSYM CTL_FIND_SUBJECT_PARA}
  9729. TCtlFindSubjectPara = CTL_FIND_SUBJECT_PARA;
  9730. PCtlFindSubjectPara = PCTL_FIND_SUBJECT_PARA;
  9731. //+-------------------------------------------------------------------------
  9732. // CTL_FIND_ANY
  9733. //
  9734. // Find any CTL.
  9735. //
  9736. // pvFindPara isn't used.
  9737. //--------------------------------------------------------------------------
  9738. //+-------------------------------------------------------------------------
  9739. // CTL_FIND_SHA1_HASH
  9740. // CTL_FIND_MD5_HASH
  9741. //
  9742. // Find a CTL with the specified hash.
  9743. //
  9744. // pvFindPara points to a CRYPT_HASH_BLOB.
  9745. //--------------------------------------------------------------------------
  9746. //+-------------------------------------------------------------------------
  9747. // CTL_FIND_USAGE
  9748. //
  9749. // Find a CTL having the specified usage identifiers, list identifier or
  9750. // signer. The CertEncodingType of the signer is obtained from the
  9751. // dwMsgAndCertEncodingType parameter.
  9752. //
  9753. // pvFindPara points to a CTL_FIND_USAGE_PARA data structure. The
  9754. // SubjectUsage.cUsageIdentifer can be 0 to match any usage. The
  9755. // ListIdentifier.cbData can be 0 to match any list identifier. To only match
  9756. // CTLs without a ListIdentifier, cbData must be set to
  9757. // CTL_FIND_NO_LIST_ID_CBDATA. pSigner can be NULL to match any signer. Only
  9758. // the Issuer and SerialNumber fields of the pSigner's PCERT_INFO are used.
  9759. // To only match CTLs without a signer, pSigner must be set to
  9760. // CTL_FIND_NO_SIGNER_PTR.
  9761. //
  9762. // The CTL_FIND_SAME_USAGE_FLAG can be set in dwFindFlags to
  9763. // only match CTLs with the same usage identifiers. CTLs having additional
  9764. // usage identifiers aren't matched. For example, if only "1.2.3" is specified
  9765. // in CTL_FIND_USAGE_PARA, then, for a match, the CTL must only contain
  9766. // "1.2.3" and not any additional usage identifers.
  9767. //--------------------------------------------------------------------------
  9768. //+-------------------------------------------------------------------------
  9769. // CTL_FIND_SUBJECT
  9770. //
  9771. // Find a CTL having the specified subject. CertFindSubjectInCTL can be
  9772. // called to get a pointer to the subject's entry in the CTL. pUsagePara can
  9773. // optionally be set to enable the above CTL_FIND_USAGE matching.
  9774. //
  9775. // pvFindPara points to a CTL_FIND_SUBJECT_PARA data structure.
  9776. //--------------------------------------------------------------------------
  9777. //+-------------------------------------------------------------------------
  9778. // Add the encoded CTL to the store according to the specified
  9779. // disposition option.
  9780. //
  9781. // Makes a copy of the encoded CTL before adding to the store.
  9782. //
  9783. // dwAddDispostion specifies the action to take if the CTL
  9784. // already exists in the store. See CertAddEncodedCertificateToStore for a
  9785. // list of and actions taken.
  9786. //
  9787. // Compares the CTL's SubjectUsage, ListIdentifier and any of its signers
  9788. // to determine if the CTL already exists in the store.
  9789. //
  9790. // ppCtlContext can be NULL, indicating the caller isn't interested
  9791. // in getting the CTL_CONTEXT of the added or existing CTL.
  9792. //--------------------------------------------------------------------------
  9793. function CertAddEncodedCTLToStore(hCertStore: HCERTSTORE;
  9794. dwMsgAndCertEncodingType: DWORD; pbCtlEncoded: LPBYTE; cbCtlEncoded: DWORD;
  9795. dwAddDisposition: DWORD; ppCtlContext: PPCCTL_CONTEXT): BOOL; stdcall;
  9796. {$EXTERNALSYM CertAddEncodedCTLToStore}
  9797. //+-------------------------------------------------------------------------
  9798. // Add the CTL context to the store according to the specified
  9799. // disposition option.
  9800. //
  9801. // In addition to the encoded CTL, the context's properties are
  9802. // also copied. Note, the CERT_KEY_CONTEXT_PROP_ID property (and its
  9803. // CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_SPEC_PROP_ID) isn't copied.
  9804. //
  9805. // Makes a copy of the encoded CTL before adding to the store.
  9806. //
  9807. // dwAddDispostion specifies the action to take if the CTL
  9808. // already exists in the store. See CertAddCertificateContextToStore for a
  9809. // list of and actions taken.
  9810. //
  9811. // Compares the CTL's SubjectUsage, ListIdentifier and any of its signers
  9812. // to determine if the CTL already exists in the store.
  9813. //
  9814. // ppStoreContext can be NULL, indicating the caller isn't interested
  9815. // in getting the CTL_CONTEXT of the added or existing CTL.
  9816. //--------------------------------------------------------------------------
  9817. function CertAddCTLContextToStore(hCertStore: HCERTSTORE; pCtlContext: PCCTL_CONTEXT;
  9818. dwAddDisposition: DWORD; ppStoreContext: PPCCTL_CONTEXT): BOOL; stdcall;
  9819. {$EXTERNALSYM CertAddCTLContextToStore}
  9820. //+-------------------------------------------------------------------------
  9821. // Serialize the CTL context's encoded CTL and its properties.
  9822. //--------------------------------------------------------------------------
  9823. function CertSerializeCTLStoreElement(pCtlContext: PCCTL_CONTEXT; dwFlags: DWORD;
  9824. pbElement: LPBYTE; var pcbElement: DWORD): BOOL; stdcall;
  9825. {$EXTERNALSYM CertSerializeCTLStoreElement}
  9826. //+-------------------------------------------------------------------------
  9827. // Delete the specified CTL from the store.
  9828. //
  9829. // All subsequent gets for the CTL will fail. However,
  9830. // memory allocated for the CTL isn't freed until all of its contexts
  9831. // have also been freed.
  9832. //
  9833. // The pCtlContext is obtained from a get or duplicate.
  9834. //
  9835. // NOTE: the pCtlContext is always CertFreeCTLContext'ed by
  9836. // this function, even for an error.
  9837. //--------------------------------------------------------------------------
  9838. function CertDeleteCTLFromStore(pCtlContext: PCCTL_CONTEXT): BOOL; stdcall;
  9839. {$EXTERNALSYM CertDeleteCTLFromStore}
  9840. function CertAddCertificateLinkToStore(hCertStore: HCERTSTORE;
  9841. pCertContext: PCCERT_CONTEXT; dwAddDisposition: DWORD;
  9842. ppStoreContext: PPCCERT_CONTEXT): BOOL; stdcall;
  9843. {$EXTERNALSYM CertAddCertificateLinkToStore}
  9844. function CertAddCRLLinkToStore(hCertStore: HCERTSTORE; pCrlContext: PCCRL_CONTEXT;
  9845. dwAddDisposition: DWORD; ppStoreContext: PPCCRL_CONTEXT): BOOL; stdcall;
  9846. {$EXTERNALSYM CertAddCRLLinkToStore}
  9847. function CertAddCTLLinkToStore(hCertStore: HCERTSTORE; pCtlContext: PCCTL_CONTEXT;
  9848. dwAddDisposition: DWORD; ppStoreContext: PPCCTL_CONTEXT): BOOL; stdcall;
  9849. {$EXTERNALSYM CertAddCTLLinkToStore}
  9850. function CertAddStoreToCollection(hCollectionStore: HCERTSTORE;
  9851. hSiblingStore: HCERTSTORE; dwUpdateFlags, dwPriority: DWORD): BOOL; stdcall;
  9852. {$EXTERNALSYM CertAddStoreToCollection}
  9853. procedure CertRemoveStoreFromCollection(hCollectionStore, hSiblingStore: HCERTSTORE); stdcall;
  9854. {$EXTERNALSYM CertRemoveStoreFromCollection}
  9855. function CertControlStore(hCertStore: HCERTSTORE; dwFlags, dwCtrlType: DWORD;
  9856. pvCtrlPara: Pointer): BOOL; stdcall;
  9857. {$EXTERNALSYM CertControlStore}
  9858. //+-------------------------------------------------------------------------
  9859. // Certificate Store control types
  9860. //--------------------------------------------------------------------------
  9861. const
  9862. CERT_STORE_CTRL_RESYNC = 1;
  9863. {$EXTERNALSYM CERT_STORE_CTRL_RESYNC}
  9864. CERT_STORE_CTRL_NOTIFY_CHANGE = 2;
  9865. {$EXTERNALSYM CERT_STORE_CTRL_NOTIFY_CHANGE}
  9866. CERT_STORE_CTRL_COMMIT = 3;
  9867. {$EXTERNALSYM CERT_STORE_CTRL_COMMIT}
  9868. CERT_STORE_CTRL_AUTO_RESYNC = 4;
  9869. {$EXTERNALSYM CERT_STORE_CTRL_AUTO_RESYNC}
  9870. //+-------------------------------------------------------------------------
  9871. // CERT_STORE_CTRL_RESYNC
  9872. //
  9873. // Re-synchronize the store.
  9874. //
  9875. // The pvCtrlPara points to the event HANDLE to be signaled on
  9876. // the next store change. Normally, this would be the same
  9877. // event HANDLE passed to CERT_STORE_CTRL_NOTIFY_CHANGE during initialization.
  9878. //
  9879. // If pvCtrlPara is NULL, no events are re-armed.
  9880. //--------------------------------------------------------------------------
  9881. //+-------------------------------------------------------------------------
  9882. // CERT_STORE_CTRL_NOTIFY_CHANGE
  9883. //
  9884. // Signal the event when the underlying store is changed.
  9885. //
  9886. // pvCtrlPara points to the event HANDLE to be signaled.
  9887. //
  9888. // pvCtrlPara can be NULL to inform the store of a subsequent
  9889. // CERT_STORE_CTRL_RESYNC and allow it to optimize by only doing a resync
  9890. // if the store has changed. For the registry based stores, an internal
  9891. // notify change event is created and registered to be signaled.
  9892. //
  9893. // Recommend calling CERT_STORE_CTRL_NOTIFY_CHANGE once for each event to
  9894. // be passed to CERT_STORE_CTRL_RESYNC. This should only happen after
  9895. // the event has been created. Not after each time the event is signaled.
  9896. //--------------------------------------------------------------------------
  9897. //+-------------------------------------------------------------------------
  9898. // CERT_STORE_CTRL_AUTO_RESYNC
  9899. //
  9900. // At the start of every enumeration or find store API call, check if the
  9901. // underlying store has changed. If it has changed, re-synchronize.
  9902. //
  9903. // This check is only done in the enumeration or find APIs when the
  9904. // pPrevContext is NULL.
  9905. //
  9906. // The pvCtrlPara isn't used and must be set to NULL.
  9907. //--------------------------------------------------------------------------
  9908. //+-------------------------------------------------------------------------
  9909. // CERT_STORE_CTRL_COMMIT
  9910. //
  9911. // If any changes have been to the cached store, they are committed to
  9912. // persisted storage. If no changes have been made since the store was
  9913. // opened or the last commit, this call is ignored. May also be ignored by
  9914. // store providers that persist changes immediately.
  9915. //
  9916. // CERT_STORE_CTRL_COMMIT_FORCE_FLAG can be set to force the store
  9917. // to be committed even if it hasn't been touched.
  9918. //
  9919. // CERT_STORE_CTRL_COMMIT_CLEAR_FLAG can be set to inhibit a commit on
  9920. // store close.
  9921. //--------------------------------------------------------------------------
  9922. const
  9923. CERT_STORE_CTRL_COMMIT_FORCE_FLAG = $1;
  9924. {$EXTERNALSYM CERT_STORE_CTRL_COMMIT_FORCE_FLAG}
  9925. CERT_STORE_CTRL_COMMIT_CLEAR_FLAG = $2;
  9926. {$EXTERNALSYM CERT_STORE_CTRL_COMMIT_CLEAR_FLAG}
  9927. //+=========================================================================
  9928. // Cert Store Property Defines and APIs
  9929. //==========================================================================
  9930. //+-------------------------------------------------------------------------
  9931. // Store property IDs. This is a property applicable to the entire store.
  9932. // Its not a property on an individual certificate, CRL or CTL context.
  9933. //
  9934. // Currently, no store properties are persisted. (This differs from
  9935. // most context properties which are persisted.)
  9936. //
  9937. // See CertSetStoreProperty or CertGetStoreProperty for usage information.
  9938. //
  9939. // Note, the range for predefined store properties should be outside
  9940. // the range of predefined context properties. We will start at 4096.
  9941. //--------------------------------------------------------------------------
  9942. CERT_STORE_LOCALIZED_NAME_PROP_ID = $1000;
  9943. {$EXTERNALSYM CERT_STORE_LOCALIZED_NAME_PROP_ID}
  9944. //+-------------------------------------------------------------------------
  9945. // Set a store property.
  9946. //
  9947. // The type definition for pvData depends on the dwPropId value.
  9948. // CERT_STORE_LOCALIZED_NAME_PROP_ID - localized name of the store.
  9949. // pvData points to a CRYPT_DATA_BLOB. pbData is a pointer to a NULL
  9950. // terminated unicode, wide character string.
  9951. // cbData = (wcslen((LPWSTR) pbData) + 1) * sizeof(WCHAR).
  9952. //
  9953. // For all the other PROP_IDs: an encoded PCRYPT_DATA_BLOB is passed in pvData.
  9954. //
  9955. // If the property already exists, then, the old value is deleted and silently
  9956. // replaced. Setting, pvData to NULL, deletes the property.
  9957. //--------------------------------------------------------------------------
  9958. function CertSetStoreProperty(hCertStore: HCERTSTORE; dwPropId, dwFlags: DWORD;
  9959. pvData: Pointer): BOOL; stdcall;
  9960. {$EXTERNALSYM CertSetStoreProperty}
  9961. //+-------------------------------------------------------------------------
  9962. // Get a store property.
  9963. //
  9964. // The type definition for pvData depends on the dwPropId value.
  9965. // CERT_STORE_LOCALIZED_NAME_PROP_ID - localized name of the store.
  9966. // pvData points to a NULL terminated unicode, wide character string.
  9967. // cbData = (wcslen((LPWSTR) pvData) + 1) * sizeof(WCHAR).
  9968. //
  9969. // For all other PROP_IDs, pvData points to an array of bytes.
  9970. //
  9971. // If the property doesn't exist, returns FALSE and sets LastError to
  9972. // CRYPT_E_NOT_FOUND.
  9973. //--------------------------------------------------------------------------
  9974. function CertGetStoreProperty(hCertStore: HCERTSTORE; dwPropId: DWORD;
  9975. pvData: Pointer; var pcbData: DWORD): BOOL; stdcall;
  9976. {$EXTERNALSYM CertGetStoreProperty}
  9977. type
  9978. PCERT_CREATE_CONTEXT_PARA = ^CERT_CREATE_CONTEXT_PARA;
  9979. {$EXTERNALSYM PCERT_CREATE_CONTEXT_PARA}
  9980. _CERT_CREATE_CONTEXT_PARA = record
  9981. cbSize: DWORD;
  9982. pfnFree: PFN_CRYPT_FREE; // OPTIONAL
  9983. pvFree: Pointer; // OPTIONAL
  9984. end;
  9985. {$EXTERNALSYM _CERT_CREATE_CONTEXT_PARA}
  9986. CERT_CREATE_CONTEXT_PARA = _CERT_CREATE_CONTEXT_PARA;
  9987. {$EXTERNALSYM CERT_CREATE_CONTEXT_PARA}
  9988. TCertCreateContextPara = CERT_CREATE_CONTEXT_PARA;
  9989. PCertCreateContextPara = PCERT_CREATE_CONTEXT_PARA;
  9990. //+-------------------------------------------------------------------------
  9991. // Creates the specified context from the encoded bytes. The created
  9992. // context isn't put in a store.
  9993. //
  9994. // dwContextType values:
  9995. // CERT_STORE_CERTIFICATE_CONTEXT
  9996. // CERT_STORE_CRL_CONTEXT
  9997. // CERT_STORE_CTL_CONTEXT
  9998. //
  9999. // If CERT_CREATE_CONTEXT_NOCOPY_FLAG is set, the created context points
  10000. // directly to the pbEncoded instead of an allocated copy. See flag
  10001. // definition for more details.
  10002. //
  10003. // If CERT_CREATE_CONTEXT_SORTED_FLAG is set, the context is created
  10004. // with sorted entries. This flag may only be set for CERT_STORE_CTL_CONTEXT.
  10005. // Setting this flag implicitly sets CERT_CREATE_CONTEXT_NO_HCRYPTMSG_FLAG and
  10006. // CERT_CREATE_CONTEXT_NO_ENTRY_FLAG. See flag definition for
  10007. // more details.
  10008. //
  10009. // If CERT_CREATE_CONTEXT_NO_HCRYPTMSG_FLAG is set, the context is created
  10010. // without creating a HCRYPTMSG handle for the context. This flag may only be
  10011. // set for CERT_STORE_CTL_CONTEXT. See flag definition for more details.
  10012. //
  10013. // If CERT_CREATE_CONTEXT_NO_ENTRY_FLAG is set, the context is created
  10014. // without decoding the entries. This flag may only be set for
  10015. // CERT_STORE_CTL_CONTEXT. See flag definition for more details.
  10016. //
  10017. // If unable to decode and create the context, NULL is returned.
  10018. // Otherwise, a pointer to a read only CERT_CONTEXT, CRL_CONTEXT or
  10019. // CTL_CONTEXT is returned. The context must be freed by the appropriate
  10020. // free context API. The context can be duplicated by calling the
  10021. // appropriate duplicate context API.
  10022. //--------------------------------------------------------------------------
  10023. function CertCreateContext(dwContextType, dwEncodingType: DWORD;
  10024. pbEncoded: LPBYTE; cbEncoded, dwFlags: DWORD;
  10025. pCreatePara: PCERT_CREATE_CONTEXT_PARA): Pointer; stdcall;
  10026. {$EXTERNALSYM CertCreateContext}
  10027. // When the following flag is set, the created context points directly to the
  10028. // pbEncoded instead of an allocated copy. If pCreatePara and
  10029. // pCreatePara->pfnFree are non-NULL, then, pfnFree is called to free
  10030. // the pbEncoded when the context is last freed. Otherwise, no attempt is
  10031. // made to free the pbEncoded. If pCreatePara->pvFree is non-NULL, then its
  10032. // passed to pfnFree instead of pbEncoded.
  10033. //
  10034. // Note, if CertCreateContext fails, pfnFree is still called.
  10035. const
  10036. CERT_CREATE_CONTEXT_NOCOPY_FLAG = $1;
  10037. {$EXTERNALSYM CERT_CREATE_CONTEXT_NOCOPY_FLAG}
  10038. // When the following flag is set, a context with sorted entries is created.
  10039. // Currently only applicable to a CTL context.
  10040. //
  10041. // For CTLs: the cCTLEntry in the returned CTL_INFO is always
  10042. // 0. CertFindSubjectInSortedCTL and CertEnumSubjectInSortedCTL must be called
  10043. // to find or enumerate the CTL entries.
  10044. //
  10045. // The Sorted CTL TrustedSubjects extension isn't returned in the created
  10046. // context's CTL_INFO.
  10047. CERT_CREATE_CONTEXT_SORTED_FLAG = $2;
  10048. {$EXTERNALSYM CERT_CREATE_CONTEXT_SORTED_FLAG}
  10049. // By default when a CTL context is created, a HCRYPTMSG handle to its
  10050. // SignedData message is created. This flag can be set to improve performance
  10051. // by not creating the HCRYPTMSG handle.
  10052. //
  10053. // This flag is only applicable to a CTL context.
  10054. CERT_CREATE_CONTEXT_NO_HCRYPTMSG_FLAG = $4;
  10055. {$EXTERNALSYM CERT_CREATE_CONTEXT_NO_HCRYPTMSG_FLAG}
  10056. // By default when a CTL context is created, its entries are decoded.
  10057. // This flag can be set to improve performance by not decoding the
  10058. // entries.
  10059. //
  10060. // This flag is only applicable to a CTL context.
  10061. CERT_CREATE_CONTEXT_NO_ENTRY_FLAG = $8;
  10062. {$EXTERNALSYM CERT_CREATE_CONTEXT_NO_ENTRY_FLAG}
  10063. //+=========================================================================
  10064. // Certificate System Store Data Structures and APIs
  10065. //==========================================================================
  10066. //+-------------------------------------------------------------------------
  10067. // System Store Information
  10068. //
  10069. // Currently, no system store information is persisted.
  10070. //--------------------------------------------------------------------------
  10071. type
  10072. PCERT_SYSTEM_STORE_INFO = ^CERT_SYSTEM_STORE_INFO;
  10073. {$EXTERNALSYM PCERT_SYSTEM_STORE_INFO}
  10074. _CERT_SYSTEM_STORE_INFO = record
  10075. cbSize: DWORD;
  10076. end;
  10077. {$EXTERNALSYM _CERT_SYSTEM_STORE_INFO}
  10078. CERT_SYSTEM_STORE_INFO = _CERT_SYSTEM_STORE_INFO;
  10079. {$EXTERNALSYM CERT_SYSTEM_STORE_INFO}
  10080. TCertSystemStoreInfo = CERT_SYSTEM_STORE_INFO;
  10081. PCertSystemStoreInfo = PCERT_SYSTEM_STORE_INFO;
  10082. //+-------------------------------------------------------------------------
  10083. // Physical Store Information
  10084. //
  10085. // The Open fields are passed directly to CertOpenStore() to open
  10086. // the physical store.
  10087. //
  10088. // By default all system stores located in the registry have an
  10089. // implicit SystemRegistry physical store that is opened. To disable the
  10090. // opening of this store, the SystemRegistry
  10091. // physical store corresponding to the System store must be registered with
  10092. // CERT_PHYSICAL_STORE_OPEN_DISABLE_FLAG set in dwFlags. Alternatively,
  10093. // a physical store with the name of ".Default" may be registered.
  10094. //
  10095. // Depending on the store location and store name, additional predefined
  10096. // physical stores may be opened. For example, system stores in
  10097. // CURRENT_USER have the predefined physical store, .LocalMachine.
  10098. // To disable the opening of these predefined physical stores, the
  10099. // corresponding physical store must be registered with
  10100. // CERT_PHYSICAL_STORE_OPEN_DISABLE_FLAG set in dwFlags.
  10101. //
  10102. // The CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG must be set in dwFlags
  10103. // to enable the adding of a context to the store.
  10104. //
  10105. // When a system store is opened via the SERVICES or USERS store location,
  10106. // the ServiceName\ is prepended to the OpenParameters
  10107. // for CERT_SYSTEM_STORE_CURRENT_USER or CERT_SYSTEM_STORE_CURRENT_SERVICE
  10108. // physical stores and the dwOpenFlags store location is changed to
  10109. // CERT_SYSTEM_STORE_USERS or CERT_SYSTEM_STORE_SERVICES.
  10110. //
  10111. // By default the SYSTEM, SYSTEM_REGISTRY and PHYSICAL provider
  10112. // stores are also opened remotely when the outer system store is opened.
  10113. // The CERT_PHYSICAL_STORE_REMOTE_OPEN_DISABLE_FLAG may be set in dwFlags
  10114. // to disable remote opens.
  10115. //
  10116. // When opened remotely, the \\ComputerName is implicitly prepended to the
  10117. // OpenParameters for the SYSTEM, SYSTEM_REGISTRY and PHYSICAL provider types.
  10118. // To also prepend the \\ComputerName to other provider types, set the
  10119. // CERT_PHYSICAL_STORE_INSERT_COMPUTER_NAME_ENABLE_FLAG in dwFlags.
  10120. //
  10121. // When the system store is opened, its physical stores are ordered
  10122. // according to the dwPriority. A larger dwPriority indicates higher priority.
  10123. //--------------------------------------------------------------------------
  10124. type
  10125. PCERT_PHYSICAL_STORE_INFO = ^CERT_PHYSICAL_STORE_INFO;
  10126. {$EXTERNALSYM PCERT_PHYSICAL_STORE_INFO}
  10127. _CERT_PHYSICAL_STORE_INFO = record
  10128. cbSize: DWORD;
  10129. pszOpenStoreProvider: LPSTR; // REG_SZ
  10130. dwOpenEncodingType: DWORD; // REG_DWORD
  10131. dwOpenFlags: DWORD; // REG_DWORD
  10132. OpenParameters: CRYPT_DATA_BLOB; // REG_BINARY
  10133. dwFlags: DWORD; // REG_DWORD
  10134. dwPriority: DWORD; // REG_DWORD
  10135. end;
  10136. {$EXTERNALSYM _CERT_PHYSICAL_STORE_INFO}
  10137. CERT_PHYSICAL_STORE_INFO = _CERT_PHYSICAL_STORE_INFO;
  10138. {$EXTERNALSYM CERT_PHYSICAL_STORE_INFO}
  10139. TCertPhysicalStoreInfo = CERT_PHYSICAL_STORE_INFO;
  10140. PCertPhysicalStoreInfo = PCERT_PHYSICAL_STORE_INFO;
  10141. //+-------------------------------------------------------------------------
  10142. // Physical Store Information dwFlags
  10143. //--------------------------------------------------------------------------
  10144. const
  10145. CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG = $1;
  10146. {$EXTERNALSYM CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG}
  10147. CERT_PHYSICAL_STORE_OPEN_DISABLE_FLAG = $2;
  10148. {$EXTERNALSYM CERT_PHYSICAL_STORE_OPEN_DISABLE_FLAG}
  10149. CERT_PHYSICAL_STORE_REMOTE_OPEN_DISABLE_FLAG = $4;
  10150. {$EXTERNALSYM CERT_PHYSICAL_STORE_REMOTE_OPEN_DISABLE_FLAG}
  10151. CERT_PHYSICAL_STORE_INSERT_COMPUTER_NAME_ENABLE_FLAG = $8;
  10152. {$EXTERNALSYM CERT_PHYSICAL_STORE_INSERT_COMPUTER_NAME_ENABLE_FLAG}
  10153. //+-------------------------------------------------------------------------
  10154. // Register a system store.
  10155. //
  10156. // The upper word of the dwFlags parameter is used to specify the location of
  10157. // the system store.
  10158. //
  10159. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvSystemStore
  10160. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure. Otherwise,
  10161. // pvSystemStore points to a null terminated UNICODE string.
  10162. //
  10163. // The CERT_SYSTEM_STORE_SERVICES or CERT_SYSTEM_STORE_USERS system store
  10164. // name must be prefixed with the ServiceName or UserName. For example,
  10165. // "ServiceName\Trust".
  10166. //
  10167. // Stores on remote computers can be registered for the
  10168. // CERT_SYSTEM_STORE_LOCAL_MACHINE, CERT_SYSTEM_STORE_SERVICES,
  10169. // CERT_SYSTEM_STORE_USERS, CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
  10170. // or CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
  10171. // locations by prepending the computer name. For example, a remote
  10172. // local machine store is registered via "\\ComputerName\Trust" or
  10173. // "ComputerName\Trust". A remote service store is registered via
  10174. // "\\ComputerName\ServiceName\Trust". The leading "\\" backslashes are
  10175. // optional in the ComputerName.
  10176. //
  10177. // Set CERT_STORE_CREATE_NEW_FLAG to cause a failure if the system store
  10178. // already exists in the store location.
  10179. //--------------------------------------------------------------------------
  10180. function CertRegisterSystemStore(pvSystemStore: Pointer; dwFlags: DWORD;
  10181. pStoreInfo: PCERT_SYSTEM_STORE_INFO; pvReserved: Pointer): BOOL; stdcall;
  10182. {$EXTERNALSYM CertRegisterSystemStore}
  10183. //+-------------------------------------------------------------------------
  10184. // Register a physical store for the specified system store.
  10185. //
  10186. // The upper word of the dwFlags parameter is used to specify the location of
  10187. // the system store.
  10188. //
  10189. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvSystemStore
  10190. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure. Otherwise,
  10191. // pvSystemStore points to a null terminated UNICODE string.
  10192. //
  10193. // See CertRegisterSystemStore for details on prepending a ServiceName
  10194. // and/or ComputerName to the system store name.
  10195. //
  10196. // Set CERT_STORE_CREATE_NEW_FLAG to cause a failure if the physical store
  10197. // already exists in the system store.
  10198. //--------------------------------------------------------------------------
  10199. function CertRegisterPhysicalStore(pvSystemStore: Pointer; dwFlags: DWORD;
  10200. pwszStoreName: LPCWSTR; pStoreInfo: PCERT_PHYSICAL_STORE_INFO;
  10201. pvReserved: Pointer): BOOL; stdcall;
  10202. {$EXTERNALSYM CertRegisterPhysicalStore}
  10203. //+-------------------------------------------------------------------------
  10204. // Unregister the specified system store.
  10205. //
  10206. // The upper word of the dwFlags parameter is used to specify the location of
  10207. // the system store.
  10208. //
  10209. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvSystemStore
  10210. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure. Otherwise,
  10211. // pvSystemStore points to a null terminated UNICODE string.
  10212. //
  10213. // See CertRegisterSystemStore for details on prepending a ServiceName
  10214. // and/or ComputerName to the system store name.
  10215. //
  10216. // CERT_STORE_DELETE_FLAG can optionally be set in dwFlags.
  10217. //--------------------------------------------------------------------------
  10218. function CertUnregisterSystemStore(pvSystemStore: Pointer; dwFlags: DWORD): BOOL; stdcall;
  10219. {$EXTERNALSYM CertUnregisterSystemStore}
  10220. //+-------------------------------------------------------------------------
  10221. // Unregister the physical store from the specified system store.
  10222. //
  10223. // The upper word of the dwFlags parameter is used to specify the location of
  10224. // the system store.
  10225. //
  10226. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvSystemStore
  10227. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure. Otherwise,
  10228. // pvSystemStore points to a null terminated UNICODE string.
  10229. //
  10230. // See CertRegisterSystemStore for details on prepending a ServiceName
  10231. // and/or ComputerName to the system store name.
  10232. //
  10233. // CERT_STORE_DELETE_FLAG can optionally be set in dwFlags.
  10234. //--------------------------------------------------------------------------
  10235. function CertUnregisterPhysicalStore(pvSystemStore: Pointer; dwFlags: DWORD;
  10236. pwszStoreName: LPCWSTR): BOOL; stdcall;
  10237. {$EXTERNALSYM CertUnregisterPhysicalStore}
  10238. //+-------------------------------------------------------------------------
  10239. // Enum callbacks
  10240. //
  10241. // The CERT_SYSTEM_STORE_LOCATION_MASK bits in the dwFlags parameter
  10242. // specifies the location of the system store
  10243. //
  10244. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvSystemStore
  10245. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure. Otherwise,
  10246. // pvSystemStore points to a null terminated UNICODE string.
  10247. //
  10248. // The callback returns FALSE and sets LAST_ERROR to stop the enumeration.
  10249. // The LAST_ERROR is returned to the caller of the enumeration.
  10250. //
  10251. // The pvSystemStore passed to the callback has leading ComputerName and/or
  10252. // ServiceName prefixes where appropriate.
  10253. //--------------------------------------------------------------------------
  10254. type
  10255. PFN_CERT_ENUM_SYSTEM_STORE_LOCATION = function(pwszStoreLocation: LPCWSTR;
  10256. dwFlags: DWORD; pvReserved: Pointer; pvArg: Pointer): BOOL; stdcall;
  10257. {$EXTERNALSYM PFN_CERT_ENUM_SYSTEM_STORE_LOCATION}
  10258. PfnCertEnumSystemStoreLocation = PFN_CERT_ENUM_SYSTEM_STORE_LOCATION;
  10259. PFN_CERT_ENUM_SYSTEM_STORE = function(pvSystemStore: Pointer;
  10260. dwFlags: DWORD; pStoreInfo: PCERT_SYSTEM_STORE_INFO; pvReserved: Pointer;
  10261. pvArg: Pointer): BOOL; stdcall;
  10262. {$EXTERNALSYM PFN_CERT_ENUM_SYSTEM_STORE}
  10263. PfnCertEnumSystemStore = PFN_CERT_ENUM_SYSTEM_STORE;
  10264. PFN_CERT_ENUM_PHYSICAL_STORE = function(pvSystemStore: Pointer;
  10265. dwFlags: DWORD; pwszStoreName: LPCWSTR; pStoreInfo: PCERT_PHYSICAL_STORE_INFO;
  10266. pvReserved: Pointer; pvArg: Pointer): BOOL; stdcall;
  10267. {$EXTERNALSYM PFN_CERT_ENUM_PHYSICAL_STORE}
  10268. PfnCertEnumPhysicalStore = PFN_CERT_ENUM_PHYSICAL_STORE;
  10269. // In the PFN_CERT_ENUM_PHYSICAL_STORE callback the following flag is
  10270. // set if the physical store wasn't registered and is an implicitly created
  10271. // predefined physical store.
  10272. const
  10273. CERT_PHYSICAL_STORE_PREDEFINED_ENUM_FLAG = $1;
  10274. {$EXTERNALSYM CERT_PHYSICAL_STORE_PREDEFINED_ENUM_FLAG}
  10275. // Names of implicitly created predefined physical stores
  10276. CERT_PHYSICAL_STORE_DEFAULT_NAME = '.Default';
  10277. {$EXTERNALSYM CERT_PHYSICAL_STORE_DEFAULT_NAME}
  10278. CERT_PHYSICAL_STORE_GROUP_POLICY_NAME = '.GroupPolicy';
  10279. {$EXTERNALSYM CERT_PHYSICAL_STORE_GROUP_POLICY_NAME}
  10280. CERT_PHYSICAL_STORE_LOCAL_MACHINE_NAME = '.LocalMachine';
  10281. {$EXTERNALSYM CERT_PHYSICAL_STORE_LOCAL_MACHINE_NAME}
  10282. CERT_PHYSICAL_STORE_DS_USER_CERTIFICATE_NAME = '.UserCertificate';
  10283. {$EXTERNALSYM CERT_PHYSICAL_STORE_DS_USER_CERTIFICATE_NAME}
  10284. CERT_PHYSICAL_STORE_LOCAL_MACHINE_GROUP_POLICY_NAME = '.LocalMachineGroupPolicy';
  10285. {$EXTERNALSYM CERT_PHYSICAL_STORE_LOCAL_MACHINE_GROUP_POLICY_NAME}
  10286. CERT_PHYSICAL_STORE_ENTERPRISE_NAME = '.Enterprise';
  10287. {$EXTERNALSYM CERT_PHYSICAL_STORE_ENTERPRISE_NAME}
  10288. //+-------------------------------------------------------------------------
  10289. // Enumerate the system store locations.
  10290. //--------------------------------------------------------------------------
  10291. function CertEnumSystemStoreLocation(dwFlags: DWORD; pvArg: Pointer;
  10292. pfnEnum: PFN_CERT_ENUM_SYSTEM_STORE_LOCATION): BOOL; stdcall;
  10293. {$EXTERNALSYM CertEnumSystemStoreLocation}
  10294. //+-------------------------------------------------------------------------
  10295. // Enumerate the system stores.
  10296. //
  10297. // The upper word of the dwFlags parameter is used to specify the location of
  10298. // the system store.
  10299. //
  10300. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags,
  10301. // pvSystemStoreLocationPara points to a CERT_SYSTEM_STORE_RELOCATE_PARA
  10302. // data structure. Otherwise, pvSystemStoreLocationPara points to a null
  10303. // terminated UNICODE string.
  10304. //
  10305. // For CERT_SYSTEM_STORE_LOCAL_MACHINE,
  10306. // CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY or
  10307. // CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE, pvSystemStoreLocationPara can
  10308. // optionally be set to a unicode computer name for enumerating local machine
  10309. // stores on a remote computer. For example, "\\ComputerName" or
  10310. // "ComputerName". The leading "\\" backslashes are optional in the
  10311. // ComputerName.
  10312. //
  10313. // For CERT_SYSTEM_STORE_SERVICES or CERT_SYSTEM_STORE_USERS,
  10314. // if pvSystemStoreLocationPara is NULL, then,
  10315. // enumerates both the service/user names and the stores for each service/user
  10316. // name. Otherwise, pvSystemStoreLocationPara is a unicode string specifying a
  10317. // remote computer name and/or service/user name. For example:
  10318. // "ServiceName"
  10319. // "\\ComputerName" or "ComputerName\"
  10320. // "ComputerName\ServiceName"
  10321. // Note, if only the ComputerName is specified, then, it must have either
  10322. // the leading "\\" backslashes or a trailing backslash. Otherwise, its
  10323. // interpretted as the ServiceName or UserName.
  10324. //--------------------------------------------------------------------------
  10325. function CertEnumSystemStore(dwFlags: DWORD; pvSystemStoreLocationPara: Pointer;
  10326. pvArg: Pointer; pfnEnum: PFN_CERT_ENUM_SYSTEM_STORE): BOOL; stdcall;
  10327. {$EXTERNALSYM CertEnumSystemStore}
  10328. //+-------------------------------------------------------------------------
  10329. // Enumerate the physical stores for the specified system store.
  10330. //
  10331. // The upper word of the dwFlags parameter is used to specify the location of
  10332. // the system store.
  10333. //
  10334. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvSystemStore
  10335. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure. Otherwise,
  10336. // pvSystemStore points to a null terminated UNICODE string.
  10337. //
  10338. // See CertRegisterSystemStore for details on prepending a ServiceName
  10339. // and/or ComputerName to the system store name.
  10340. //
  10341. // If the system store location only supports system stores and doesn't
  10342. // support physical stores, LastError is set to ERROR_CALL_NOT_IMPLEMENTED.
  10343. //--------------------------------------------------------------------------
  10344. function CertEnumPhysicalStore(pvSystemStore: Pointer; dwFlags: DWORD;
  10345. pvArg: Pointer; pfnEnum: PFN_CERT_ENUM_PHYSICAL_STORE): BOOL; stdcall;
  10346. {$EXTERNALSYM CertEnumPhysicalStore}
  10347. //+-------------------------------------------------------------------------
  10348. // Certificate System Store Installable Functions
  10349. //
  10350. // The CERT_SYSTEM_STORE_LOCATION_MASK bits in the dwFlags parameter passed
  10351. // to the CertOpenStore(for "System", "SystemRegistry" or "Physical"
  10352. // Provider), CertRegisterSystemStore,
  10353. // CertUnregisterSystemStore, CertEnumSystemStore, CertRegisterPhysicalStore,
  10354. // CertUnregisterPhysicalStore and CertEnumPhysicalStore APIs is used as the
  10355. // constant pszOID value passed to the OID installable functions.
  10356. // Therefore, the pszOID is restricted to a constant <= (LPCSTR) 0x0FFF.
  10357. //
  10358. // The EncodingType is 0.
  10359. //--------------------------------------------------------------------------
  10360. // Installable System Store Provider OID pszFuncNames.
  10361. const
  10362. CRYPT_OID_OPEN_SYSTEM_STORE_PROV_FUNC = 'CertDllOpenSystemStoreProv';
  10363. {$EXTERNALSYM CRYPT_OID_OPEN_SYSTEM_STORE_PROV_FUNC}
  10364. CRYPT_OID_REGISTER_SYSTEM_STORE_FUNC = 'CertDllRegisterSystemStore';
  10365. {$EXTERNALSYM CRYPT_OID_REGISTER_SYSTEM_STORE_FUNC}
  10366. CRYPT_OID_UNREGISTER_SYSTEM_STORE_FUNC = 'CertDllUnregisterSystemStore';
  10367. {$EXTERNALSYM CRYPT_OID_UNREGISTER_SYSTEM_STORE_FUNC}
  10368. CRYPT_OID_ENUM_SYSTEM_STORE_FUNC = 'CertDllEnumSystemStore';
  10369. {$EXTERNALSYM CRYPT_OID_ENUM_SYSTEM_STORE_FUNC}
  10370. CRYPT_OID_REGISTER_PHYSICAL_STORE_FUNC = 'CertDllRegisterPhysicalStore';
  10371. {$EXTERNALSYM CRYPT_OID_REGISTER_PHYSICAL_STORE_FUNC}
  10372. CRYPT_OID_UNREGISTER_PHYSICAL_STORE_FUNC = 'CertDllUnregisterPhysicalStore';
  10373. {$EXTERNALSYM CRYPT_OID_UNREGISTER_PHYSICAL_STORE_FUNC}
  10374. CRYPT_OID_ENUM_PHYSICAL_STORE_FUNC = 'CertDllEnumPhysicalStore';
  10375. {$EXTERNALSYM CRYPT_OID_ENUM_PHYSICAL_STORE_FUNC}
  10376. // CertDllOpenSystemStoreProv has the same function signature as the
  10377. // installable "CertDllOpenStoreProv" function. See CertOpenStore for
  10378. // more details.
  10379. // CertDllRegisterSystemStore has the same function signature as
  10380. // CertRegisterSystemStore.
  10381. //
  10382. // The "SystemStoreLocation" REG_SZ value must also be set for registered
  10383. // CertDllEnumSystemStore OID functions.
  10384. CRYPT_OID_SYSTEM_STORE_LOCATION_VALUE_NAME = 'SystemStoreLocation';
  10385. {$EXTERNALSYM CRYPT_OID_SYSTEM_STORE_LOCATION_VALUE_NAME}
  10386. // The remaining Register, Enum and Unregister OID installable functions
  10387. // have the same signature as their Cert Store API counterpart.
  10388. //+=========================================================================
  10389. // Enhanced Key Usage Helper Functions
  10390. //==========================================================================
  10391. //+-------------------------------------------------------------------------
  10392. // Get the enhanced key usage extension or property from the certificate
  10393. // and decode.
  10394. //
  10395. // If the CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG is set, then, only get the
  10396. // extension.
  10397. //
  10398. // If the CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG is set, then, only get the
  10399. // property.
  10400. //--------------------------------------------------------------------------
  10401. function CertGetEnhancedKeyUsage(pCertContext: PCCERT_CONTEXT; dwFlags: DWORD;
  10402. pUsage: PCERT_ENHKEY_USAGE; var pcbUsage: DWORD): BOOL; stdcall;
  10403. {$EXTERNALSYM CertGetEnhancedKeyUsage}
  10404. //+-------------------------------------------------------------------------
  10405. // Set the enhanced key usage property for the certificate.
  10406. //--------------------------------------------------------------------------
  10407. function CertSetEnhancedKeyUsage(pCertContext: PCCERT_CONTEXT;
  10408. pUsage: PCERT_ENHKEY_USAGE): BOOL; stdcall;
  10409. {$EXTERNALSYM CertSetEnhancedKeyUsage}
  10410. //+-------------------------------------------------------------------------
  10411. // Add the usage identifier to the certificate's enhanced key usage property.
  10412. //--------------------------------------------------------------------------
  10413. function CertAddEnhancedKeyUsageIdentifier(pCertContext: PCCERT_CONTEXT;
  10414. pszUsageIdentifier: LPCSTR): BOOL; stdcall;
  10415. {$EXTERNALSYM CertAddEnhancedKeyUsageIdentifier}
  10416. //+-------------------------------------------------------------------------
  10417. // Remove the usage identifier from the certificate's enhanced key usage
  10418. // property.
  10419. //--------------------------------------------------------------------------
  10420. function CertRemoveEnhancedKeyUsageIdentifier(pCertContext: PCCERT_CONTEXT;
  10421. pszUsageIdentifier: LPCSTR): BOOL; stdcall;
  10422. {$EXTERNALSYM CertRemoveEnhancedKeyUsageIdentifier}
  10423. //+---------------------------------------------------------------------------
  10424. //
  10425. //
  10426. // Takes an array of certs and returns an array of usages
  10427. // which consists of the intersection of the valid usages for each cert.
  10428. // If each cert is good for all possible usages then the cNumOIDs is set to -1.
  10429. //
  10430. //----------------------------------------------------------------------------
  10431. function CertGetValidUsages(cCerts: DWORD; rghCerts: PCCERT_CONTEXT;
  10432. var cNumOIDs: Integer; rghOIDs: LPLPSTR; var pcbOIDs: DWORD): BOOL; stdcall;
  10433. {$EXTERNALSYM CertGetValidUsages}
  10434. //+=========================================================================
  10435. // Cryptographic Message helper functions for verifying and signing a
  10436. // CTL.
  10437. //==========================================================================
  10438. //+-------------------------------------------------------------------------
  10439. // Get and verify the signer of a cryptographic message.
  10440. //
  10441. // To verify a CTL, the hCryptMsg is obtained from the CTL_CONTEXT's
  10442. // hCryptMsg field.
  10443. //
  10444. // If CMSG_TRUSTED_SIGNER_FLAG is set, then, treat the Signer stores as being
  10445. // trusted and only search them to find the certificate corresponding to the
  10446. // signer's issuer and serial number. Otherwise, the SignerStores are
  10447. // optionally provided to supplement the message's store of certificates.
  10448. // If a signer certificate is found, its public key is used to verify
  10449. // the message signature. The CMSG_SIGNER_ONLY_FLAG can be set to
  10450. // return the signer without doing the signature verify.
  10451. //
  10452. // If CMSG_USE_SIGNER_INDEX_FLAG is set, then, only get the signer specified
  10453. // by *pdwSignerIndex. Otherwise, iterate through all the signers
  10454. // until a signer verifies or no more signers.
  10455. //
  10456. // For a verified signature, *ppSigner is updated with certificate context
  10457. // of the signer and *pdwSignerIndex is updated with the index of the signer.
  10458. // ppSigner and/or pdwSignerIndex can be NULL, indicating the caller isn't
  10459. // interested in getting the CertContext and/or index of the signer.
  10460. //--------------------------------------------------------------------------
  10461. function CryptMsgGetAndVerifySigner(hCryptMsg: HCRYPTMSG; cSignerStore: DWORD;
  10462. rghSignerStore: PHCERTSTORE; dwFlags: DWORD; ppSigner: PPCCERT_CONTEXT;
  10463. pdwSignerIndex: LPDWORD): BOOL; stdcall;
  10464. {$EXTERNALSYM CryptMsgGetAndVerifySigner}
  10465. const
  10466. CMSG_TRUSTED_SIGNER_FLAG = $1;
  10467. {$EXTERNALSYM CMSG_TRUSTED_SIGNER_FLAG}
  10468. CMSG_SIGNER_ONLY_FLAG = $2;
  10469. {$EXTERNALSYM CMSG_SIGNER_ONLY_FLAG}
  10470. CMSG_USE_SIGNER_INDEX_FLAG = $4;
  10471. {$EXTERNALSYM CMSG_USE_SIGNER_INDEX_FLAG}
  10472. //+-------------------------------------------------------------------------
  10473. // Sign an encoded CTL.
  10474. //
  10475. // The pbCtlContent can be obtained via a CTL_CONTEXT's pbCtlContent
  10476. // field or via a CryptEncodeObject(PKCS_CTL or PKCS_SORTED_CTL).
  10477. //
  10478. // CMSG_CMS_ENCAPSULATED_CTL_FLAG can be set to encode a CMS compatible
  10479. // V3 SignedData message.
  10480. //--------------------------------------------------------------------------
  10481. function CryptMsgSignCTL(dwMsgEncodingType: DWORD; pbCtlContent: LPBYTE;
  10482. cbCtlContent: DWORD; pSignInfo: PCMSG_SIGNED_ENCODE_INFO; dwFlags: DWORD;
  10483. pbEncoded: LPBYTE; var pcbEncoded: DWORD): BOOL; stdcall;
  10484. {$EXTERNALSYM CryptMsgSignCTL}
  10485. // When set, CTL inner content is encapsulated within an OCTET STRING
  10486. const
  10487. CMSG_CMS_ENCAPSULATED_CTL_FLAG = $00008000;
  10488. {$EXTERNALSYM CMSG_CMS_ENCAPSULATED_CTL_FLAG}
  10489. //+-------------------------------------------------------------------------
  10490. // Encode the CTL and create a signed message containing the encoded CTL.
  10491. //
  10492. // Set CMSG_ENCODE_SORTED_CTL_FLAG if the CTL entries are to be sorted
  10493. // before encoding. This flag should be set, if the
  10494. // CertFindSubjectInSortedCTL or CertEnumSubjectInSortedCTL APIs will
  10495. // be called. If the identifier for the CTL entries is a hash, such as,
  10496. // MD5 or SHA1, then, CMSG_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG should
  10497. // also be set.
  10498. //
  10499. // CMSG_CMS_ENCAPSULATED_CTL_FLAG can be set to encode a CMS compatible
  10500. // V3 SignedData message.
  10501. //--------------------------------------------------------------------------
  10502. function CryptMsgEncodeAndSignCTL(dwMsgEncodingType: DWORD; pCtlInfo: PCTL_INFO;
  10503. pSignInfo: PCMSG_SIGNED_ENCODE_INFO; dwFlags: DWORD; pbEncoded: LPBYTE;
  10504. var pcbEncoded: DWORD): BOOL; stdcall;
  10505. {$EXTERNALSYM CryptMsgEncodeAndSignCTL}
  10506. // The following flag is set if the CTL is to be encoded with sorted
  10507. // trusted subjects and the szOID_SORTED_CTL extension is inserted containing
  10508. // sorted offsets to the encoded subjects.
  10509. const
  10510. CMSG_ENCODE_SORTED_CTL_FLAG = $1;
  10511. {$EXTERNALSYM CMSG_ENCODE_SORTED_CTL_FLAG}
  10512. // If the above sorted flag is set, then, the following flag should also
  10513. // be set if the identifier for the TrustedSubjects is a hash,
  10514. // such as, MD5 or SHA1.
  10515. CMSG_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG = $2;
  10516. {$EXTERNALSYM CMSG_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG}
  10517. //+-------------------------------------------------------------------------
  10518. // Returns TRUE if the SubjectIdentifier exists in the CTL. Optionally
  10519. // returns a pointer to and byte count of the Subject's encoded attributes.
  10520. //--------------------------------------------------------------------------
  10521. function CertFindSubjectInSortedCTL(pSubjectIdentifier: PCRYPT_DATA_BLOB;
  10522. pCtlContext: PCCTL_CONTEXT; dwFlags: DWORD; pvReserved: Pointer;
  10523. pEncodedAttributes: PCRYPT_DER_BLOB): BOOL; stdcall;
  10524. {$EXTERNALSYM CertFindSubjectInSortedCTL}
  10525. //+-------------------------------------------------------------------------
  10526. // Enumerates through the sequence of TrustedSubjects in a CTL context
  10527. // created with CERT_CREATE_CONTEXT_SORTED_FLAG set.
  10528. //
  10529. // To start the enumeration, *ppvNextSubject must be NULL. Upon return,
  10530. // *ppvNextSubject is updated to point to the next TrustedSubject in
  10531. // the encoded sequence.
  10532. //
  10533. // Returns FALSE for no more subjects or invalid arguments.
  10534. //
  10535. // Note, the returned DER_BLOBs point directly into the encoded
  10536. // bytes (not allocated, and must not be freed).
  10537. //--------------------------------------------------------------------------
  10538. function CertEnumSubjectInSortedCTL(pCtlContext: PCCTL_CONTEXT;
  10539. var ppvNextSubject: Pointer; pSubjectIdentifier: PCRYPT_DER_BLOB;
  10540. pEncodedAttributes: PCRYPT_DER_BLOB): BOOL; stdcall;
  10541. {$EXTERNALSYM CertEnumSubjectInSortedCTL}
  10542. //+=========================================================================
  10543. // Certificate Verify CTL Usage Data Structures and APIs
  10544. //==========================================================================
  10545. type
  10546. PCTL_VERIFY_USAGE_PARA = ^CTL_VERIFY_USAGE_PARA;
  10547. {$EXTERNALSYM PCTL_VERIFY_USAGE_PARA}
  10548. _CTL_VERIFY_USAGE_PARA = record
  10549. cbSize: DWORD;
  10550. ListIdentifier: CRYPT_DATA_BLOB; // OPTIONAL
  10551. cCtlStore: DWORD;
  10552. rghCtlStore: PHCERTSTORE; // OPTIONAL
  10553. cSignerStore: DWORD;
  10554. rghSignerStore: PHCERTSTORE; // OPTIONAL
  10555. end;
  10556. {$EXTERNALSYM _CTL_VERIFY_USAGE_PARA}
  10557. CTL_VERIFY_USAGE_PARA = _CTL_VERIFY_USAGE_PARA;
  10558. {$EXTERNALSYM CTL_VERIFY_USAGE_PARA}
  10559. TCtlVerifyUsagePara = CTL_VERIFY_USAGE_PARA;
  10560. PCtlVerifyUsagePara = PCTL_VERIFY_USAGE_PARA;
  10561. PCTL_VERIFY_USAGE_STATUS = ^CTL_VERIFY_USAGE_STATUS;
  10562. {$EXTERNALSYM PCTL_VERIFY_USAGE_STATUS}
  10563. _CTL_VERIFY_USAGE_STATUS = record
  10564. cbSize: DWORD;
  10565. dwError: DWORD;
  10566. dwFlags: DWORD;
  10567. ppCtl: PPCCTL_CONTEXT; // IN OUT OPTIONAL
  10568. dwCtlEntryIndex: DWORD;
  10569. ppSigner: PPCCERT_CONTEXT; // IN OUT OPTIONAL
  10570. dwSignerIndex: DWORD;
  10571. end;
  10572. {$EXTERNALSYM _CTL_VERIFY_USAGE_STATUS}
  10573. CTL_VERIFY_USAGE_STATUS = _CTL_VERIFY_USAGE_STATUS;
  10574. {$EXTERNALSYM CTL_VERIFY_USAGE_STATUS}
  10575. TCtlVerifyUsageStatus = CTL_VERIFY_USAGE_STATUS;
  10576. PCtlVerifyUsageStatus = PCTL_VERIFY_USAGE_STATUS;
  10577. const
  10578. CERT_VERIFY_INHIBIT_CTL_UPDATE_FLAG = $1;
  10579. {$EXTERNALSYM CERT_VERIFY_INHIBIT_CTL_UPDATE_FLAG}
  10580. CERT_VERIFY_TRUSTED_SIGNERS_FLAG = $2;
  10581. {$EXTERNALSYM CERT_VERIFY_TRUSTED_SIGNERS_FLAG}
  10582. CERT_VERIFY_NO_TIME_CHECK_FLAG = $4;
  10583. {$EXTERNALSYM CERT_VERIFY_NO_TIME_CHECK_FLAG}
  10584. CERT_VERIFY_ALLOW_MORE_USAGE_FLAG = $8;
  10585. {$EXTERNALSYM CERT_VERIFY_ALLOW_MORE_USAGE_FLAG}
  10586. CERT_VERIFY_UPDATED_CTL_FLAG = $1;
  10587. {$EXTERNALSYM CERT_VERIFY_UPDATED_CTL_FLAG}
  10588. //+-------------------------------------------------------------------------
  10589. // Verify that a subject is trusted for the specified usage by finding a
  10590. // signed and time valid CTL with the usage identifiers and containing the
  10591. // the subject. A subject can be identified by either its certificate context
  10592. // or any identifier such as its SHA1 hash.
  10593. //
  10594. // See CertFindSubjectInCTL for definition of dwSubjectType and pvSubject
  10595. // parameters.
  10596. //
  10597. // Via pVerifyUsagePara, the caller can specify the stores to be searched
  10598. // to find the CTL. The caller can also specify the stores containing
  10599. // acceptable CTL signers. By setting the ListIdentifier, the caller
  10600. // can also restrict to a particular signer CTL list.
  10601. //
  10602. // Via pVerifyUsageStatus, the CTL containing the subject, the subject's
  10603. // index into the CTL's array of entries, and the signer of the CTL
  10604. // are returned. If the caller is not interested, ppCtl and ppSigner can be set
  10605. // to NULL. Returned contexts must be freed via the store's free context APIs.
  10606. //
  10607. // If the CERT_VERIFY_INHIBIT_CTL_UPDATE_FLAG isn't set, then, a time
  10608. // invalid CTL in one of the CtlStores may be replaced. When replaced, the
  10609. // CERT_VERIFY_UPDATED_CTL_FLAG is set in pVerifyUsageStatus->dwFlags.
  10610. //
  10611. // If the CERT_VERIFY_TRUSTED_SIGNERS_FLAG is set, then, only the
  10612. // SignerStores specified in pVerifyUsageStatus are searched to find
  10613. // the signer. Otherwise, the SignerStores provide additional sources
  10614. // to find the signer's certificate.
  10615. //
  10616. // If CERT_VERIFY_NO_TIME_CHECK_FLAG is set, then, the CTLs aren't checked
  10617. // for time validity.
  10618. //
  10619. // If CERT_VERIFY_ALLOW_MORE_USAGE_FLAG is set, then, the CTL may contain
  10620. // additional usage identifiers than specified by pSubjectUsage. Otherwise,
  10621. // the found CTL will contain the same usage identifers and no more.
  10622. //
  10623. // CertVerifyCTLUsage will be implemented as a dispatcher to OID installable
  10624. // functions. First, it will try to find an OID function matching the first
  10625. // usage object identifier in the pUsage sequence. Next, it will dispatch
  10626. // to the default CertDllVerifyCTLUsage functions.
  10627. //
  10628. // If the subject is trusted for the specified usage, then, TRUE is
  10629. // returned. Otherwise, FALSE is returned with dwError set to one of the
  10630. // following:
  10631. // CRYPT_E_NO_VERIFY_USAGE_DLL
  10632. // CRYPT_E_NO_VERIFY_USAGE_CHECK
  10633. // CRYPT_E_VERIFY_USAGE_OFFLINE
  10634. // CRYPT_E_NOT_IN_CTL
  10635. // CRYPT_E_NO_TRUSTED_SIGNER
  10636. //--------------------------------------------------------------------------
  10637. function CertVerifyCTLUsage(dwEncodingType: DWORD; dwSubjectType: DWORD;
  10638. pvSubject: Pointer; pSubjectUsage: PCTL_USAGE; dwFlags: DWORD;
  10639. pVerifyUsagePara: PCTL_VERIFY_USAGE_PARA;
  10640. pVerifyUsageStatus: PCTL_VERIFY_USAGE_STATUS): BOOL; stdcall;
  10641. {$EXTERNALSYM CertVerifyCTLUsage}
  10642. //+=========================================================================
  10643. // Certificate Revocation Data Structures and APIs
  10644. //==========================================================================
  10645. //+-------------------------------------------------------------------------
  10646. // The following data structure may be passed to CertVerifyRevocation to
  10647. // assist in finding the issuer of the context to be verified.
  10648. //
  10649. // When pIssuerCert is specified, pIssuerCert is the issuer of
  10650. // rgpvContext[cContext - 1].
  10651. //
  10652. // When cCertStore and rgCertStore are specified, these stores may contain
  10653. // an issuer certificate.
  10654. //
  10655. // When hCrlStore is specified then a handler which uses CRLs can search this
  10656. // store for them
  10657. //
  10658. // When pftTimeToUse is specified then the handler (if possible) must determine
  10659. // revocation status relative to the time given otherwise the answer may be
  10660. // independent of time or relative to current time
  10661. //--------------------------------------------------------------------------
  10662. type
  10663. PCERT_REVOCATION_PARA = ^CERT_REVOCATION_PARA;
  10664. {$EXTERNALSYM PCERT_REVOCATION_PARA}
  10665. _CERT_REVOCATION_PARA = record
  10666. cbSize: DWORD;
  10667. pIssuerCert: PCCERT_CONTEXT;
  10668. cCertStore: DWORD;
  10669. rgCertStore: PHCERTSTORE;
  10670. hCrlStore: HCERTSTORE;
  10671. pftTimeToUse: LPFILETIME;
  10672. end;
  10673. {$EXTERNALSYM _CERT_REVOCATION_PARA}
  10674. CERT_REVOCATION_PARA = _CERT_REVOCATION_PARA;
  10675. {$EXTERNALSYM CERT_REVOCATION_PARA}
  10676. TCertRevocationPara = CERT_REVOCATION_PARA;
  10677. PCertRevocationPara = PCERT_REVOCATION_PARA;
  10678. //+-------------------------------------------------------------------------
  10679. // The following data structure is returned by CertVerifyRevocation to
  10680. // specify the status of the revoked or unchecked context. Review the
  10681. // following CertVerifyRevocation comments for details.
  10682. //
  10683. // Upon input to CertVerifyRevocation, cbSize must be set to a size
  10684. // >= sizeof(CERT_REVOCATION_STATUS). Otherwise, CertVerifyRevocation
  10685. // returns FALSE and sets LastError to E_INVALIDARG.
  10686. //
  10687. // Upon input to the installed or registered CRYPT_OID_VERIFY_REVOCATION_FUNC
  10688. // functions, the dwIndex, dwError and dwReason have been zero'ed.
  10689. //--------------------------------------------------------------------------
  10690. PCERT_REVOCATION_STATUS = ^CERT_REVOCATION_STATUS;
  10691. {$EXTERNALSYM PCERT_REVOCATION_STATUS}
  10692. _CERT_REVOCATION_STATUS = record
  10693. cbSize: DWORD;
  10694. dwIndex: DWORD;
  10695. dwError: DWORD;
  10696. dwReason: DWORD;
  10697. end;
  10698. {$EXTERNALSYM _CERT_REVOCATION_STATUS}
  10699. CERT_REVOCATION_STATUS = _CERT_REVOCATION_STATUS;
  10700. {$EXTERNALSYM CERT_REVOCATION_STATUS}
  10701. TCertRevocationStatus = CERT_REVOCATION_STATUS;
  10702. PCertRevocationStatus = PCERT_REVOCATION_STATUS;
  10703. //+-------------------------------------------------------------------------
  10704. // Verifies the array of contexts for revocation. The dwRevType parameter
  10705. // indicates the type of the context data structure passed in rgpvContext.
  10706. // Currently only the revocation of certificates is defined.
  10707. //
  10708. // If the CERT_VERIFY_REV_CHAIN_FLAG flag is set, then, CertVerifyRevocation
  10709. // is verifying a chain of certs where, rgpvContext[i + 1] is the issuer
  10710. // of rgpvContext[i]. Otherwise, CertVerifyRevocation makes no assumptions
  10711. // about the order of the contexts.
  10712. //
  10713. // To assist in finding the issuer, the pRevPara may optionally be set. See
  10714. // the CERT_REVOCATION_PARA data structure for details.
  10715. //
  10716. // The contexts must contain enough information to allow the
  10717. // installable or registered revocation DLLs to find the revocation server. For
  10718. // certificates, this information would normally be conveyed in an
  10719. // extension such as the IETF's AuthorityInfoAccess extension.
  10720. //
  10721. // CertVerifyRevocation returns TRUE if all of the contexts were successfully
  10722. // checked and none were revoked. Otherwise, returns FALSE and updates the
  10723. // returned pRevStatus data structure as follows:
  10724. // dwIndex
  10725. // Index of the first context that was revoked or unable to
  10726. // be checked for revocation
  10727. // dwError
  10728. // Error status. LastError is also set to this error status.
  10729. // dwError can be set to one of the following error codes defined
  10730. // in winerror.h:
  10731. // ERROR_SUCCESS - good context
  10732. // CRYPT_E_REVOKED - context was revoked. dwReason contains the
  10733. // reason for revocation
  10734. // CRYPT_E_REVOCATION_OFFLINE - unable to connect to the
  10735. // revocation server
  10736. // CRYPT_E_NOT_IN_REVOCATION_DATABASE - the context to be checked
  10737. // was not found in the revocation server's database.
  10738. // CRYPT_E_NO_REVOCATION_CHECK - the called revocation function
  10739. // wasn't able to do a revocation check on the context
  10740. // CRYPT_E_NO_REVOCATION_DLL - no installed or registered Dll was
  10741. // found to verify revocation
  10742. // dwReason
  10743. // The dwReason is currently only set for CRYPT_E_REVOKED and contains
  10744. // the reason why the context was revoked. May be one of the following
  10745. // CRL reasons defined by the CRL Reason Code extension ("2.5.29.21")
  10746. // CRL_REASON_UNSPECIFIED 0
  10747. // CRL_REASON_KEY_COMPROMISE 1
  10748. // CRL_REASON_CA_COMPROMISE 2
  10749. // CRL_REASON_AFFILIATION_CHANGED 3
  10750. // CRL_REASON_SUPERSEDED 4
  10751. // CRL_REASON_CESSATION_OF_OPERATION 5
  10752. // CRL_REASON_CERTIFICATE_HOLD 6
  10753. //
  10754. // For each entry in rgpvContext, CertVerifyRevocation iterates
  10755. // through the CRYPT_OID_VERIFY_REVOCATION_FUNC
  10756. // function set's list of installed DEFAULT functions.
  10757. // CryptGetDefaultOIDFunctionAddress is called with pwszDll = NULL. If no
  10758. // installed functions are found capable of doing the revocation verification,
  10759. // CryptVerifyRevocation iterates through CRYPT_OID_VERIFY_REVOCATION_FUNC's
  10760. // list of registered DEFAULT Dlls. CryptGetDefaultOIDDllList is called to
  10761. // get the list. CryptGetDefaultOIDFunctionAddress is called to load the Dll.
  10762. //
  10763. // The called functions have the same signature as CertVerifyRevocation. A
  10764. // called function returns TRUE if it was able to successfully check all of
  10765. // the contexts and none were revoked. Otherwise, the called function returns
  10766. // FALSE and updates pRevStatus. dwIndex is set to the index of
  10767. // the first context that was found to be revoked or unable to be checked.
  10768. // dwError and LastError are updated. For CRYPT_E_REVOKED, dwReason
  10769. // is updated. Upon input to the called function, dwIndex, dwError and
  10770. // dwReason have been zero'ed. cbSize has been checked to be >=
  10771. // sizeof(CERT_REVOCATION_STATUS).
  10772. //
  10773. // If the called function returns FALSE, and dwError isn't set to
  10774. // CRYPT_E_REVOKED, then, CertVerifyRevocation either continues on to the
  10775. // next DLL in the list for a returned dwIndex of 0 or for a returned
  10776. // dwIndex > 0, restarts the process of finding a verify function by
  10777. // advancing the start of the context array to the returned dwIndex and
  10778. // decrementing the count of remaining contexts.
  10779. //--------------------------------------------------------------------------
  10780. function CertVerifyRevocation(dwEncodingType, dwRevType, cContext: DWORD;
  10781. rgpvContext: PVOID; dwFlags: DWORD; pRevPara: PCERT_REVOCATION_PARA;
  10782. pRevStatus: PCERT_REVOCATION_STATUS): BOOL; stdcall;
  10783. {$EXTERNALSYM CertVerifyRevocation}
  10784. //+-------------------------------------------------------------------------
  10785. // Revocation types
  10786. //--------------------------------------------------------------------------
  10787. const
  10788. CERT_CONTEXT_REVOCATION_TYPE = 1;
  10789. {$EXTERNALSYM CERT_CONTEXT_REVOCATION_TYPE}
  10790. //+-------------------------------------------------------------------------
  10791. // When the following flag is set, rgpvContext[] consists of a chain
  10792. // of certificates, where rgpvContext[i + 1] is the issuer of rgpvContext[i].
  10793. //--------------------------------------------------------------------------
  10794. CERT_VERIFY_REV_CHAIN_FLAG = $00000001;
  10795. {$EXTERNALSYM CERT_VERIFY_REV_CHAIN_FLAG}
  10796. //+-------------------------------------------------------------------------
  10797. // CERT_VERIFY_CACHE_ONLY_BASED_REVOCATION prevents the revocation handler from
  10798. // accessing any network based resources for revocation checking
  10799. //--------------------------------------------------------------------------
  10800. CERT_VERIFY_CACHE_ONLY_BASED_REVOCATION = $00000002;
  10801. {$EXTERNALSYM CERT_VERIFY_CACHE_ONLY_BASED_REVOCATION}
  10802. //+-------------------------------------------------------------------------
  10803. // CERT_CONTEXT_REVOCATION_TYPE
  10804. //
  10805. // pvContext points to a const CERT_CONTEXT.
  10806. //--------------------------------------------------------------------------
  10807. //+=========================================================================
  10808. // Certificate Helper APIs
  10809. //==========================================================================
  10810. //+-------------------------------------------------------------------------
  10811. // Compare two multiple byte integer blobs to see if they are identical.
  10812. //
  10813. // Before doing the comparison, leading zero bytes are removed from a
  10814. // positive number and leading 0xFF bytes are removed from a negative
  10815. // number.
  10816. //
  10817. // The multiple byte integers are treated as Little Endian. pbData[0] is the
  10818. // least significant byte and pbData[cbData - 1] is the most significant
  10819. // byte.
  10820. //
  10821. // Returns TRUE if the integer blobs are identical after removing leading
  10822. // 0 or 0xFF bytes.
  10823. //--------------------------------------------------------------------------
  10824. function CertCompareIntegerBlob(pInt1, pInt2: PCRYPT_INTEGER_BLOB): BOOL; stdcall;
  10825. {$EXTERNALSYM CertCompareIntegerBlob}
  10826. //+-------------------------------------------------------------------------
  10827. // Compare two certificates to see if they are identical.
  10828. //
  10829. // Since a certificate is uniquely identified by its Issuer and SerialNumber,
  10830. // these are the only fields needing to be compared.
  10831. //
  10832. // Returns TRUE if the certificates are identical.
  10833. //--------------------------------------------------------------------------
  10834. function CertCompareCertificate(dwCertEncodingType: DWORD; pCertId1, pCertId2: PCERT_INFO): BOOL; stdcall;
  10835. {$EXTERNALSYM CertCompareCertificate}
  10836. //+-------------------------------------------------------------------------
  10837. // Compare two certificate names to see if they are identical.
  10838. //
  10839. // Returns TRUE if the names are identical.
  10840. //--------------------------------------------------------------------------
  10841. function CertCompareCertificateName(dwCertEncodingType: DWORD;
  10842. pCertName1: PCERT_NAME_BLOB; pCertName2: PCERT_NAME_BLOB): BOOL; stdcall;
  10843. {$EXTERNALSYM CertCompareCertificateName}
  10844. //+-------------------------------------------------------------------------
  10845. // Compare the attributes in the certificate name with the specified
  10846. // Relative Distinguished Name's (CERT_RDN) array of attributes.
  10847. // The comparison iterates through the CERT_RDN attributes and looks for an
  10848. // attribute match in any of the certificate name's RDNs.
  10849. // Returns TRUE if all the attributes are found and match.
  10850. //
  10851. // The CERT_RDN_ATTR fields can have the following special values:
  10852. // pszObjId == NULL - ignore the attribute object identifier
  10853. // dwValueType == RDN_ANY_TYPE - ignore the value type
  10854. //
  10855. // CERT_CASE_INSENSITIVE_IS_RDN_ATTRS_FLAG should be set to do
  10856. // a case insensitive match. Otherwise, defaults to an exact, case sensitive
  10857. // match.
  10858. //
  10859. // CERT_UNICODE_IS_RDN_ATTRS_FLAG should be set if the pRDN was initialized
  10860. // with unicode strings as for CryptEncodeObject(X509_UNICODE_NAME).
  10861. //--------------------------------------------------------------------------
  10862. function CertIsRDNAttrsInCertificateName(dwCertEncodingType, dwFlags: DWORD;
  10863. pCertName: PCERT_NAME_BLOB; pRDN: PCERT_RDN): BOOL; stdcall;
  10864. {$EXTERNALSYM CertIsRDNAttrsInCertificateName}
  10865. const
  10866. CERT_UNICODE_IS_RDN_ATTRS_FLAG = $1;
  10867. {$EXTERNALSYM CERT_UNICODE_IS_RDN_ATTRS_FLAG}
  10868. CERT_CASE_INSENSITIVE_IS_RDN_ATTRS_FLAG = $2;
  10869. {$EXTERNALSYM CERT_CASE_INSENSITIVE_IS_RDN_ATTRS_FLAG}
  10870. //+-------------------------------------------------------------------------
  10871. // Compare two public keys to see if they are identical.
  10872. //
  10873. // Returns TRUE if the keys are identical.
  10874. //--------------------------------------------------------------------------
  10875. function CertComparePublicKeyInfo(dwCertEncodingType: DWORD;
  10876. pPublicKey1, pPublicKey2: PCERT_PUBLIC_KEY_INFO): BOOL; stdcall;
  10877. {$EXTERNALSYM CertComparePublicKeyInfo}
  10878. //+-------------------------------------------------------------------------
  10879. // Get the public/private key's bit length.
  10880. //
  10881. // Returns 0 if unable to determine the key's length.
  10882. //--------------------------------------------------------------------------
  10883. function CertGetPublicKeyLength(dwCertEncodingType: DWORD;
  10884. pPublicKey: PCERT_PUBLIC_KEY_INFO): DWORD; stdcall;
  10885. {$EXTERNALSYM CertGetPublicKeyLength}
  10886. //+-------------------------------------------------------------------------
  10887. // Verify the signature of a subject certificate or a CRL using the
  10888. // public key info
  10889. //
  10890. // Returns TRUE for a valid signature.
  10891. //
  10892. // hCryptProv specifies the crypto provider to use to verify the signature.
  10893. // It doesn't need to use a private key.
  10894. //--------------------------------------------------------------------------
  10895. function CryptVerifyCertificateSignature(hCryptProv: HCRYPTPROV;
  10896. dwCertEncodingType: DWORD; pbEncoded: LPBYTE; cbEncoded: DWORD;
  10897. pPublicKey: PCERT_PUBLIC_KEY_INFO): BOOL; stdcall;
  10898. {$EXTERNALSYM CryptVerifyCertificateSignature}
  10899. //+-------------------------------------------------------------------------
  10900. // Verify the signature of a subject certificate, CRL, certificate request
  10901. // or keygen request using the issuer's public key.
  10902. //
  10903. // Returns TRUE for a valid signature.
  10904. //
  10905. // The subject can be an encoded blob or a context for a certificate or CRL.
  10906. // For a subject certificate context, if the certificate is missing
  10907. // inheritable PublicKey Algorithm Parameters, the context's
  10908. // CERT_PUBKEY_ALG_PARA_PROP_ID is updated with the issuer's public key
  10909. // algorithm parameters for a valid signature.
  10910. //
  10911. // The issuer can be a pointer to a CERT_PUBLIC_KEY_INFO, certificate
  10912. // context or a chain context.
  10913. //
  10914. // hCryptProv specifies the crypto provider to use to verify the signature.
  10915. // Its private key isn't used. If hCryptProv is NULL, a default
  10916. // provider is picked according to the PublicKey Algorithm OID.
  10917. //--------------------------------------------------------------------------
  10918. function CryptVerifyCertificateSignatureEx(hCryptProv: HCRYPTPROV;
  10919. dwCertEncodingType, dwSubjectType: DWORD; pvSubject: Pointer;
  10920. dwIssuerType: DWORD; pvIssuer: Pointer; dwFlags: DWORD; pvReserved: Pointer): BOOL; stdcall;
  10921. {$EXTERNALSYM CryptVerifyCertificateSignatureEx}
  10922. // Subject Types
  10923. const
  10924. CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB = 1;
  10925. {$EXTERNALSYM CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB}
  10926. // pvSubject :: PCRYPT_DATA_BLOB
  10927. CRYPT_VERIFY_CERT_SIGN_SUBJECT_CERT = 2;
  10928. {$EXTERNALSYM CRYPT_VERIFY_CERT_SIGN_SUBJECT_CERT}
  10929. // pvSubject :: PCCERT_CONTEXT
  10930. CRYPT_VERIFY_CERT_SIGN_SUBJECT_CRL = 3;
  10931. {$EXTERNALSYM CRYPT_VERIFY_CERT_SIGN_SUBJECT_CRL}
  10932. // pvSubject :: PCCRL_CONTEXT
  10933. // Issuer Types
  10934. CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY = 1;
  10935. {$EXTERNALSYM CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY}
  10936. // pvIssuer :: PCERT_PUBLIC_KEY_INFO
  10937. CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT = 2;
  10938. {$EXTERNALSYM CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT}
  10939. // pvIssuer :: PCCERT_CONTEXT
  10940. CRYPT_VERIFY_CERT_SIGN_ISSUER_CHAIN = 3;
  10941. {$EXTERNALSYM CRYPT_VERIFY_CERT_SIGN_ISSUER_CHAIN}
  10942. // pvIssuer :: PCCERT_CHAIN_CONTEXT
  10943. //+-------------------------------------------------------------------------
  10944. // Compute the hash of the "to be signed" information in the encoded
  10945. // signed content (CERT_SIGNED_CONTENT_INFO).
  10946. //
  10947. // hCryptProv specifies the crypto provider to use to compute the hash.
  10948. // It doesn't need to use a private key.
  10949. //--------------------------------------------------------------------------
  10950. function CryptHashToBeSigned(hCryptProv: HCRYPTPROV; dwCertEncodingType: DWORD;
  10951. pbEncoded: LPBYTE; cbEncoded: DWORD; pbComputedHash: LPBYTE;
  10952. var pcbComputedHash: DWORD): BOOL; stdcall;
  10953. {$EXTERNALSYM CryptHashToBeSigned}
  10954. //+-------------------------------------------------------------------------
  10955. // Hash the encoded content.
  10956. //
  10957. // hCryptProv specifies the crypto provider to use to compute the hash.
  10958. // It doesn't need to use a private key.
  10959. //
  10960. // Algid specifies the CAPI hash algorithm to use. If Algid is 0, then, the
  10961. // default hash algorithm (currently SHA1) is used.
  10962. //--------------------------------------------------------------------------
  10963. function CryptHashCertificate(hCryptProv: HCRYPTPROV; Algid: ALG_ID;
  10964. dwFlags: DWORD; pbEncoded: LPBYTE; cbEncoded: DWORD; pbComputedHash: LPBYTE;
  10965. var pcbComputedHash: DWORD): BOOL; stdcall;
  10966. {$EXTERNALSYM CryptHashCertificate}
  10967. //+-------------------------------------------------------------------------
  10968. // Sign the "to be signed" information in the encoded signed content.
  10969. //
  10970. // hCryptProv specifies the crypto provider to use to do the signature.
  10971. // It uses the specified private key.
  10972. //--------------------------------------------------------------------------
  10973. function CryptSignCertificate(hCryptProv: HCRYPTPROV; dwKeySpec: DWORD;
  10974. dwCertEncodingType: DWORD; pbEncodedToBeSigned: LPBYTE; cbEncodedToBeSigned: DWORD;
  10975. pSignatureAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER; pvHashAuxInfo: Pointer;
  10976. pbSignature: LPBYTE; var pcbSignature: DWORD): BOOL; stdcall;
  10977. {$EXTERNALSYM CryptSignCertificate}
  10978. //+-------------------------------------------------------------------------
  10979. // Encode the "to be signed" information. Sign the encoded "to be signed".
  10980. // Encode the "to be signed" and the signature.
  10981. //
  10982. // hCryptProv specifies the crypto provider to use to do the signature.
  10983. // It uses the specified private key.
  10984. //--------------------------------------------------------------------------
  10985. function CryptSignAndEncodeCertificate(hCryptProv: HCRYPTPROV; dwKeySpec: DWORD;
  10986. dwCertEncodingType: DWORD; lpszStructType: LPCSTR; pvStructInfo: Pointer;
  10987. pSignatureAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER; pvHashAuxInfo: Pointer;
  10988. pbEncoded: PBYTE; var pcbEncoded: DWORD): BOOL; stdcall;
  10989. {$EXTERNALSYM CryptSignAndEncodeCertificate}
  10990. //+-------------------------------------------------------------------------
  10991. // Verify the time validity of a certificate.
  10992. //
  10993. // Returns -1 if before NotBefore, +1 if after NotAfter and otherwise 0 for
  10994. // a valid certificate
  10995. //
  10996. // If pTimeToVerify is NULL, uses the current time.
  10997. //--------------------------------------------------------------------------
  10998. function CertVerifyTimeValidity(pTimeToVerify: LPFILETIME; pCertInfo: PCERT_INFO): LONG; stdcall;
  10999. {$EXTERNALSYM CertVerifyTimeValidity}
  11000. //+-------------------------------------------------------------------------
  11001. // Verify the time validity of a CRL.
  11002. //
  11003. // Returns -1 if before ThisUpdate, +1 if after NextUpdate and otherwise 0 for
  11004. // a valid CRL
  11005. //
  11006. // If pTimeToVerify is NULL, uses the current time.
  11007. //--------------------------------------------------------------------------
  11008. function CertVerifyCRLTimeValidity(pTimeToVerify: LPFILETIME; pCrlInfo: PCRL_INFO): LONG; stdcall;
  11009. {$EXTERNALSYM CertVerifyCRLTimeValidity}
  11010. //+-------------------------------------------------------------------------
  11011. // Verify that the subject's time validity nests within the issuer's time
  11012. // validity.
  11013. //
  11014. // Returns TRUE if it nests. Otherwise, returns FALSE.
  11015. //--------------------------------------------------------------------------
  11016. function CertVerifyValidityNesting(pSubjectInfo, pIssuerInfo: PCERT_INFO): BOOL; stdcall;
  11017. {$EXTERNALSYM CertVerifyValidityNesting}
  11018. //+-------------------------------------------------------------------------
  11019. // Verify that the subject certificate isn't on its issuer CRL.
  11020. //
  11021. // Returns true if the certificate isn't on the CRL.
  11022. //--------------------------------------------------------------------------
  11023. function CertVerifyCRLRevocation(dwCertEncodingType: DWORD; pCertId: PCERT_INFO;
  11024. cCrlInfo: DWORD; rgpCrlInfo: PCRL_INFO): BOOL; stdcall;
  11025. {$EXTERNALSYM CertVerifyCRLRevocation}
  11026. //+-------------------------------------------------------------------------
  11027. // Convert the CAPI AlgId to the ASN.1 Object Identifier string
  11028. //
  11029. // Returns NULL if there isn't an ObjId corresponding to the AlgId.
  11030. //--------------------------------------------------------------------------
  11031. function CertAlgIdToOID(dwAlgId: DWORD): LPCSTR; stdcall;
  11032. {$EXTERNALSYM CertAlgIdToOID}
  11033. //+-------------------------------------------------------------------------
  11034. // Convert the ASN.1 Object Identifier string to the CAPI AlgId.
  11035. //
  11036. // Returns 0 if there isn't an AlgId corresponding to the ObjId.
  11037. //--------------------------------------------------------------------------
  11038. function CertOIDToAlgId(pszObjId: LPCSTR): DWORD; stdcall;
  11039. {$EXTERNALSYM CertOIDToAlgId}
  11040. //+-------------------------------------------------------------------------
  11041. // Find an extension identified by its Object Identifier.
  11042. //
  11043. // If found, returns pointer to the extension. Otherwise, returns NULL.
  11044. //--------------------------------------------------------------------------
  11045. function CertFindExtension(pszObjId: LPCSTR; cExtensions: DWORD;
  11046. rgExtensions: PCERT_EXTENSION): PCERT_EXTENSION; stdcall;
  11047. {$EXTERNALSYM CertFindExtension}
  11048. //+-------------------------------------------------------------------------
  11049. // Find the first attribute identified by its Object Identifier.
  11050. //
  11051. // If found, returns pointer to the attribute. Otherwise, returns NULL.
  11052. //--------------------------------------------------------------------------
  11053. function CertFindAttribute(pszObjId: LPCSTR; cAttr: DWORD;
  11054. rgAttr: PCRYPT_ATTRIBUTE): PCRYPT_ATTRIBUTE; stdcall;
  11055. {$EXTERNALSYM CertFindAttribute}
  11056. //+-------------------------------------------------------------------------
  11057. // Find the first CERT_RDN attribute identified by its Object Identifier in
  11058. // the name's list of Relative Distinguished Names.
  11059. //
  11060. // If found, returns pointer to the attribute. Otherwise, returns NULL.
  11061. //--------------------------------------------------------------------------
  11062. function CertFindRDNAttr(pszObjId: LPCSTR; pName: PCERT_NAME_INFO): PCERT_RDN_ATTR; stdcall;
  11063. {$EXTERNALSYM CertFindRDNAttr}
  11064. //+-------------------------------------------------------------------------
  11065. // Get the intended key usage bytes from the certificate.
  11066. //
  11067. // If the certificate doesn't have any intended key usage bytes, returns FALSE
  11068. // and *pbKeyUsage is zeroed. Otherwise, returns TRUE and up through
  11069. // cbKeyUsage bytes are copied into *pbKeyUsage. Any remaining uncopied
  11070. // bytes are zeroed.
  11071. //--------------------------------------------------------------------------
  11072. function CertGetIntendedKeyUsage(dwCertEncodingType: DWORD; pCertInfo: PCERT_INFO;
  11073. pbKeyUsage: LPBYTE; cbKeyUsage: DWORD): BOOL; stdcall;
  11074. {$EXTERNALSYM CertGetIntendedKeyUsage}
  11075. type
  11076. HCRYPTDEFAULTCONTEXT = Pointer;
  11077. {$EXTERNALSYM HCRYPTDEFAULTCONTEXT}
  11078. //+-------------------------------------------------------------------------
  11079. // Install a previously CryptAcquiredContext'ed HCRYPTPROV to be used as
  11080. // a default context.
  11081. //
  11082. // dwDefaultType and pvDefaultPara specify where the default context is used.
  11083. // For example, install the HCRYPTPROV to be used to verify certificate's
  11084. // having szOID_OIWSEC_md5RSA signatures.
  11085. //
  11086. // By default, the installed HCRYPTPROV is only applicable to the current
  11087. // thread. Set CRYPT_DEFAULT_CONTEXT_PROCESS_FLAG to allow the HCRYPTPROV
  11088. // to be used by all threads in the current process.
  11089. //
  11090. // For a successful install, TRUE is returned and *phDefaultContext is
  11091. // updated with the HANDLE to be passed to CryptUninstallDefaultContext.
  11092. //
  11093. // The installed HCRYPTPROVs are stack ordered (the last installed
  11094. // HCRYPTPROV is checked first). All thread installed HCRYPTPROVs are
  11095. // checked before any process HCRYPTPROVs.
  11096. //
  11097. // The installed HCRYPTPROV remains available for default usage until
  11098. // CryptUninstallDefaultContext is called or the thread or process exits.
  11099. //
  11100. // If CRYPT_DEFAULT_CONTEXT_AUTO_RELEASE_FLAG is set, then, the HCRYPTPROV
  11101. // is CryptReleaseContext'ed at thread or process exit. However,
  11102. // not CryptReleaseContext'ed if CryptUninstallDefaultContext is
  11103. // called.
  11104. //--------------------------------------------------------------------------
  11105. function CryptInstallDefaultContext(hCryptProv: HCRYPTPROV; dwDefaultType: DWORD;
  11106. pvDefaultPara: Pointer; dwFlags: DWORD; pvReserved: Pointer;
  11107. var phDefaultContext: HCRYPTDEFAULTCONTEXT): BOOL; stdcall;
  11108. {$EXTERNALSYM CryptInstallDefaultContext}
  11109. // dwFlags
  11110. const
  11111. CRYPT_DEFAULT_CONTEXT_AUTO_RELEASE_FLAG = $00000001;
  11112. {$EXTERNALSYM CRYPT_DEFAULT_CONTEXT_AUTO_RELEASE_FLAG}
  11113. CRYPT_DEFAULT_CONTEXT_PROCESS_FLAG = $00000002;
  11114. {$EXTERNALSYM CRYPT_DEFAULT_CONTEXT_PROCESS_FLAG}
  11115. // List of dwDefaultType's
  11116. CRYPT_DEFAULT_CONTEXT_CERT_SIGN_OID = 1;
  11117. {$EXTERNALSYM CRYPT_DEFAULT_CONTEXT_CERT_SIGN_OID}
  11118. CRYPT_DEFAULT_CONTEXT_MULTI_CERT_SIGN_OID = 2;
  11119. {$EXTERNALSYM CRYPT_DEFAULT_CONTEXT_MULTI_CERT_SIGN_OID}
  11120. //+-------------------------------------------------------------------------
  11121. // CRYPT_DEFAULT_CONTEXT_CERT_SIGN_OID
  11122. //
  11123. // Install a default HCRYPTPROV used to verify a certificate
  11124. // signature. pvDefaultPara points to the szOID of the certificate
  11125. // signature algorithm, for example, szOID_OIWSEC_md5RSA. If
  11126. // pvDefaultPara is NULL, then, the HCRYPTPROV is used to verify all
  11127. // certificate signatures. Note, pvDefaultPara can't be NULL when
  11128. // CRYPT_DEFAULT_CONTEXT_PROCESS_FLAG is set.
  11129. //--------------------------------------------------------------------------
  11130. //+-------------------------------------------------------------------------
  11131. // CRYPT_DEFAULT_CONTEXT_MULTI_CERT_SIGN_OID
  11132. //
  11133. // Same as CRYPT_DEFAULT_CONTEXT_CERT_SIGN_OID. However, the default
  11134. // HCRYPTPROV is to be used for multiple signature szOIDs. pvDefaultPara
  11135. // points to a CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA structure containing
  11136. // an array of szOID pointers.
  11137. //--------------------------------------------------------------------------
  11138. type
  11139. PCRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA = ^CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA;
  11140. {$EXTERNALSYM PCRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA}
  11141. _CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA = record
  11142. cOID: DWORD;
  11143. rgpszOID: LPLPSTR;
  11144. end;
  11145. {$EXTERNALSYM _CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA}
  11146. CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA = _CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA;
  11147. {$EXTERNALSYM CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA}
  11148. TCryptDefaultContextMultiOidPara = CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA;
  11149. PCryptDefaultContextMultiOidPara = PCRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA;
  11150. //+-------------------------------------------------------------------------
  11151. // Uninstall a default context previously installed by
  11152. // CryptInstallDefaultContext.
  11153. //
  11154. // For a default context installed with CRYPT_DEFAULT_CONTEXT_PROCESS_FLAG
  11155. // set, if any other threads are currently using this context,
  11156. // this function will block until they finish.
  11157. //--------------------------------------------------------------------------
  11158. function CryptUninstallDefaultContext(hDefaultContext: HCRYPTDEFAULTCONTEXT;
  11159. dwFlags: DWORD; pvReserved: Pointer): BOOL; stdcall;
  11160. {$EXTERNALSYM CryptUninstallDefaultContext}
  11161. //+-------------------------------------------------------------------------
  11162. // Export the public key info associated with the provider's corresponding
  11163. // private key.
  11164. //
  11165. // Calls CryptExportPublicKeyInfo with pszPublicKeyObjId = szOID_RSA_RSA,
  11166. // dwFlags = 0 and pvAuxInfo = NULL.
  11167. //--------------------------------------------------------------------------
  11168. function CryptExportPublicKeyInfo(hCryptProv: HCRYPTPROV; dwKeySpec: DWORD;
  11169. dwCertEncodingType: DWORD; pInfo: PCERT_PUBLIC_KEY_INFO; var pcbInfo: DWORD): BOOL; stdcall;
  11170. {$EXTERNALSYM CryptExportPublicKeyInfo}
  11171. //+-------------------------------------------------------------------------
  11172. // Export the public key info associated with the provider's corresponding
  11173. // private key.
  11174. //
  11175. // Uses the dwCertEncodingType and pszPublicKeyObjId to call the
  11176. // installable CRYPT_OID_EXPORT_PUBLIC_KEY_INFO_FUNC. The called function
  11177. // has the same signature as CryptExportPublicKeyInfoEx.
  11178. //
  11179. // If unable to find an installable OID function for the pszPublicKeyObjId,
  11180. // attempts to export as a RSA Public Key (szOID_RSA_RSA).
  11181. //
  11182. // The dwFlags and pvAuxInfo aren't used for szOID_RSA_RSA.
  11183. //--------------------------------------------------------------------------
  11184. const
  11185. CRYPT_OID_EXPORT_PUBLIC_KEY_INFO_FUNC = 'CryptDllExportPublicKeyInfoEx';
  11186. {$EXTERNALSYM CRYPT_OID_EXPORT_PUBLIC_KEY_INFO_FUNC}
  11187. function CryptExportPublicKeyInfoEx(hCryptProv: HCRYPTPROV; dwKeySpec: DWORD;
  11188. dwCertEncodingType: DWORD; pszPublicKeyObjId: LPSTR; dwFlags: DWORD;
  11189. pvAuxInfo: Pointer; pInfo: PCERT_PUBLIC_KEY_INFO; var pcbInfo: DWORD): BOOL; stdcall;
  11190. {$EXTERNALSYM CryptExportPublicKeyInfoEx}
  11191. //+-------------------------------------------------------------------------
  11192. // Convert and import the public key info into the provider and return a
  11193. // handle to the public key.
  11194. //
  11195. // Calls CryptImportPublicKeyInfoEx with aiKeyAlg = 0, dwFlags = 0 and
  11196. // pvAuxInfo = NULL.
  11197. //--------------------------------------------------------------------------
  11198. function CryptImportPublicKeyInfo(hCryptProv: HCRYPTPROV; dwCertEncodingType: DWORD;
  11199. pInfo: PCERT_PUBLIC_KEY_INFO; var phKey: HCRYPTKEY): BOOL; stdcall;
  11200. {$EXTERNALSYM CryptImportPublicKeyInfo}
  11201. //+-------------------------------------------------------------------------
  11202. // Convert and import the public key info into the provider and return a
  11203. // handle to the public key.
  11204. //
  11205. // Uses the dwCertEncodingType and pInfo->Algorithm.pszObjId to call the
  11206. // installable CRYPT_OID_IMPORT_PUBLIC_KEY_INFO_FUNC. The called function
  11207. // has the same signature as CryptImportPublicKeyInfoEx.
  11208. //
  11209. // If unable to find an installable OID function for the pszObjId,
  11210. // attempts to import as a RSA Public Key (szOID_RSA_RSA).
  11211. //
  11212. // For szOID_RSA_RSA: aiKeyAlg may be set to CALG_RSA_SIGN or CALG_RSA_KEYX.
  11213. // Defaults to CALG_RSA_KEYX. The dwFlags and pvAuxInfo aren't used.
  11214. //--------------------------------------------------------------------------
  11215. const
  11216. CRYPT_OID_IMPORT_PUBLIC_KEY_INFO_FUNC = 'CryptDllImportPublicKeyInfoEx';
  11217. {$EXTERNALSYM CRYPT_OID_IMPORT_PUBLIC_KEY_INFO_FUNC}
  11218. function CryptImportPublicKeyInfoEx(hCryptProv: HCRYPTPROV; dwCertEncodingType: DWORD;
  11219. pInfo: PCERT_PUBLIC_KEY_INFO; aiKeyAlg: ALG_ID; dwFlags: DWORD; pvAuxInfo: Pointer;
  11220. var phKey: HCRYPTKEY): BOOL; stdcall;
  11221. {$EXTERNALSYM CryptImportPublicKeyInfoEx}
  11222. //+-------------------------------------------------------------------------
  11223. // Acquire a HCRYPTPROV handle and dwKeySpec for the specified certificate
  11224. // context. Uses the certificate's CERT_KEY_PROV_INFO_PROP_ID property.
  11225. // The returned HCRYPTPROV handle may optionally be cached using the
  11226. // certificate's CERT_KEY_CONTEXT_PROP_ID property.
  11227. //
  11228. // If CRYPT_ACQUIRE_CACHE_FLAG is set, then, if an already acquired and
  11229. // cached HCRYPTPROV exists for the certificate, its returned. Otherwise,
  11230. // a HCRYPTPROV is acquired and then cached via the certificate's
  11231. // CERT_KEY_CONTEXT_PROP_ID.
  11232. //
  11233. // The CRYPT_ACQUIRE_USE_PROV_INFO_FLAG can be set to use the dwFlags field of
  11234. // the certificate's CERT_KEY_PROV_INFO_PROP_ID property's CRYPT_KEY_PROV_INFO
  11235. // data structure to determine if the returned HCRYPTPROV should be cached.
  11236. // HCRYPTPROV caching is enabled if the CERT_SET_KEY_CONTEXT_PROP_ID flag was
  11237. // set.
  11238. //
  11239. // If CRYPT_ACQUIRE_COMPARE_KEY_FLAG is set, then,
  11240. // the public key in the certificate is compared with the public
  11241. // key returned by the cryptographic provider. If the keys don't match, the
  11242. // acquire fails and LastError is set to NTE_BAD_PUBLIC_KEY. Note, if
  11243. // a cached HCRYPTPROV is returned, the comparison isn't done. We assume the
  11244. // comparison was done on the initial acquire.
  11245. //
  11246. // *pfCallerFreeProv is returned set to FALSE for:
  11247. // - Acquire or public key comparison fails.
  11248. // - CRYPT_ACQUIRE_CACHE_FLAG is set.
  11249. // - CRYPT_ACQUIRE_USE_PROV_INFO_FLAG is set AND
  11250. // CERT_SET_KEY_CONTEXT_PROP_ID flag is set in the dwFlags field of the
  11251. // certificate's CERT_KEY_PROV_INFO_PROP_ID property's
  11252. // CRYPT_KEY_PROV_INFO data structure.
  11253. // When *pfCallerFreeProv is FALSE, the caller must not release. The
  11254. // returned HCRYPTPROV will be released on the last free of the certificate
  11255. // context.
  11256. //
  11257. // Otherwise, *pfCallerFreeProv is TRUE and the returned HCRYPTPROV must
  11258. // be released by the caller by calling CryptReleaseContext.
  11259. //--------------------------------------------------------------------------
  11260. function CryptAcquireCertificatePrivateKey(pCert: PCCERT_CONTEXT; dwFlags: DWORD;
  11261. pvReserved: Pointer; var phCryptProv: HCRYPTPROV; pdwKeySpec: LPDWORD;
  11262. pfCallerFreeProv: PBOOL): BOOL; stdcall;
  11263. {$EXTERNALSYM CryptAcquireCertificatePrivateKey}
  11264. const
  11265. CRYPT_ACQUIRE_CACHE_FLAG = $1;
  11266. {$EXTERNALSYM CRYPT_ACQUIRE_CACHE_FLAG}
  11267. CRYPT_ACQUIRE_USE_PROV_INFO_FLAG = $2;
  11268. {$EXTERNALSYM CRYPT_ACQUIRE_USE_PROV_INFO_FLAG}
  11269. CRYPT_ACQUIRE_COMPARE_KEY_FLAG = $4;
  11270. {$EXTERNALSYM CRYPT_ACQUIRE_COMPARE_KEY_FLAG}
  11271. //+-------------------------------------------------------------------------
  11272. // Enumerates the cryptographic providers and their containers to find the
  11273. // private key corresponding to the certificate's public key. For a match,
  11274. // the certificate's CERT_KEY_PROV_INFO_PROP_ID property is updated.
  11275. //
  11276. // If the CERT_KEY_PROV_INFO_PROP_ID is already set, then, its checked to
  11277. // see if it matches the provider's public key. For a match, the above
  11278. // enumeration is skipped.
  11279. //
  11280. // By default both the user and machine key containers are searched.
  11281. // The CRYPT_FIND_USER_KEYSET_FLAG or CRYPT_FIND_MACHINE_KEYSET_FLAG
  11282. // can be set in dwFlags to restrict the search to either of the containers.
  11283. //
  11284. // If a container isn't found, returns FALSE with LastError set to
  11285. // NTE_NO_KEY.
  11286. //--------------------------------------------------------------------------
  11287. function CryptFindCertificateKeyProvInfo(pCert: PCCERT_CONTEXT; dwFlags: DWORD;
  11288. pvReserved: Pointer): BOOL; stdcall;
  11289. {$EXTERNALSYM CryptFindCertificateKeyProvInfo}
  11290. const
  11291. CRYPT_FIND_USER_KEYSET_FLAG = $1;
  11292. {$EXTERNALSYM CRYPT_FIND_USER_KEYSET_FLAG}
  11293. CRYPT_FIND_MACHINE_KEYSET_FLAG = $2;
  11294. {$EXTERNALSYM CRYPT_FIND_MACHINE_KEYSET_FLAG}
  11295. //+-------------------------------------------------------------------------
  11296. // This is the prototype for the installable function which is called to
  11297. // actually import a key into a CSP. an installable of this type is called
  11298. // from CryptImportPKCS8. the algorithm OID of the private key is used
  11299. // to look up the proper installable function to call.
  11300. //
  11301. // hCryptProv - the provider to import the key to
  11302. // pPrivateKeyInfo - describes the key to be imported
  11303. // dwFlags - The available flags are:
  11304. // CRYPT_EXPORTABLE
  11305. // this flag is used when importing private keys, for a full
  11306. // explanation please see the documentation for CryptImportKey.
  11307. // pvAuxInfo - reserved for future, must be NULL
  11308. //--------------------------------------------------------------------------
  11309. type
  11310. PFN_IMPORT_PRIV_KEY_FUNC = function(hCryptProv: HCRYPTPROV;
  11311. pPrivateKeyInfo: PCRYPT_PRIVATE_KEY_INFO; dwFlags: DWORD;
  11312. pvAuxInfo: Pointer): BOOL; stdcall;
  11313. {$EXTERNALSYM PFN_IMPORT_PRIV_KEY_FUNC}
  11314. PFnImportPrivKeyFunc = PFN_IMPORT_PRIV_KEY_FUNC;
  11315. const
  11316. CRYPT_OID_IMPORT_PRIVATE_KEY_INFO_FUNC = 'CryptDllImportPrivateKeyInfoEx';
  11317. {$EXTERNALSYM CRYPT_OID_IMPORT_PRIVATE_KEY_INFO_FUNC}
  11318. //+-------------------------------------------------------------------------
  11319. // Convert (from PKCS8 format) and import the private key into a provider
  11320. // and return a handle to the provider as well as the KeySpec used to import to.
  11321. //
  11322. // This function will call the PRESOLVE_HCRYPTPROV_FUNC in the
  11323. // privateKeyAndParams to obtain a handle of provider to import the key to.
  11324. // if the PRESOLVE_HCRYPTPROV_FUNC is NULL then the default provider will be used.
  11325. //
  11326. // privateKeyAndParams - private key blob and corresponding parameters
  11327. // dwFlags - The available flags are:
  11328. // CRYPT_EXPORTABLE
  11329. // this flag is used when importing private keys, for a full
  11330. // explanation please see the documentation for CryptImportKey.
  11331. // phCryptProv - filled in with the handle of the provider the key was
  11332. // imported to, the caller is responsible for freeing it
  11333. // pvAuxInfo - This parameter is reserved for future use and should be set
  11334. // to NULL in the interim.
  11335. //--------------------------------------------------------------------------
  11336. function CryptImportPKCS8(sImportParams: CRYPT_PKCS8_IMPORT_PARAMS; dwFlags: DWORD;
  11337. phCryptProv: PHCRYPTPROV; pvAuxInfo: Pointer): BOOL; stdcall;
  11338. {$EXTERNALSYM CryptImportPKCS8}
  11339. //+-------------------------------------------------------------------------
  11340. // this is the prototype for installable functions for exporting the private key
  11341. //--------------------------------------------------------------------------
  11342. type
  11343. PFN_EXPORT_PRIV_KEY_FUNC = function(hCryptProv: HCRYPTPROV; dwKeySpec: DWORD;
  11344. pszPrivateKeyObjId: LPSTR; dwFlags: DWORD; pvAuxInfo: Pointer;
  11345. var pPrivateKeyInfo: CRYPT_PRIVATE_KEY_INFO; var pcbPrivateKeyBlob: DWORD): BOOL; stdcall;
  11346. {$EXTERNALSYM PFN_EXPORT_PRIV_KEY_FUNC}
  11347. PfnExportPrivKeyFunc = PFN_EXPORT_PRIV_KEY_FUNC;
  11348. const
  11349. CRYPT_OID_EXPORT_PRIVATE_KEY_INFO_FUNC = 'CryptDllExportPrivateKeyInfoEx';
  11350. {$EXTERNALSYM CRYPT_OID_EXPORT_PRIVATE_KEY_INFO_FUNC}
  11351. CRYPT_DELETE_KEYSET = $0001;
  11352. {$EXTERNALSYM CRYPT_DELETE_KEYSET}
  11353. //+-------------------------------------------------------------------------
  11354. // CryptExportPKCS8 -- superseded by CryptExportPKCS8Ex
  11355. //
  11356. // Export the private key in PKCS8 format
  11357. //--------------------------------------------------------------------------
  11358. function CryptExportPKCS8(hCryptProv: HCRYPTPROV; dwKeySpec: DWORD;
  11359. pszPrivateKeyObjId: LPSTR; dwFlags: DWORD; pvAuxInfo: Pointer;
  11360. pbPrivateKeyBlob: LPBYTE; var pcbPrivateKeyBlob: DWORD): BOOL; stdcall;
  11361. {$EXTERNALSYM CryptExportPKCS8}
  11362. //+-------------------------------------------------------------------------
  11363. // CryptExportPKCS8Ex
  11364. //
  11365. // Export the private key in PKCS8 format
  11366. //
  11367. //
  11368. // Uses the pszPrivateKeyObjId to call the
  11369. // installable CRYPT_OID_EXPORT_PRIVATE_KEY_INFO_FUNC. The called function
  11370. // has the signature defined by PFN_EXPORT_PRIV_KEY_FUNC.
  11371. //
  11372. // If unable to find an installable OID function for the pszPrivateKeyObjId,
  11373. // attempts to export as a RSA Private Key (szOID_RSA_RSA).
  11374. //
  11375. // psExportParams - specifies information about the key to export
  11376. // dwFlags - The flag values. None currently supported
  11377. // pvAuxInfo - This parameter is reserved for future use and should be set to
  11378. // NULL in the interim.
  11379. // pbPrivateKeyBlob - A pointer to the private key blob. It will be encoded
  11380. // as a PKCS8 PrivateKeyInfo.
  11381. // pcbPrivateKeyBlob - A pointer to a DWORD that contains the size, in bytes,
  11382. // of the private key blob being exported.
  11383. //+-------------------------------------------------------------------------
  11384. function CryptExportPKCS8Ex(psExportParams: PCRYPT_PKCS8_EXPORT_PARAMS;
  11385. dwFlags: DWORD; pvAuxInfo: Pointer; pbPrivateKeyBlob: LPBYTE;
  11386. var pcbPrivateKeyBlob: DWORD): BOOL; stdcall;
  11387. {$EXTERNALSYM CryptExportPKCS8Ex}
  11388. //+-------------------------------------------------------------------------
  11389. // Compute the hash of the encoded public key info.
  11390. //
  11391. // The public key info is encoded and then hashed.
  11392. //--------------------------------------------------------------------------
  11393. function CryptHashPublicKeyInfo(hCryptProv: HCRYPTPROV; Algid: ALG_ID;
  11394. dwFlags: DWORD; dwCertEncodingType: DWORD; pInfo: PCERT_PUBLIC_KEY_INFO;
  11395. pbComputedHash: LPBYTE; var pcbComputedHash: DWORD): BOOL; stdcall;
  11396. {$EXTERNALSYM CryptHashPublicKeyInfo}
  11397. //+-------------------------------------------------------------------------
  11398. // Convert a Name Value to a null terminated char string
  11399. //
  11400. // Returns the number of characters converted including the terminating null
  11401. // character. If psz is NULL or csz is 0, returns the required size of the
  11402. // destination string (including the terminating null char).
  11403. //
  11404. // If psz != NULL && csz != 0, returned psz is always NULL terminated.
  11405. //
  11406. // Note: csz includes the NULL char.
  11407. //--------------------------------------------------------------------------
  11408. function CertRDNValueToStrA(dwValueType: DWORD; pValue: PCERT_RDN_VALUE_BLOB;
  11409. psz: LPSTR; csz: DWORD): DWORD; stdcall;
  11410. {$EXTERNALSYM CertRDNValueToStrA}
  11411. //+-------------------------------------------------------------------------
  11412. // Convert a Name Value to a null terminated char string
  11413. //
  11414. // Returns the number of characters converted including the terminating null
  11415. // character. If psz is NULL or csz is 0, returns the required size of the
  11416. // destination string (including the terminating null char).
  11417. //
  11418. // If psz != NULL && csz != 0, returned psz is always NULL terminated.
  11419. //
  11420. // Note: csz includes the NULL char.
  11421. //--------------------------------------------------------------------------
  11422. function CertRDNValueToStrW(dwValueType: DWORD; pValue: PCERT_RDN_VALUE_BLOB;
  11423. psz: LPWSTR; csz: DWORD): DWORD; stdcall;
  11424. {$EXTERNALSYM CertRDNValueToStrW}
  11425. function CertRDNValueToStr(dwValueType: DWORD; pValue: PCERT_RDN_VALUE_BLOB;
  11426. psz: LPTSTR; csz: DWORD): DWORD; stdcall;
  11427. {$EXTERNALSYM CertRDNValueToStr}
  11428. //+-------------------------------------------------------------------------
  11429. // Convert the certificate name blob to a null terminated char string.
  11430. //
  11431. // Follows the string representation of distinguished names specified in
  11432. // RFC 1779. (Note, added double quoting "" for embedded quotes, quote
  11433. // empty strings and don't quote strings containing consecutive spaces).
  11434. // RDN values of type CERT_RDN_ENCODED_BLOB or CERT_RDN_OCTET_STRING are
  11435. // formatted in hexadecimal (e.g. #0A56CF).
  11436. //
  11437. // The name string is formatted according to the dwStrType:
  11438. // CERT_SIMPLE_NAME_STR
  11439. // The object identifiers are discarded. CERT_RDN entries are separated
  11440. // by ", ". Multiple attributes per CERT_RDN are separated by " + ".
  11441. // For example:
  11442. // Microsoft, Joe Cool + Programmer
  11443. // CERT_OID_NAME_STR
  11444. // The object identifiers are included with a "=" separator from their
  11445. // attribute value. CERT_RDN entries are separated by ", ".
  11446. // Multiple attributes per CERT_RDN are separated by " + ". For example:
  11447. // 2.5.4.11=Microsoft, 2.5.4.3=Joe Cool + 2.5.4.12=Programmer
  11448. // CERT_X500_NAME_STR
  11449. // The object identifiers are converted to their X500 key name. Otherwise,
  11450. // same as CERT_OID_NAME_STR. If the object identifier doesn't have
  11451. // a corresponding X500 key name, then, the object identifier is used with
  11452. // a "OID." prefix. For example:
  11453. // OU=Microsoft, CN=Joe Cool + T=Programmer, OID.1.2.3.4.5.6=Unknown
  11454. //
  11455. // We quote the RDN value if it contains leading or trailing whitespace
  11456. // or one of the following characters: ",", "+", "=", """, "\n", "<", ">",
  11457. // "#" or ";". The quoting character is ". If the the RDN Value contains
  11458. // a " it is double quoted (""). For example:
  11459. // OU=" Microsoft", CN="Joe ""Cool""" + T="Programmer, Manager"
  11460. //
  11461. // CERT_NAME_STR_SEMICOLON_FLAG can be or'ed into dwStrType to replace
  11462. // the ", " separator with a "; " separator.
  11463. //
  11464. // CERT_NAME_STR_CRLF_FLAG can be or'ed into dwStrType to replace
  11465. // the ", " separator with a "\r\n" separator.
  11466. //
  11467. // CERT_NAME_STR_NO_PLUS_FLAG can be or'ed into dwStrType to replace the
  11468. // " + " separator with a single space, " ".
  11469. //
  11470. // CERT_NAME_STR_NO_QUOTING_FLAG can be or'ed into dwStrType to inhibit
  11471. // the above quoting.
  11472. //
  11473. // CERT_NAME_STR_REVERSE_FLAG can be or'ed into dwStrType to reverse the
  11474. // order of the RDNs before converting to the string.
  11475. //
  11476. // By default, CERT_RDN_T61_STRING encoded values are initially decoded
  11477. // as UTF8. If the UTF8 decoding fails, then, decoded as 8 bit characters.
  11478. // CERT_NAME_STR_DISABLE_IE4_UTF8_FLAG can be or'ed into dwStrType to
  11479. // skip the initial attempt to decode as UTF8.
  11480. //
  11481. // Returns the number of characters converted including the terminating null
  11482. // character. If psz is NULL or csz is 0, returns the required size of the
  11483. // destination string (including the terminating null char).
  11484. //
  11485. // If psz != NULL && csz != 0, returned psz is always NULL terminated.
  11486. //
  11487. // Note: csz includes the NULL char.
  11488. //--------------------------------------------------------------------------
  11489. //+-------------------------------------------------------------------------
  11490. //--------------------------------------------------------------------------
  11491. function CertNameToStrA(dwCertEncodingType: DWORD; pName: PCERT_NAME_BLOB;
  11492. dwStrType: DWORD; psz: LPSTR; csz: DWORD): DWORD; stdcall;
  11493. {$EXTERNALSYM CertNameToStrA}
  11494. //+-------------------------------------------------------------------------
  11495. //--------------------------------------------------------------------------
  11496. function CertNameToStrW(dwCertEncodingType: DWORD; pName: PCERT_NAME_BLOB;
  11497. dwStrType: DWORD; psz: LPWSTR; csz: DWORD): DWORD; stdcall;
  11498. {$EXTERNALSYM CertNameToStrW}
  11499. function CertNameToStr(dwCertEncodingType: DWORD; pName: PCERT_NAME_BLOB;
  11500. dwStrType: DWORD; psz: LPTSTR; csz: DWORD): DWORD; stdcall;
  11501. {$EXTERNALSYM CertNameToStr}
  11502. //+-------------------------------------------------------------------------
  11503. // Certificate name string types
  11504. //--------------------------------------------------------------------------
  11505. const
  11506. CERT_SIMPLE_NAME_STR = 1;
  11507. {$EXTERNALSYM CERT_SIMPLE_NAME_STR}
  11508. CERT_OID_NAME_STR = 2;
  11509. {$EXTERNALSYM CERT_OID_NAME_STR}
  11510. CERT_X500_NAME_STR = 3;
  11511. {$EXTERNALSYM CERT_X500_NAME_STR}
  11512. //+-------------------------------------------------------------------------
  11513. // Certificate name string type flags OR'ed with the above types
  11514. //--------------------------------------------------------------------------
  11515. CERT_NAME_STR_SEMICOLON_FLAG = $40000000;
  11516. {$EXTERNALSYM CERT_NAME_STR_SEMICOLON_FLAG}
  11517. CERT_NAME_STR_NO_PLUS_FLAG = $20000000;
  11518. {$EXTERNALSYM CERT_NAME_STR_NO_PLUS_FLAG}
  11519. CERT_NAME_STR_NO_QUOTING_FLAG = $10000000;
  11520. {$EXTERNALSYM CERT_NAME_STR_NO_QUOTING_FLAG}
  11521. CERT_NAME_STR_CRLF_FLAG = $08000000;
  11522. {$EXTERNALSYM CERT_NAME_STR_CRLF_FLAG}
  11523. CERT_NAME_STR_COMMA_FLAG = $04000000;
  11524. {$EXTERNALSYM CERT_NAME_STR_COMMA_FLAG}
  11525. CERT_NAME_STR_REVERSE_FLAG = $02000000;
  11526. {$EXTERNALSYM CERT_NAME_STR_REVERSE_FLAG}
  11527. CERT_NAME_STR_DISABLE_IE4_UTF8_FLAG = $00010000;
  11528. {$EXTERNALSYM CERT_NAME_STR_DISABLE_IE4_UTF8_FLAG}
  11529. CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG = $00020000;
  11530. {$EXTERNALSYM CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG}
  11531. CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG = $00040000;
  11532. {$EXTERNALSYM CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG}
  11533. //+-------------------------------------------------------------------------
  11534. // Convert the null terminated X500 string to an encoded certificate name.
  11535. //
  11536. // The input string is expected to be formatted the same as the output
  11537. // from the above CertNameToStr API.
  11538. //
  11539. // The CERT_SIMPLE_NAME_STR type isn't supported. Otherwise, when dwStrType
  11540. // is set to 0, CERT_OID_NAME_STR or CERT_X500_NAME_STR, allow either a
  11541. // case insensitive X500 key (CN=), case insensitive "OID." prefixed
  11542. // object identifier (OID.1.2.3.4.5.6=) or an object identifier (1.2.3.4=).
  11543. //
  11544. // If no flags are OR'ed into dwStrType, then, allow "," or ";" as RDN
  11545. // separators and "+" as the multiple RDN value separator. Quoting is
  11546. // supported. A quote may be included in a quoted value by double quoting,
  11547. // for example (CN="Joe ""Cool"""). A value starting with a "#" is treated
  11548. // as ascii hex and converted to a CERT_RDN_OCTET_STRING. Embedded whitespace
  11549. // is skipped (1.2.3 = # AB CD 01 is the same as 1.2.3=#ABCD01).
  11550. //
  11551. // Whitespace surrounding the keys, object identifers and values is removed.
  11552. //
  11553. // CERT_NAME_STR_COMMA_FLAG can be or'ed into dwStrType to only allow the
  11554. // "," as the RDN separator.
  11555. //
  11556. // CERT_NAME_STR_SEMICOLON_FLAG can be or'ed into dwStrType to only allow the
  11557. // ";" as the RDN separator.
  11558. //
  11559. // CERT_NAME_STR_CRLF_FLAG can be or'ed into dwStrType to only allow
  11560. // "\r" or "\n" as the RDN separator.
  11561. //
  11562. // CERT_NAME_STR_NO_PLUS_FLAG can be or'ed into dwStrType to ignore "+"
  11563. // as a separator and not allow multiple values per RDN.
  11564. //
  11565. // CERT_NAME_STR_NO_QUOTING_FLAG can be or'ed into dwStrType to inhibit
  11566. // quoting.
  11567. //
  11568. // CERT_NAME_STR_REVERSE_FLAG can be or'ed into dwStrType to reverse the
  11569. // order of the RDNs after converting from the string and before encoding.
  11570. //
  11571. // CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG can be or'ed into dwStrType to
  11572. // to select the CERT_RDN_T61_STRING encoded value type instead of
  11573. // CERT_RDN_UNICODE_STRING if all the UNICODE characters are <= 0xFF.
  11574. //
  11575. // CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG can be or'ed into dwStrType to
  11576. // to select the CERT_RDN_UTF8_STRING encoded value type instead of
  11577. // CERT_RDN_UNICODE_STRING.
  11578. //
  11579. // Support the following X500 Keys:
  11580. //
  11581. // Key Object Identifier RDN Value Type(s)
  11582. // --- ----------------- -----------------
  11583. // CN szOID_COMMON_NAME Printable, Unicode
  11584. // L szOID_LOCALITY_NAME Printable, Unicode
  11585. // O szOID_ORGANIZATION_NAME Printable, Unicode
  11586. // OU szOID_ORGANIZATIONAL_UNIT_NAME Printable, Unicode
  11587. // E szOID_RSA_emailAddr Only IA5
  11588. // Email szOID_RSA_emailAddr Only IA5
  11589. // C szOID_COUNTRY_NAME Only Printable
  11590. // S szOID_STATE_OR_PROVINCE_NAME Printable, Unicode
  11591. // ST szOID_STATE_OR_PROVINCE_NAME Printable, Unicode
  11592. // STREET szOID_STREET_ADDRESS Printable, Unicode
  11593. // T szOID_TITLE Printable, Unicode
  11594. // Title szOID_TITLE Printable, Unicode
  11595. // G szOID_GIVEN_NAME Printable, Unicode
  11596. // GivenName szOID_GIVEN_NAME Printable, Unicode
  11597. // I szOID_INITIALS Printable, Unicode
  11598. // Initials szOID_INITIALS Printable, Unicode
  11599. // SN szOID_SUR_NAME Printable, Unicode
  11600. // DC szOID_DOMAIN_COMPONENT IA5, UTF8
  11601. //
  11602. // Note, T61 is selected instead of Unicode if
  11603. // CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG is set and all the unicode
  11604. // characters are <= 0xFF.
  11605. //
  11606. // Note, UTF8 is selected instead of Unicode if
  11607. // CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG is set.
  11608. //
  11609. // Returns TRUE if successfully parsed the input string and encoded
  11610. // the name.
  11611. //
  11612. // If the input string is detected to be invalid, *ppszError is updated
  11613. // to point to the beginning of the invalid character sequence. Otherwise,
  11614. // *ppszError is set to NULL. *ppszError is updated with a non-NULL pointer
  11615. // for the following errors:
  11616. // CRYPT_E_INVALID_X500_STRING
  11617. // CRYPT_E_INVALID_NUMERIC_STRING
  11618. // CRYPT_E_INVALID_PRINTABLE_STRING
  11619. // CRYPT_E_INVALID_IA5_STRING
  11620. //
  11621. // ppszError can be set to NULL if not interested in getting a pointer
  11622. // to the invalid character sequence.
  11623. //--------------------------------------------------------------------------
  11624. //+-------------------------------------------------------------------------
  11625. //--------------------------------------------------------------------------
  11626. function CertStrToNameA(dwCertEncodingType: DWORD; pszX500: LPCSTR;
  11627. dwStrType: DWORD; pvReserved: Pointer; pbEncoded: LPBYTE; var pcbEncoded: DWORD;
  11628. ppszError: LPLPCSTR): BOOL; stdcall;
  11629. {$EXTERNALSYM CertStrToNameA}
  11630. function CertStrToNameW(dwCertEncodingType: DWORD; pszX500: LPCWSTR;
  11631. dwStrType: DWORD; pvReserved: Pointer; pbEncoded: LPBYTE; var pcbEncoded: DWORD;
  11632. ppszError: LPLPCWSTR): BOOL; stdcall;
  11633. {$EXTERNALSYM CertStrToNameW}
  11634. function CertStrToName(dwCertEncodingType: DWORD; pszX500: LPCTSTR;
  11635. dwStrType: DWORD; pvReserved: Pointer; pbEncoded: LPBYTE; var pcbEncoded: DWORD;
  11636. ppszError: LPLPCTSTR): BOOL; stdcall;
  11637. {$EXTERNALSYM CertStrToName}
  11638. //+-------------------------------------------------------------------------
  11639. // Get the subject or issuer name from the certificate and
  11640. // according to the specified format type, convert to a null terminated
  11641. // character string.
  11642. //
  11643. // CERT_NAME_ISSUER_FLAG can be set to get the issuer's name. Otherwise,
  11644. // gets the subject's name.
  11645. //
  11646. // By default, CERT_RDN_T61_STRING encoded values are initially decoded
  11647. // as UTF8. If the UTF8 decoding fails, then, decoded as 8 bit characters.
  11648. // CERT_NAME_DISABLE_IE4_UTF8_FLAG can be set in dwFlags to
  11649. // skip the initial attempt to decode as UTF8.
  11650. //
  11651. // The name string is formatted according to the dwType:
  11652. // CERT_NAME_EMAIL_TYPE
  11653. // If the certificate has a Subject Alternative Name extension (for
  11654. // issuer, Issuer Alternative Name), searches for first rfc822Name choice.
  11655. // If the rfc822Name choice isn't found in the extension, searches the
  11656. // Subject Name field for the Email OID, "1.2.840.113549.1.9.1".
  11657. // If the rfc822Name or Email OID is found, returns the string. Otherwise,
  11658. // returns an empty string (returned character count is 1).
  11659. // CERT_NAME_RDN_TYPE
  11660. // Converts the Subject Name blob by calling CertNameToStr. pvTypePara
  11661. // points to a DWORD containing the dwStrType passed to CertNameToStr.
  11662. // If the Subject Name field is empty and the certificate has a
  11663. // Subject Alternative Name extension, searches for and converts
  11664. // the first directoryName choice.
  11665. // CERT_NAME_ATTR_TYPE
  11666. // pvTypePara points to the Object Identifier specifying the name attribute
  11667. // to be returned. For example, to get the CN,
  11668. // pvTypePara = szOID_COMMON_NAME ("2.5.4.3"). Searches, the Subject Name
  11669. // field for the attribute.
  11670. // If the Subject Name field is empty and the certificate has a
  11671. // Subject Alternative Name extension, checks for
  11672. // the first directoryName choice and searches it.
  11673. //
  11674. // Note, searches the RDNs in reverse order.
  11675. //
  11676. // CERT_NAME_SIMPLE_DISPLAY_TYPE
  11677. // Iterates through the following list of name attributes and searches
  11678. // the Subject Name and then the Subject Alternative Name extension
  11679. // for the first occurrence of:
  11680. // szOID_COMMON_NAME ("2.5.4.3")
  11681. // szOID_ORGANIZATIONAL_UNIT_NAME ("2.5.4.11")
  11682. // szOID_ORGANIZATION_NAME ("2.5.4.10")
  11683. // szOID_RSA_emailAddr ("1.2.840.113549.1.9.1")
  11684. //
  11685. // If none of the above attributes is found, then, searches the
  11686. // Subject Alternative Name extension for a rfc822Name choice.
  11687. //
  11688. // If still no match, then, returns the first attribute.
  11689. //
  11690. // Note, like CERT_NAME_ATTR_TYPE, searches the RDNs in reverse order.
  11691. //
  11692. // CERT_NAME_FRIENDLY_DISPLAY_TYPE
  11693. // First checks if the certificate has a CERT_FRIENDLY_NAME_PROP_ID
  11694. // property. If it does, then, this property is returned. Otherwise,
  11695. // returns the above CERT_NAME_SIMPLE_DISPLAY_TYPE.
  11696. //
  11697. // Returns the number of characters converted including the terminating null
  11698. // character. If pwszNameString is NULL or cchNameString is 0, returns the
  11699. // required size of the destination string (including the terminating null
  11700. // char). If the specified name type isn't found. returns an empty string
  11701. // with a returned character count of 1.
  11702. //
  11703. // If pwszNameString != NULL && cwszNameString != 0, returned pwszNameString
  11704. // is always NULL terminated.
  11705. //
  11706. // Note: cchNameString includes the NULL char.
  11707. //--------------------------------------------------------------------------
  11708. //+-------------------------------------------------------------------------
  11709. //--------------------------------------------------------------------------
  11710. function CertGetNameStringA(pCertContext: PCCERT_CONTEXT; dwType, dwFlags: DWORD;
  11711. pvTypePara: Pointer; pszNameString: LPSTR; cchNameString: DWORD): DWORD; stdcall;
  11712. {$EXTERNALSYM CertGetNameStringA}
  11713. function CertGetNameStringW(pCertContext: PCCERT_CONTEXT; dwType, dwFlags: DWORD;
  11714. pvTypePara: Pointer; pszNameString: LPWSTR; cchNameString: DWORD): DWORD; stdcall;
  11715. {$EXTERNALSYM CertGetNameStringW}
  11716. function CertGetNameString(pCertContext: PCCERT_CONTEXT; dwType, dwFlags: DWORD;
  11717. pvTypePara: Pointer; pszNameString: LPTSTR; cchNameString: DWORD): DWORD; stdcall;
  11718. {$EXTERNALSYM CertGetNameString}
  11719. //+-------------------------------------------------------------------------
  11720. // Certificate name types
  11721. //--------------------------------------------------------------------------
  11722. const
  11723. CERT_NAME_EMAIL_TYPE = 1;
  11724. {$EXTERNALSYM CERT_NAME_EMAIL_TYPE}
  11725. CERT_NAME_RDN_TYPE = 2;
  11726. {$EXTERNALSYM CERT_NAME_RDN_TYPE}
  11727. CERT_NAME_ATTR_TYPE = 3;
  11728. {$EXTERNALSYM CERT_NAME_ATTR_TYPE}
  11729. CERT_NAME_SIMPLE_DISPLAY_TYPE = 4;
  11730. {$EXTERNALSYM CERT_NAME_SIMPLE_DISPLAY_TYPE}
  11731. CERT_NAME_FRIENDLY_DISPLAY_TYPE = 5;
  11732. {$EXTERNALSYM CERT_NAME_FRIENDLY_DISPLAY_TYPE}
  11733. //+-------------------------------------------------------------------------
  11734. // Certificate name flags
  11735. //--------------------------------------------------------------------------
  11736. CERT_NAME_ISSUER_FLAG = $1;
  11737. {$EXTERNALSYM CERT_NAME_ISSUER_FLAG}
  11738. CERT_NAME_DISABLE_IE4_UTF8_FLAG = $00010000;
  11739. {$EXTERNALSYM CERT_NAME_DISABLE_IE4_UTF8_FLAG}
  11740. //+=========================================================================
  11741. // Simplified Cryptographic Message Data Structures and APIs
  11742. //==========================================================================
  11743. //+-------------------------------------------------------------------------
  11744. // Conventions for the *pb and *pcb output parameters:
  11745. //
  11746. // Upon entry to the function:
  11747. // if pcb is OPTIONAL && pcb == NULL, then,
  11748. // No output is returned
  11749. // else if pb == NULL && pcb != NULL, then,
  11750. // Length only determination. No length error is
  11751. // returned.
  11752. // otherwise where (pb != NULL && pcb != NULL && *pcb != 0)
  11753. // Output is returned. If *pcb isn't big enough a
  11754. // length error is returned. In all cases *pcb is updated
  11755. // with the actual length needed/returned.
  11756. //--------------------------------------------------------------------------
  11757. //+-------------------------------------------------------------------------
  11758. // Type definitions of the parameters used for doing the cryptographic
  11759. // operations.
  11760. //--------------------------------------------------------------------------
  11761. //+-------------------------------------------------------------------------
  11762. // Callback to get and verify the signer's certificate.
  11763. //
  11764. // Passed the CertId of the signer (its Issuer and SerialNumber) and a
  11765. // handle to its cryptographic signed message's cert store.
  11766. //
  11767. // For CRYPT_E_NO_SIGNER, called with pSignerId == NULL.
  11768. //
  11769. // For a valid signer certificate, returns a pointer to a read only
  11770. // CERT_CONTEXT. The returned CERT_CONTEXT is either obtained from a
  11771. // cert store or was created via CertCreateCertificateContext. For either case,
  11772. // its freed via CertFreeCertificateContext.
  11773. //
  11774. // If a valid certificate isn't found, this callback returns NULL with
  11775. // LastError set via SetLastError().
  11776. //
  11777. // The NULL implementation tries to get the Signer certificate from the
  11778. // message cert store. It doesn't verify the certificate.
  11779. //
  11780. // Note, if the KEYID choice was selected for a CMS SignerId, then, the
  11781. // SerialNumber is 0 and the Issuer is encoded containing a single RDN with a
  11782. // single Attribute whose OID is szOID_KEYID_RDN, value type is
  11783. // CERT_RDN_OCTET_STRING and value is the KEYID. When the
  11784. // CertGetSubjectCertificateFromStore and
  11785. // CertFindCertificateInStore(CERT_FIND_SUBJECT_CERT) APIs see this
  11786. // special KEYID Issuer and SerialNumber, they do a KEYID match.
  11787. //--------------------------------------------------------------------------
  11788. type
  11789. PFN_CRYPT_GET_SIGNER_CERTIFICATE = function(pvGetArg: Pointer;
  11790. dwCertEncodingType: DWORD; pSignerId: PCERT_INFO;
  11791. hMsgCertStore: HCERTSTORE): PCCERT_CONTEXT; stdcall;
  11792. {$EXTERNALSYM PFN_CRYPT_GET_SIGNER_CERTIFICATE}
  11793. PfnCryptGetSignerCertificate = PFN_CRYPT_GET_SIGNER_CERTIFICATE;
  11794. //+-------------------------------------------------------------------------
  11795. // The CRYPT_SIGN_MESSAGE_PARA are used for signing messages using the
  11796. // specified signing certificate context.
  11797. //
  11798. // Either the CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_PROV_INFO_PROP_ID must
  11799. // be set for each rgpSigningCert[]. Either one specifies the private
  11800. // signature key to use.
  11801. //
  11802. // If any certificates and/or CRLs are to be included in the signed message,
  11803. // then, the MsgCert and MsgCrl parameters need to be updated. If the
  11804. // rgpSigningCerts are to be included, then, they must also be in the
  11805. // rgpMsgCert array.
  11806. //
  11807. // cbSize must be set to the sizeof(CRYPT_SIGN_MESSAGE_PARA) or else
  11808. // LastError will be updated with E_INVALIDARG.
  11809. //
  11810. // pvHashAuxInfo currently isn't used and must be set to NULL.
  11811. //
  11812. // dwFlags normally is set to 0. However, if the encoded output
  11813. // is to be a CMSG_SIGNED inner content of an outer cryptographic message,
  11814. // such as a CMSG_ENVELOPED, then, the CRYPT_MESSAGE_BARE_CONTENT_OUT_FLAG
  11815. // should be set. If not set, then it would be encoded as an inner content
  11816. // type of CMSG_DATA.
  11817. //
  11818. // dwInnerContentType is normally set to 0. It needs to be set if the
  11819. // ToBeSigned input is the encoded output of another cryptographic
  11820. // message, such as, an CMSG_ENVELOPED. When set, it's one of the cryptographic
  11821. // message types, for example, CMSG_ENVELOPED.
  11822. //
  11823. // If the inner content of a nested cryptographic message is data (CMSG_DATA
  11824. // the default), then, neither dwFlags or dwInnerContentType need to be set.
  11825. //
  11826. // For CMS messages, CRYPT_MESSAGE_ENCAPSULATED_CONTENT_OUT_FLAG may be
  11827. // set to encapsulate nonData inner content within an OCTET STRING.
  11828. //
  11829. // For CMS messages, CRYPT_MESSAGE_KEYID_SIGNER_FLAG may be set to identify
  11830. // signers by their Key Identifier and not their Issuer and Serial Number.
  11831. //
  11832. // If HashEncryptionAlgorithm is present and not NULL its used instead of
  11833. // the SigningCert's PublicKeyInfo.Algorithm.
  11834. //
  11835. // Note, for RSA, the hash encryption algorithm is normally the same as
  11836. // the public key algorithm. For DSA, the hash encryption algorithm is
  11837. // normally a DSS signature algorithm.
  11838. //
  11839. // pvHashEncryptionAuxInfo currently isn't used and must be set to NULL if
  11840. // present in the data structure.
  11841. //--------------------------------------------------------------------------
  11842. type
  11843. PCRYPT_SIGN_MESSAGE_PARA = ^CRYPT_SIGN_MESSAGE_PARA;
  11844. {$EXTERNALSYM PCRYPT_SIGN_MESSAGE_PARA}
  11845. _CRYPT_SIGN_MESSAGE_PARA = record
  11846. cbSize: DWORD;
  11847. dwMsgEncodingType: DWORD;
  11848. pSigningCert: PCCERT_CONTEXT;
  11849. HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  11850. pvHashAuxInfo: Pointer;
  11851. cMsgCert: DWORD;
  11852. rgpMsgCert: PPCCERT_CONTEXT;
  11853. cMsgCrl: DWORD;
  11854. rgpMsgCrl: PPCCRL_CONTEXT;
  11855. cAuthAttr: DWORD;
  11856. rgAuthAttr: PCRYPT_ATTRIBUTE;
  11857. cUnauthAttr: DWORD;
  11858. rgUnauthAttr: PCRYPT_ATTRIBUTE;
  11859. dwFlags: DWORD;
  11860. dwInnerContentType: DWORD;
  11861. {$IFDEF CRYPT_SIGN_MESSAGE_PARA_HAS_CMS_FIELDS}
  11862. HashEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  11863. pvHashEncryptionAuxInfo: Pointer;
  11864. {$ENDIF CRYPT_SIGN_MESSAGE_PARA_HAS_CMS_FIELDS}
  11865. end;
  11866. {$EXTERNALSYM _CRYPT_SIGN_MESSAGE_PARA}
  11867. CRYPT_SIGN_MESSAGE_PARA = _CRYPT_SIGN_MESSAGE_PARA;
  11868. {$EXTERNALSYM CRYPT_SIGN_MESSAGE_PARA}
  11869. TCryptSignMessagePara = CRYPT_SIGN_MESSAGE_PARA;
  11870. PCryptSignMessagePara = PCRYPT_SIGN_MESSAGE_PARA;
  11871. const
  11872. CRYPT_MESSAGE_BARE_CONTENT_OUT_FLAG = $1;
  11873. {$EXTERNALSYM CRYPT_MESSAGE_BARE_CONTENT_OUT_FLAG}
  11874. // When set, nonData type inner content is encapsulated within an
  11875. // OCTET STRING
  11876. CRYPT_MESSAGE_ENCAPSULATED_CONTENT_OUT_FLAG = $2;
  11877. {$EXTERNALSYM CRYPT_MESSAGE_ENCAPSULATED_CONTENT_OUT_FLAG}
  11878. // When set, signers are identified by their Key Identifier and not
  11879. // their Issuer and Serial Number.
  11880. CRYPT_MESSAGE_KEYID_SIGNER_FLAG = $4;
  11881. {$EXTERNALSYM CRYPT_MESSAGE_KEYID_SIGNER_FLAG}
  11882. //+-------------------------------------------------------------------------
  11883. // The CRYPT_VERIFY_MESSAGE_PARA are used to verify signed messages.
  11884. //
  11885. // hCryptProv is used to do hashing and signature verification.
  11886. //
  11887. // The dwCertEncodingType specifies the encoding type of the certificates
  11888. // and/or CRLs in the message.
  11889. //
  11890. // pfnGetSignerCertificate is called to get and verify the message signer's
  11891. // certificate.
  11892. //
  11893. // cbSize must be set to the sizeof(CRYPT_VERIFY_MESSAGE_PARA) or else
  11894. // LastError will be updated with E_INVALIDARG.
  11895. //--------------------------------------------------------------------------
  11896. type
  11897. PCRYPT_VERIFY_MESSAGE_PARA = ^CRYPT_VERIFY_MESSAGE_PARA;
  11898. {$EXTERNALSYM PCRYPT_VERIFY_MESSAGE_PARA}
  11899. _CRYPT_VERIFY_MESSAGE_PARA = record
  11900. cbSize: DWORD;
  11901. dwMsgAndCertEncodingType: DWORD;
  11902. hCryptProv: HCRYPTPROV;
  11903. pfnGetSignerCertificate: PFN_CRYPT_GET_SIGNER_CERTIFICATE;
  11904. pvGetArg: Pointer;
  11905. end;
  11906. {$EXTERNALSYM _CRYPT_VERIFY_MESSAGE_PARA}
  11907. CRYPT_VERIFY_MESSAGE_PARA = _CRYPT_VERIFY_MESSAGE_PARA;
  11908. {$EXTERNALSYM CRYPT_VERIFY_MESSAGE_PARA}
  11909. TCryptVerifyMessagePara = CRYPT_VERIFY_MESSAGE_PARA;
  11910. PCryptVerifyMessagePara = PCRYPT_VERIFY_MESSAGE_PARA;
  11911. //+-------------------------------------------------------------------------
  11912. // The CRYPT_ENCRYPT_MESSAGE_PARA are used for encrypting messages.
  11913. //
  11914. // hCryptProv is used to do content encryption, recipient key
  11915. // encryption, and recipient key export. Its private key
  11916. // isn't used.
  11917. //
  11918. // Currently, pvEncryptionAuxInfo is only defined for RC2 or RC4 encryption
  11919. // algorithms. Otherwise, its not used and must be set to NULL.
  11920. // See CMSG_RC2_AUX_INFO for the RC2 encryption algorithms.
  11921. // See CMSG_RC4_AUX_INFO for the RC4 encryption algorithms.
  11922. //
  11923. // To enable SP3 compatible encryption, pvEncryptionAuxInfo should point to
  11924. // a CMSG_SP3_COMPATIBLE_AUX_INFO data structure.
  11925. //
  11926. // cbSize must be set to the sizeof(CRYPT_ENCRYPT_MESSAGE_PARA) or else
  11927. // LastError will be updated with E_INVALIDARG.
  11928. //
  11929. // dwFlags normally is set to 0. However, if the encoded output
  11930. // is to be a CMSG_ENVELOPED inner content of an outer cryptographic message,
  11931. // such as a CMSG_SIGNED, then, the CRYPT_MESSAGE_BARE_CONTENT_OUT_FLAG
  11932. // should be set. If not set, then it would be encoded as an inner content
  11933. // type of CMSG_DATA.
  11934. //
  11935. // dwInnerContentType is normally set to 0. It needs to be set if the
  11936. // ToBeEncrypted input is the encoded output of another cryptographic
  11937. // message, such as, an CMSG_SIGNED. When set, it's one of the cryptographic
  11938. // message types, for example, CMSG_SIGNED.
  11939. //
  11940. // If the inner content of a nested cryptographic message is data (CMSG_DATA
  11941. // the default), then, neither dwFlags or dwInnerContentType need to be set.
  11942. //
  11943. // For CMS messages, CRYPT_MESSAGE_ENCAPSULATED_CONTENT_OUT_FLAG may be
  11944. // set to encapsulate nonData inner content within an OCTET STRING before
  11945. // encrypting.
  11946. //
  11947. // For CMS messages, CRYPT_MESSAGE_KEYID_RECIPIENT_FLAG may be set to identify
  11948. // recipients by their Key Identifier and not their Issuer and Serial Number.
  11949. //--------------------------------------------------------------------------
  11950. type
  11951. PCRYPT_ENCRYPT_MESSAGE_PARA = ^CRYPT_ENCRYPT_MESSAGE_PARA;
  11952. {$EXTERNALSYM PCRYPT_ENCRYPT_MESSAGE_PARA}
  11953. _CRYPT_ENCRYPT_MESSAGE_PARA = record
  11954. cbSize: DWORD;
  11955. dwMsgEncodingType: DWORD;
  11956. hCryptProv: HCRYPTPROV;
  11957. ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  11958. pvEncryptionAuxInfo: Pointer;
  11959. dwFlags: DWORD;
  11960. dwInnerContentType: DWORD;
  11961. end;
  11962. {$EXTERNALSYM _CRYPT_ENCRYPT_MESSAGE_PARA}
  11963. CRYPT_ENCRYPT_MESSAGE_PARA = _CRYPT_ENCRYPT_MESSAGE_PARA;
  11964. {$EXTERNALSYM CRYPT_ENCRYPT_MESSAGE_PARA}
  11965. TCryptEncryptMessagePara = CRYPT_ENCRYPT_MESSAGE_PARA;
  11966. PCryptEncryptMessagePara = PCRYPT_ENCRYPT_MESSAGE_PARA;
  11967. // When set, recipients are identified by their Key Identifier and not
  11968. // their Issuer and Serial Number.
  11969. const
  11970. CRYPT_MESSAGE_KEYID_RECIPIENT_FLAG = $4;
  11971. {$EXTERNALSYM CRYPT_MESSAGE_KEYID_RECIPIENT_FLAG}
  11972. //+-------------------------------------------------------------------------
  11973. // The CRYPT_DECRYPT_MESSAGE_PARA are used for decrypting messages.
  11974. //
  11975. // The CertContext to use for decrypting a message is obtained from one
  11976. // of the specified cert stores. An encrypted message can have one or
  11977. // more recipients. The recipients are identified by their CertId (Issuer
  11978. // and SerialNumber). The cert stores are searched to find the CertContext
  11979. // corresponding to the CertId.
  11980. //
  11981. // For CMS, the recipients may also be identified by their KeyId.
  11982. // CMS also allows Key Agreement (Diffie Hellman) in addition to
  11983. // Key Transport (RSA) recipients.
  11984. //
  11985. // Only CertContexts in the store with either
  11986. // the CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_PROV_INFO_PROP_ID set
  11987. // can be used. Either property specifies the private exchange key to use.
  11988. //
  11989. // cbSize must be set to the sizeof(CRYPT_DECRYPT_MESSAGE_PARA) or else
  11990. // LastError will be updated with E_INVALIDARG.
  11991. //--------------------------------------------------------------------------
  11992. type
  11993. PCRYPT_DECRYPT_MESSAGE_PARA = ^CRYPT_DECRYPT_MESSAGE_PARA;
  11994. {$EXTERNALSYM PCRYPT_DECRYPT_MESSAGE_PARA}
  11995. _CRYPT_DECRYPT_MESSAGE_PARA = record
  11996. cbSize: DWORD;
  11997. dwMsgAndCertEncodingType: DWORD;
  11998. cCertStore: DWORD;
  11999. rghCertStore: PHCERTSTORE;
  12000. end;
  12001. {$EXTERNALSYM _CRYPT_DECRYPT_MESSAGE_PARA}
  12002. CRYPT_DECRYPT_MESSAGE_PARA = _CRYPT_DECRYPT_MESSAGE_PARA;
  12003. {$EXTERNALSYM CRYPT_DECRYPT_MESSAGE_PARA}
  12004. TCryptDecryptMessagePara = CRYPT_DECRYPT_MESSAGE_PARA;
  12005. PCryptDecryptMessagePara = PCRYPT_DECRYPT_MESSAGE_PARA;
  12006. //+-------------------------------------------------------------------------
  12007. // The CRYPT_HASH_MESSAGE_PARA are used for hashing or unhashing
  12008. // messages.
  12009. //
  12010. // hCryptProv is used to compute the hash.
  12011. //
  12012. // pvHashAuxInfo currently isn't used and must be set to NULL.
  12013. //
  12014. // cbSize must be set to the sizeof(CRYPT_HASH_MESSAGE_PARA) or else
  12015. // LastError will be updated with E_INVALIDARG.
  12016. //--------------------------------------------------------------------------
  12017. PCRYPT_HASH_MESSAGE_PARA = ^CRYPT_HASH_MESSAGE_PARA;
  12018. {$EXTERNALSYM PCRYPT_HASH_MESSAGE_PARA}
  12019. _CRYPT_HASH_MESSAGE_PARA = record
  12020. cbSize: DWORD;
  12021. dwMsgEncodingType: DWORD;
  12022. hCryptProv: HCRYPTPROV;
  12023. HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  12024. pvHashAuxInfo: Pointer;
  12025. end;
  12026. {$EXTERNALSYM _CRYPT_HASH_MESSAGE_PARA}
  12027. CRYPT_HASH_MESSAGE_PARA = _CRYPT_HASH_MESSAGE_PARA;
  12028. {$EXTERNALSYM CRYPT_HASH_MESSAGE_PARA}
  12029. TCryptHashMessagePara = CRYPT_HASH_MESSAGE_PARA;
  12030. PCryptHashMessagePara = PCRYPT_HASH_MESSAGE_PARA;
  12031. //+-------------------------------------------------------------------------
  12032. // The CRYPT_KEY_SIGN_MESSAGE_PARA are used for signing messages until a
  12033. // certificate has been created for the signature key.
  12034. //
  12035. // pvHashAuxInfo currently isn't used and must be set to NULL.
  12036. //
  12037. // If PubKeyAlgorithm isn't set, defaults to szOID_RSA_RSA.
  12038. //
  12039. // cbSize must be set to the sizeof(CRYPT_KEY_SIGN_MESSAGE_PARA) or else
  12040. // LastError will be updated with E_INVALIDARG.
  12041. //--------------------------------------------------------------------------
  12042. PCRYPT_KEY_SIGN_MESSAGE_PARA = ^CRYPT_KEY_SIGN_MESSAGE_PARA;
  12043. {$EXTERNALSYM PCRYPT_KEY_SIGN_MESSAGE_PARA}
  12044. _CRYPT_KEY_SIGN_MESSAGE_PARA = record
  12045. cbSize: DWORD;
  12046. dwMsgAndCertEncodingType: DWORD;
  12047. hCryptProv: HCRYPTPROV;
  12048. dwKeySpec: DWORD;
  12049. HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  12050. pvHashAuxInfo: Pointer;
  12051. PubKeyAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  12052. end;
  12053. {$EXTERNALSYM _CRYPT_KEY_SIGN_MESSAGE_PARA}
  12054. CRYPT_KEY_SIGN_MESSAGE_PARA = _CRYPT_KEY_SIGN_MESSAGE_PARA;
  12055. {$EXTERNALSYM CRYPT_KEY_SIGN_MESSAGE_PARA}
  12056. TCryptKeySignMessagePara = CRYPT_KEY_SIGN_MESSAGE_PARA;
  12057. PCryptKeySignMessagePara = PCRYPT_KEY_SIGN_MESSAGE_PARA;
  12058. //+-------------------------------------------------------------------------
  12059. // The CRYPT_KEY_VERIFY_MESSAGE_PARA are used to verify signed messages without
  12060. // a certificate for the signer.
  12061. //
  12062. // Normally used until a certificate has been created for the key.
  12063. //
  12064. // hCryptProv is used to do hashing and signature verification.
  12065. //
  12066. // cbSize must be set to the sizeof(CRYPT_KEY_VERIFY_MESSAGE_PARA) or else
  12067. // LastError will be updated with E_INVALIDARG.
  12068. //--------------------------------------------------------------------------
  12069. PCRYPT_KEY_VERIFY_MESSAGE_PARA = ^CRYPT_KEY_VERIFY_MESSAGE_PARA;
  12070. {$EXTERNALSYM PCRYPT_KEY_VERIFY_MESSAGE_PARA}
  12071. _CRYPT_KEY_VERIFY_MESSAGE_PARA = record
  12072. cbSize: DWORD;
  12073. dwMsgEncodingType: DWORD;
  12074. hCryptProv: HCRYPTPROV;
  12075. end;
  12076. {$EXTERNALSYM _CRYPT_KEY_VERIFY_MESSAGE_PARA}
  12077. CRYPT_KEY_VERIFY_MESSAGE_PARA = _CRYPT_KEY_VERIFY_MESSAGE_PARA;
  12078. {$EXTERNALSYM CRYPT_KEY_VERIFY_MESSAGE_PARA}
  12079. TCryptKeyVerifyMessagePara = CRYPT_KEY_VERIFY_MESSAGE_PARA;
  12080. PCryptKeyVerifyMessagePara = PCRYPT_KEY_VERIFY_MESSAGE_PARA;
  12081. //+-------------------------------------------------------------------------
  12082. // Sign the message.
  12083. //
  12084. // If fDetachedSignature is TRUE, the "to be signed" content isn't included
  12085. // in the encoded signed blob.
  12086. //--------------------------------------------------------------------------
  12087. function CryptSignMessage(pSignPara: PCRYPT_SIGN_MESSAGE_PARA;
  12088. fDetachedSignature: BOOL; cToBeSigned: DWORD; rgpbToBeSigned: LPBYTE;
  12089. rgcbToBeSigned: LPDWORD; pbSignedBlob: LPBYTE; var pcbSignedBlob: DWORD): BOOL; stdcall;
  12090. {$EXTERNALSYM CryptSignMessage}
  12091. //+-------------------------------------------------------------------------
  12092. // Verify a signed message.
  12093. //
  12094. // If pbDecoded == NULL, then, *pcbDecoded is implicitly set to 0 on input.
  12095. // For *pcbDecoded == 0 && ppSignerCert == NULL on input, the signer isn't
  12096. // verified.
  12097. //
  12098. // A message might have more than one signer. Set dwSignerIndex to iterate
  12099. // through all the signers. dwSignerIndex == 0 selects the first signer.
  12100. //
  12101. // pVerifyPara's pfnGetSignerCertificate is called to get the signer's
  12102. // certificate.
  12103. //
  12104. // For a verified signer and message, *ppSignerCert is updated
  12105. // with the CertContext of the signer. It must be freed by calling
  12106. // CertFreeCertificateContext. Otherwise, *ppSignerCert is set to NULL.
  12107. //
  12108. // ppSignerCert can be NULL, indicating the caller isn't interested
  12109. // in getting the CertContext of the signer.
  12110. //
  12111. // pcbDecoded can be NULL, indicating the caller isn't interested in getting
  12112. // the decoded content. Furthermore, if the message doesn't contain any
  12113. // content or signers, then, pcbDecoded must be set to NULL, to allow the
  12114. // pVerifyPara->pfnGetCertificate to be called. Normally, this would be
  12115. // the case when the signed message contains only certficates and CRLs.
  12116. // If pcbDecoded is NULL and the message doesn't have the indicated signer,
  12117. // pfnGetCertificate is called with pSignerId set to NULL.
  12118. //
  12119. // If the message doesn't contain any signers || dwSignerIndex > message's
  12120. // SignerCount, then, an error is returned with LastError set to
  12121. // CRYPT_E_NO_SIGNER. Also, for CRYPT_E_NO_SIGNER, pfnGetSignerCertificate
  12122. // is still called with pSignerId set to NULL.
  12123. //
  12124. // Note, an alternative way to get the certificates and CRLs from a
  12125. // signed message is to call CryptGetMessageCertificates.
  12126. //--------------------------------------------------------------------------
  12127. function CryptVerifyMessageSignature(pVerifyPara: PCRYPT_VERIFY_MESSAGE_PARA;
  12128. dwSignerIndex: DWORD; pbSignedBlob: LPBYTE; cbSignedBlob: DWORD;
  12129. pbDecoded: LPBYTE; pcbDecoded: LPDWORD; ppSignerCert: PPCCERT_CONTEXT): BOOL; stdcall;
  12130. {$EXTERNALSYM CryptVerifyMessageSignature}
  12131. //+-------------------------------------------------------------------------
  12132. // Returns the count of signers in the signed message. For no signers, returns
  12133. // 0. For an error returns -1 with LastError updated accordingly.
  12134. //--------------------------------------------------------------------------
  12135. function CryptGetMessageSignerCount(dwMsgEncodingType: DWORD; pbSignedBlob: LPBYTE;
  12136. cbSignedBlob: DWORD): LONG; stdcall;
  12137. {$EXTERNALSYM CryptGetMessageSignerCount}
  12138. //+-------------------------------------------------------------------------
  12139. // Returns the cert store containing the message's certs and CRLs.
  12140. // For an error, returns NULL with LastError updated.
  12141. //--------------------------------------------------------------------------
  12142. function CryptGetMessageCertificates(dwMsgAndCertEncodingType: DWORD;
  12143. hCryptProv: HCRYPTPROV; dwFlags: DWORD; pbSignedBlob: LPBYTE;
  12144. cbSignedBlob: DWORD): HCERTSTORE; stdcall;
  12145. {$EXTERNALSYM CryptGetMessageCertificates}
  12146. //+-------------------------------------------------------------------------
  12147. // Verify a signed message containing detached signature(s).
  12148. // The "to be signed" content is passed in separately. No
  12149. // decoded output. Otherwise, identical to CryptVerifyMessageSignature.
  12150. //--------------------------------------------------------------------------
  12151. function CryptVerifyDetachedMessageSignature(pVerifyPara: PCRYPT_VERIFY_MESSAGE_PARA;
  12152. dwSignerIndex: DWORD; pbDetachedSignBlob: LPBYTE; cbDetachedSignBlob: DWORD;
  12153. cToBeSigned: DWORD; rgpbToBeSigned: LPBYTE; rgcbToBeSigned: LPDWORD;
  12154. ppSignerCert: PPCCERT_CONTEXT): BOOL; stdcall;
  12155. {$EXTERNALSYM CryptVerifyDetachedMessageSignature}
  12156. //+-------------------------------------------------------------------------
  12157. // Encrypts the message for the recipient(s).
  12158. //--------------------------------------------------------------------------
  12159. function CryptEncryptMessage(pEncryptPara: PCRYPT_ENCRYPT_MESSAGE_PARA;
  12160. cRecipientCert: DWORD; rgpRecipientCert: PCCERT_CONTEXT; pbToBeEncrypted: LPBYTE;
  12161. cbToBeEncrypted: DWORD; pbEncryptedBlob: LPBYTE; var pcbEncryptedBlob: DWORD): BOOL; stdcall;
  12162. {$EXTERNALSYM CryptEncryptMessage}
  12163. //+-------------------------------------------------------------------------
  12164. // Decrypts the message.
  12165. //
  12166. // If pbDecrypted == NULL, then, *pcbDecrypted is implicitly set to 0 on input.
  12167. // For *pcbDecrypted == 0 && ppXchgCert == NULL on input, the message isn't
  12168. // decrypted.
  12169. //
  12170. // For a successfully decrypted message, *ppXchgCert is updated
  12171. // with the CertContext used to decrypt. It must be freed by calling
  12172. // CertStoreFreeCert. Otherwise, *ppXchgCert is set to NULL.
  12173. //
  12174. // ppXchgCert can be NULL, indicating the caller isn't interested
  12175. // in getting the CertContext used to decrypt.
  12176. //--------------------------------------------------------------------------
  12177. function CryptDecryptMessage(pDecryptPara: PCRYPT_DECRYPT_MESSAGE_PARA;
  12178. pbEncryptedBlob: LPBYTE; cbEncryptedBlob: DWORD; pbDecrypted: LPBYTE;
  12179. pcbDecrypted: LPDWORD; ppXchgCert: PPCCERT_CONTEXT): BOOL; stdcall;
  12180. {$EXTERNALSYM CryptDecryptMessage}
  12181. //+-------------------------------------------------------------------------
  12182. // Sign the message and encrypt for the recipient(s). Does a CryptSignMessage
  12183. // followed with a CryptEncryptMessage.
  12184. //
  12185. // Note: this isn't the CMSG_SIGNED_AND_ENVELOPED. Its a CMSG_SIGNED
  12186. // inside of an CMSG_ENVELOPED.
  12187. //--------------------------------------------------------------------------
  12188. function CryptSignAndEncryptMessage(pSignPara: PCRYPT_SIGN_MESSAGE_PARA;
  12189. pEncryptPara: PCRYPT_ENCRYPT_MESSAGE_PARA; cRecipientCert: DWORD;
  12190. rgpRecipientCert: PCCERT_CONTEXT; pbToBeSignedAndEncrypted: LPBYTE;
  12191. cbToBeSignedAndEncrypted: DWORD; pbSignedAndEncryptedBlob: LPBYTE;
  12192. var pcbSignedAndEncryptedBlob: DWORD): BOOL; stdcall;
  12193. {$EXTERNALSYM CryptSignAndEncryptMessage}
  12194. //+-------------------------------------------------------------------------
  12195. // Decrypts the message and verifies the signer. Does a CryptDecryptMessage
  12196. // followed with a CryptVerifyMessageSignature.
  12197. //
  12198. // If pbDecrypted == NULL, then, *pcbDecrypted is implicitly set to 0 on input.
  12199. // For *pcbDecrypted == 0 && ppSignerCert == NULL on input, the signer isn't
  12200. // verified.
  12201. //
  12202. // A message might have more than one signer. Set dwSignerIndex to iterate
  12203. // through all the signers. dwSignerIndex == 0 selects the first signer.
  12204. //
  12205. // The pVerifyPara's VerifySignerPolicy is called to verify the signer's
  12206. // certificate.
  12207. //
  12208. // For a successfully decrypted and verified message, *ppXchgCert and
  12209. // *ppSignerCert are updated. They must be freed by calling
  12210. // CertStoreFreeCert. Otherwise, they are set to NULL.
  12211. //
  12212. // ppXchgCert and/or ppSignerCert can be NULL, indicating the
  12213. // caller isn't interested in getting the CertContext.
  12214. //
  12215. // Note: this isn't the CMSG_SIGNED_AND_ENVELOPED. Its a CMSG_SIGNED
  12216. // inside of an CMSG_ENVELOPED.
  12217. //
  12218. // The message always needs to be decrypted to allow access to the
  12219. // signed message. Therefore, if ppXchgCert != NULL, its always updated.
  12220. //--------------------------------------------------------------------------
  12221. function CryptDecryptAndVerifyMessageSignature(pDecryptPara: PCRYPT_DECRYPT_MESSAGE_PARA;
  12222. pVerifyPara: PCRYPT_VERIFY_MESSAGE_PARA; dwSignerIndex: DWORD; pbEncryptedBlob: LPBYTE;
  12223. cbEncryptedBlob: DWORD; pbDecrypted: LPBYTE; pcbDecrypted: LPDWORD;
  12224. ppXchgCert: PPCCERT_CONTEXT; ppSignerCert: PPCCERT_CONTEXT): BOOL; stdcall;
  12225. {$EXTERNALSYM CryptDecryptAndVerifyMessageSignature}
  12226. //+-------------------------------------------------------------------------
  12227. // Decodes a cryptographic message which may be one of the following types:
  12228. // CMSG_DATA
  12229. // CMSG_SIGNED
  12230. // CMSG_ENVELOPED
  12231. // CMSG_SIGNED_AND_ENVELOPED
  12232. // CMSG_HASHED
  12233. //
  12234. // dwMsgTypeFlags specifies the set of allowable messages. For example, to
  12235. // decode either SIGNED or ENVELOPED messages, set dwMsgTypeFlags to:
  12236. // CMSG_SIGNED_FLAG | CMSG_ENVELOPED_FLAG.
  12237. //
  12238. // dwProvInnerContentType is only applicable when processing nested
  12239. // crytographic messages. When processing an outer crytographic message
  12240. // it must be set to 0. When decoding a nested cryptographic message
  12241. // its the dwInnerContentType returned by a previous CryptDecodeMessage
  12242. // of the outer message. The InnerContentType can be any of the CMSG types,
  12243. // for example, CMSG_DATA, CMSG_SIGNED, ...
  12244. //
  12245. // The optional *pdwMsgType is updated with the type of message.
  12246. //
  12247. // The optional *pdwInnerContentType is updated with the type of the inner
  12248. // message. Unless there is cryptographic message nesting, CMSG_DATA
  12249. // is returned.
  12250. //
  12251. // For CMSG_DATA: returns decoded content.
  12252. // For CMSG_SIGNED: same as CryptVerifyMessageSignature.
  12253. // For CMSG_ENVELOPED: same as CryptDecryptMessage.
  12254. // For CMSG_SIGNED_AND_ENVELOPED: same as CryptDecryptMessage plus
  12255. // CryptVerifyMessageSignature.
  12256. // For CMSG_HASHED: verifies the hash and returns decoded content.
  12257. //--------------------------------------------------------------------------
  12258. function CryptDecodeMessage(dwMsgTypeFlags: DWORD; pDecryptPara: PCRYPT_DECRYPT_MESSAGE_PARA;
  12259. pVerifyPara: PCRYPT_VERIFY_MESSAGE_PARA; dwSignerIndex: DWORD; pbEncodedBlob: LPBYTE;
  12260. cbEncodedBlob: DWORD; dwPrevInnerContentType: DWORD; pdwMsgType: LPDWORD;
  12261. pdwInnerContentType: LPDWORD; pbDecoded: LPBYTE; pcbDecoded: LPDWORD;
  12262. ppXchgCert: PPCCERT_CONTEXT; ppSignerCert: PPCCERT_CONTEXT): BOOL; stdcall;
  12263. {$EXTERNALSYM CryptDecodeMessage}
  12264. //+-------------------------------------------------------------------------
  12265. // Hash the message.
  12266. //
  12267. // If fDetachedHash is TRUE, only the ComputedHash is encoded in the
  12268. // pbHashedBlob. Otherwise, both the ToBeHashed and ComputedHash
  12269. // are encoded.
  12270. //
  12271. // pcbHashedBlob or pcbComputedHash can be NULL, indicating the caller
  12272. // isn't interested in getting the output.
  12273. //--------------------------------------------------------------------------
  12274. function CryptHashMessage(pHashPara: PCRYPT_HASH_MESSAGE_PARA; fDetachedHash: BOOL;
  12275. cToBeHashed: DWORD; rgpbToBeHashed: LPBYTE; rgcbToBeHashed: LPDWORD;
  12276. pbHashedBlob: LPBYTE; pcbHashedBlob: LPDWORD; pbComputedHash: LPBYTE;
  12277. pcbComputedHash: LPDWORD): BOOL; stdcall;
  12278. {$EXTERNALSYM CryptHashMessage}
  12279. //+-------------------------------------------------------------------------
  12280. // Verify a hashed message.
  12281. //
  12282. // pcbToBeHashed or pcbComputedHash can be NULL,
  12283. // indicating the caller isn't interested in getting the output.
  12284. //--------------------------------------------------------------------------
  12285. function CryptVerifyMessageHash(pHashPara: PCRYPT_HASH_MESSAGE_PARA;
  12286. pbHashedBlob: LPBYTE; cbHashedBlob: DWORD; pbToBeHashed: LPBYTE;
  12287. pcbToBeHashed: LPDWORD; pbComputedHash: LPBYTE; pcbComputedHash: LPDWORD): BOOL; stdcall;
  12288. {$EXTERNALSYM CryptVerifyMessageHash}
  12289. //+-------------------------------------------------------------------------
  12290. // Verify a hashed message containing a detached hash.
  12291. // The "to be hashed" content is passed in separately. No
  12292. // decoded output. Otherwise, identical to CryptVerifyMessageHash.
  12293. //
  12294. // pcbComputedHash can be NULL, indicating the caller isn't interested
  12295. // in getting the output.
  12296. //--------------------------------------------------------------------------
  12297. function CryptVerifyDetachedMessageHash(pHashPara: PCRYPT_HASH_MESSAGE_PARA;
  12298. pbDetachedHashBlob: LPBYTE; cbDetachedHashBlob: DWORD; cToBeHashed: DWORD;
  12299. rgpbToBeHashed: LPBYTE; rgcbToBeHashed: LPDWORD; pbComputedHash: LPBYTE;
  12300. pcbComputedHash: LPDWORD): BOOL; stdcall;
  12301. {$EXTERNALSYM CryptVerifyDetachedMessageHash}
  12302. //+-------------------------------------------------------------------------
  12303. // Sign the message using the provider's private key specified in the
  12304. // parameters. A dummy SignerId is created and stored in the message.
  12305. //
  12306. // Normally used until a certificate has been created for the key.
  12307. //--------------------------------------------------------------------------
  12308. function CryptSignMessageWithKey(pSignPara: PCRYPT_KEY_SIGN_MESSAGE_PARA;
  12309. pbToBeSigned: LPBYTE; cbToBeSigned: DWORD; pbSignedBlob: LPBYTE;
  12310. var pcbSignedBlob: DWORD): BOOL; stdcall;
  12311. {$EXTERNALSYM CryptSignMessageWithKey}
  12312. //+-------------------------------------------------------------------------
  12313. // Verify a signed message using the specified public key info.
  12314. //
  12315. // Normally called by a CA until it has created a certificate for the
  12316. // key.
  12317. //
  12318. // pPublicKeyInfo contains the public key to use to verify the signed
  12319. // message. If NULL, the signature isn't verified (for instance, the decoded
  12320. // content may contain the PublicKeyInfo).
  12321. //
  12322. // pcbDecoded can be NULL, indicating the caller isn't interested
  12323. // in getting the decoded content.
  12324. //--------------------------------------------------------------------------
  12325. function CryptVerifyMessageSignatureWithKey(pVerifyPara: PCRYPT_KEY_VERIFY_MESSAGE_PARA;
  12326. pPublicKeyInfo: PCERT_PUBLIC_KEY_INFO; pbSignedBlob: LPBYTE; cbSignedBlob: DWORD;
  12327. pbDecoded: LPBYTE; pcbDecoded: LPDWORD): BOOL; stdcall;
  12328. {$EXTERNALSYM CryptVerifyMessageSignatureWithKey}
  12329. //+=========================================================================
  12330. // System Certificate Store Data Structures and APIs
  12331. //==========================================================================
  12332. //+-------------------------------------------------------------------------
  12333. // Get a system certificate store based on a subsystem protocol.
  12334. //
  12335. // Current examples of subsystems protocols are:
  12336. // "MY" Cert Store hold certs with associated Private Keys
  12337. // "CA" Certifying Authority certs
  12338. // "ROOT" Root Certs
  12339. // "SPC" Software publisher certs
  12340. //
  12341. //
  12342. // If hProv is NULL the default provider "1" is opened for you.
  12343. // When the store is closed the provider is release. Otherwise
  12344. // if hProv is not NULL, no provider is created or released.
  12345. //
  12346. // The returned Cert Store can be searched for an appropriate Cert
  12347. // using the Cert Store API's (see certstor.h)
  12348. //
  12349. // When done, the cert store should be closed using CertStoreClose
  12350. //--------------------------------------------------------------------------
  12351. function CertOpenSystemStoreA(hProv: HCRYPTPROV; szSubsystemProtocol: LPCSTR): HCERTSTORE; stdcall;
  12352. {$EXTERNALSYM CertOpenSystemStoreA}
  12353. function CertOpenSystemStoreW(hProv: HCRYPTPROV; szSubsystemProtocol: LPCWSTR): HCERTSTORE; stdcall;
  12354. {$EXTERNALSYM CertOpenSystemStoreW}
  12355. function CertOpenSystemStore(hProv: HCRYPTPROV; szSubsystemProtocol: LPCTSTR): HCERTSTORE; stdcall;
  12356. {$EXTERNALSYM CertOpenSystemStore}
  12357. function CertAddEncodedCertificateToSystemStoreA(szCertStoreName: LPCSTR;
  12358. pbCertEncoded: LPBYTE; cbCertEncoded: DWORD): BOOL; stdcall;
  12359. {$EXTERNALSYM CertAddEncodedCertificateToSystemStoreA}
  12360. function CertAddEncodedCertificateToSystemStoreW(szCertStoreName: LPCWSTR;
  12361. pbCertEncoded: LPBYTE; cbCertEncoded: DWORD): BOOL; stdcall;
  12362. {$EXTERNALSYM CertAddEncodedCertificateToSystemStoreW}
  12363. function CertAddEncodedCertificateToSystemStore(szCertStoreName: LPCTSTR;
  12364. pbCertEncoded: LPBYTE; cbCertEncoded: DWORD): BOOL; stdcall;
  12365. {$EXTERNALSYM CertAddEncodedCertificateToSystemStore}
  12366. //+-------------------------------------------------------------------------
  12367. // Find all certificate chains tying the given issuer name to any certificate
  12368. // that the current user has a private key for.
  12369. //
  12370. // If no certificate chain is found, FALSE is returned with LastError set
  12371. // to CRYPT_E_NOT_FOUND and the counts zeroed.
  12372. //
  12373. // IE 3.0 ASSUMPTION:
  12374. // The client certificates are in the "My" system store. The issuer
  12375. // cerificates may be in the "Root", "CA" or "My" system stores.
  12376. //--------------------------------------------------------------------------
  12377. type
  12378. PCERT_CHAIN = ^CERT_CHAIN;
  12379. {$EXTERNALSYM PCERT_CHAIN}
  12380. _CERT_CHAIN = record
  12381. cCerts: DWORD; // number of certs in chain
  12382. certs: PCERT_BLOB; // pointer to array of cert chain blobs
  12383. // representing the certs
  12384. keyLocatorInfo: CRYPT_KEY_PROV_INFO; // key locator for cert
  12385. end;
  12386. {$EXTERNALSYM _CERT_CHAIN}
  12387. CERT_CHAIN = _CERT_CHAIN;
  12388. {$EXTERNALSYM CERT_CHAIN}
  12389. TCertChain = CERT_CHAIN;
  12390. PCertChain = PCERT_CHAIN;
  12391. // WINCRYPT32API This is not exported by crypt32, it is exported by softpub
  12392. function FindCertsByIssuer(pCertChains: PCERT_CHAIN; var pcbCertChains: DWORD;
  12393. pcCertChains: LPDWORD; pbEncodedIssuerName: LPBYTE; cbEncodedIssuerName: DWORD;
  12394. pwszPurpose: LPCWSTR; dwKeySpec: DWORD): HRESULT; stdcall;
  12395. {$EXTERNALSYM FindCertsByIssuer}
  12396. //-------------------------------------------------------------------------
  12397. //
  12398. // CryptQueryObject takes a CERT_BLOB or a file name and returns the
  12399. // information about the content in the blob or in the file.
  12400. //
  12401. // Parameters:
  12402. // INPUT dwObjectType:
  12403. // Indicate the type of the object. Should be one of the
  12404. // following:
  12405. // CERT_QUERY_OBJECT_FILE
  12406. // CERT_QUERY_OBJECT_BLOB
  12407. //
  12408. // INPUT pvObject:
  12409. // If dwObjectType == CERT_QUERY_OBJECT_FILE, it is a
  12410. // LPWSTR, that is, the pointer to a wchar file name
  12411. // if dwObjectType == CERT_QUERY_OBJECT_BLOB, it is a
  12412. // PCERT_BLOB, that is, a pointer to a CERT_BLOB
  12413. //
  12414. // INPUT dwExpectedContentTypeFlags:
  12415. // Indicate the expected contenet type.
  12416. // Can be one of the following:
  12417. // CERT_QUERY_CONTENT_FLAG_ALL (the content can be any type)
  12418. // CERT_QUERY_CONTENT_FLAG_CERT
  12419. // CERT_QUERY_CONTENT_FLAG_CTL
  12420. // CERT_QUERY_CONTENT_FLAG_CRL
  12421. // CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE
  12422. // CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT
  12423. // CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL
  12424. // CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL
  12425. // CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED
  12426. // CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED
  12427. // CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED
  12428. // CERT_QUERY_CONTNET_FLAG_PKCS10
  12429. // CERT_QUERY_CONTNET_FLAG_PFX
  12430. //
  12431. // INPUT dwExpectedFormatTypeFlags:
  12432. // Indicate the expected format type.
  12433. // Can be one of the following:
  12434. // CERT_QUERY_FORMAT_FLAG_ALL (the content can be any format)
  12435. // CERT_QUERY_FORMAT_FLAG_BINARY
  12436. // CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED
  12437. //
  12438. //
  12439. // INPUT dwFlags
  12440. // Reserved flag. Should always set to 0
  12441. //
  12442. // OUTPUT pdwMsgAndCertEncodingType
  12443. // Optional output. If NULL != pdwMsgAndCertEncodingType,
  12444. // it contains the encoding type of the content as any
  12445. // combination of the following:
  12446. // X509_ASN_ENCODING
  12447. // PKCS_7_ASN_ENCODING
  12448. //
  12449. // OUTPUT pdwContentType
  12450. // Optional output. If NULL!=pdwContentType, it contains
  12451. // the content type as one of the the following:
  12452. // CERT_QUERY_CONTENT_CERT
  12453. // CERT_QUERY_CONTENT_CTL
  12454. // CERT_QUERY_CONTENT_CRL
  12455. // CERT_QUERY_CONTENT_SERIALIZED_STORE
  12456. // CERT_QUERY_CONTENT_SERIALIZED_CERT
  12457. // CERT_QUERY_CONTENT_SERIALIZED_CTL
  12458. // CERT_QUERY_CONTENT_SERIALIZED_CRL
  12459. // CERT_QUERY_CONTENT_PKCS7_SIGNED
  12460. // CERT_QUERY_CONTENT_PKCS7_UNSIGNED
  12461. // CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED
  12462. // CERT_QUERY_CONTENT_PKCS10
  12463. // CERT_QUERY_CONTENT_PFX
  12464. //
  12465. // OUTPUT pdwFormatType
  12466. // Optional output. If NULL !=pdwFormatType, it
  12467. // contains the format type of the content as one of the
  12468. // following:
  12469. // CERT_QUERY_FORMAT_BINARY
  12470. // CERT_QUERY_FORMAT_BASE64_ENCODED
  12471. //
  12472. //
  12473. // OUTPUT phCertStore
  12474. // Optional output. If NULL !=phStore,
  12475. // it contains a cert store that includes all of certificates,
  12476. // CRL, and CTL in the object if the object content type is
  12477. // one of the following:
  12478. // CERT_QUERY_CONTENT_CERT
  12479. // CERT_QUERY_CONTENT_CTL
  12480. // CERT_QUERY_CONTENT_CRL
  12481. // CERT_QUERY_CONTENT_SERIALIZED_STORE
  12482. // CERT_QUERY_CONTENT_SERIALIZED_CERT
  12483. // CERT_QUERY_CONTENT_SERIALIZED_CTL
  12484. // CERT_QUERY_CONTENT_SERIALIZED_CRL
  12485. // CERT_QUERY_CONTENT_PKCS7_SIGNED
  12486. // CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED
  12487. //
  12488. // Caller should free *phCertStore via CertCloseStore.
  12489. //
  12490. //
  12491. // OUTPUT phMsg Optional output. If NULL != phMsg,
  12492. // it contains a handle to a opened message if
  12493. // the content type is one of the following:
  12494. // CERT_QUERY_CONTENT_PKCS7_SIGNED
  12495. // CERT_QUERY_CONTENT_PKCS7_UNSIGNED
  12496. // CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED
  12497. //
  12498. // Caller should free *phMsg via CryptMsgClose.
  12499. //
  12500. // OUTPUT pContext Optional output. If NULL != pContext,
  12501. // it contains either a PCCERT_CONTEXT or PCCRL_CONTEXT,
  12502. // or PCCTL_CONTEXT based on the content type.
  12503. //
  12504. // If the content type is CERT_QUERY_CONTENT_CERT or
  12505. // CERT_QUERY_CONTENT_SERIALIZED_CERT, it is a PCCERT_CONTEXT;
  12506. // Caller should free the pContext via CertFreeCertificateContext.
  12507. //
  12508. // If the content type is CERT_QUERY_CONTENT_CRL or
  12509. // CERT_QUERY_CONTENT_SERIALIZED_CRL, it is a PCCRL_CONTEXT;
  12510. // Caller should free the pContext via CertFreeCRLContext.
  12511. //
  12512. // If the content type is CERT_QUERY_CONTENT_CTL or
  12513. // CERT_QUERY_CONTENT_SERIALIZED_CTL, it is a PCCTL_CONTEXT;
  12514. // Caller should free the pContext via CertFreeCTLContext.
  12515. //
  12516. // If the *pbObject is of type CERT_QUERY_CONTENT_PKCS10 or CERT_QUERY_CONTENT_PFX, CryptQueryObject
  12517. // will not return anything in *phCertstore, *phMsg, or *ppvContext.
  12518. //--------------------------------------------------------------------------
  12519. function CryptQueryObject(dwObjectType: DWORD; pvObject: Pointer;
  12520. dwExpectedContentTypeFlags, dwExpectedFormatTypeFlags, dwFlags: DWORD;
  12521. pdwMsgAndCertEncodingType, pdwContentType, pdwFormatType: LPDWORD;
  12522. phCertStore: PHCERTSTORE; phMsg: PHCRYPTMSG; ppvContext: PPointer): BOOL; stdcall;
  12523. {$EXTERNALSYM CryptQueryObject}
  12524. //-------------------------------------------------------------------------
  12525. //dwObjectType for CryptQueryObject
  12526. //-------------------------------------------------------------------------
  12527. const
  12528. CERT_QUERY_OBJECT_FILE = $00000001;
  12529. {$EXTERNALSYM CERT_QUERY_OBJECT_FILE}
  12530. CERT_QUERY_OBJECT_BLOB = $00000002;
  12531. {$EXTERNALSYM CERT_QUERY_OBJECT_BLOB}
  12532. //-------------------------------------------------------------------------
  12533. //dwConentType for CryptQueryObject
  12534. //-------------------------------------------------------------------------
  12535. //encoded single certificate
  12536. CERT_QUERY_CONTENT_CERT = 1;
  12537. {$EXTERNALSYM CERT_QUERY_CONTENT_CERT}
  12538. //encoded single CTL
  12539. CERT_QUERY_CONTENT_CTL = 2;
  12540. {$EXTERNALSYM CERT_QUERY_CONTENT_CTL}
  12541. //encoded single CRL
  12542. CERT_QUERY_CONTENT_CRL = 3;
  12543. {$EXTERNALSYM CERT_QUERY_CONTENT_CRL}
  12544. //serialized store
  12545. CERT_QUERY_CONTENT_SERIALIZED_STORE = 4;
  12546. {$EXTERNALSYM CERT_QUERY_CONTENT_SERIALIZED_STORE}
  12547. //serialized single certificate
  12548. CERT_QUERY_CONTENT_SERIALIZED_CERT = 5;
  12549. {$EXTERNALSYM CERT_QUERY_CONTENT_SERIALIZED_CERT}
  12550. //serialized single CTL
  12551. CERT_QUERY_CONTENT_SERIALIZED_CTL = 6;
  12552. {$EXTERNALSYM CERT_QUERY_CONTENT_SERIALIZED_CTL}
  12553. //serialized single CRL
  12554. CERT_QUERY_CONTENT_SERIALIZED_CRL = 7;
  12555. {$EXTERNALSYM CERT_QUERY_CONTENT_SERIALIZED_CRL}
  12556. //a PKCS#7 signed message
  12557. CERT_QUERY_CONTENT_PKCS7_SIGNED = 8;
  12558. {$EXTERNALSYM CERT_QUERY_CONTENT_PKCS7_SIGNED}
  12559. //a PKCS#7 message, such as enveloped message. But it is not a signed message,
  12560. CERT_QUERY_CONTENT_PKCS7_UNSIGNED = 9;
  12561. {$EXTERNALSYM CERT_QUERY_CONTENT_PKCS7_UNSIGNED}
  12562. //a PKCS7 signed message embedded in a file
  12563. CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED = 10;
  12564. {$EXTERNALSYM CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED}
  12565. //an encoded PKCS#10
  12566. CERT_QUERY_CONTENT_PKCS10 = 11;
  12567. {$EXTERNALSYM CERT_QUERY_CONTENT_PKCS10}
  12568. //an encoded PKX BLOB
  12569. CERT_QUERY_CONTENT_PFX = 12;
  12570. {$EXTERNALSYM CERT_QUERY_CONTENT_PFX}
  12571. //-------------------------------------------------------------------------
  12572. //dwExpectedConentTypeFlags for CryptQueryObject
  12573. //-------------------------------------------------------------------------
  12574. //encoded single certificate
  12575. CERT_QUERY_CONTENT_FLAG_CERT = 1 shl CERT_QUERY_CONTENT_CERT;
  12576. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_CERT}
  12577. //encoded single CTL
  12578. CERT_QUERY_CONTENT_FLAG_CTL = 1 shl CERT_QUERY_CONTENT_CTL;
  12579. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_CTL}
  12580. //encoded single CRL
  12581. CERT_QUERY_CONTENT_FLAG_CRL = 1 shl CERT_QUERY_CONTENT_CRL;
  12582. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_CRL}
  12583. //serialized store
  12584. CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE = 1 shl CERT_QUERY_CONTENT_SERIALIZED_STORE;
  12585. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE}
  12586. //serialized single certificate
  12587. CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT = 1 shl CERT_QUERY_CONTENT_SERIALIZED_CERT;
  12588. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT}
  12589. //serialized single CTL
  12590. CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL = 1 shl CERT_QUERY_CONTENT_SERIALIZED_CTL;
  12591. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL}
  12592. //serialized single CRL
  12593. CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL = 1 shl CERT_QUERY_CONTENT_SERIALIZED_CRL;
  12594. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL}
  12595. //an encoded PKCS#7 signed message
  12596. CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED = 1 shl CERT_QUERY_CONTENT_PKCS7_SIGNED;
  12597. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED}
  12598. //an encoded PKCS#7 message. But it is not a signed message
  12599. CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED = 1 shl CERT_QUERY_CONTENT_PKCS7_UNSIGNED;
  12600. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED}
  12601. //the content includes an embedded PKCS7 signed message
  12602. CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED = 1 shl CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED;
  12603. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED}
  12604. //an encoded PKCS#10
  12605. CERT_QUERY_CONTENT_FLAG_PKCS10 = 1 shl CERT_QUERY_CONTENT_PKCS10;
  12606. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_PKCS10}
  12607. //an encoded PFX BLOB
  12608. CERT_QUERY_CONTENT_FLAG_PFX = 1 shl CERT_QUERY_CONTENT_PFX;
  12609. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_PFX}
  12610. //content can be any type
  12611. CERT_QUERY_CONTENT_FLAG_ALL = CERT_QUERY_CONTENT_FLAG_CERT or
  12612. CERT_QUERY_CONTENT_FLAG_CTL or
  12613. CERT_QUERY_CONTENT_FLAG_CRL or
  12614. CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE or
  12615. CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT or
  12616. CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL or
  12617. CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL or
  12618. CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED or
  12619. CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED or
  12620. CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED or
  12621. CERT_QUERY_CONTENT_FLAG_PKCS10 or
  12622. CERT_QUERY_CONTENT_FLAG_PFX;
  12623. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_ALL}
  12624. //-------------------------------------------------------------------------
  12625. //dwFormatType for CryptQueryObject
  12626. //-------------------------------------------------------------------------
  12627. //the content is in binary format
  12628. CERT_QUERY_FORMAT_BINARY = 1;
  12629. {$EXTERNALSYM CERT_QUERY_FORMAT_BINARY}
  12630. //the content is base64 encoded
  12631. CERT_QUERY_FORMAT_BASE64_ENCODED = 2;
  12632. {$EXTERNALSYM CERT_QUERY_FORMAT_BASE64_ENCODED}
  12633. //-------------------------------------------------------------------------
  12634. //dwExpectedFormatTypeFlags for CryptQueryObject
  12635. //-------------------------------------------------------------------------
  12636. //the content is in binary format
  12637. CERT_QUERY_FORMAT_FLAG_BINARY = 1 shl CERT_QUERY_FORMAT_BINARY;
  12638. {$EXTERNALSYM CERT_QUERY_FORMAT_FLAG_BINARY}
  12639. //the content is base64 encoded
  12640. CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED = 1 shl CERT_QUERY_FORMAT_BASE64_ENCODED;
  12641. {$EXTERNALSYM CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED}
  12642. //the content can be of any format
  12643. CERT_QUERY_FORMAT_FLAG_ALL = CERT_QUERY_FORMAT_FLAG_BINARY or CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED;
  12644. {$EXTERNALSYM CERT_QUERY_FORMAT_FLAG_ALL}
  12645. //
  12646. // Crypt32 Memory Management Routines. All Crypt32 API which return allocated
  12647. // buffers will do so via CryptMemAlloc, CryptMemRealloc. Clients can free
  12648. // those buffers using CryptMemFree. Also included is CryptMemSize
  12649. //
  12650. function CryptMemAlloc(cbSize: ULONG): LPVOID; stdcall;
  12651. {$EXTERNALSYM CryptMemAlloc}
  12652. function CryptMemRealloc(pv: LPVOID; cbSize: ULONG): LPVOID; stdcall;
  12653. {$EXTERNALSYM CryptMemRealloc}
  12654. procedure CryptMemFree(pv: LPVOID); stdcall;
  12655. {$EXTERNALSYM CryptMemFree}
  12656. //
  12657. // Crypt32 Asynchronous Parameter Management Routines. All Crypt32 API which
  12658. // expose asynchronous mode operation use a Crypt32 Async Handle to pass
  12659. // around information about the operation e.g. callback routines. The
  12660. // following API are used for manipulation of the async handle
  12661. //
  12662. type
  12663. HCRYPTASYNC = HANDLE;
  12664. {$EXTERNALSYM HCRYPTASYNC}
  12665. PHCRYPTASYNC = ^HCRYPTASYNC;
  12666. {$EXTERNALSYM PHCRYPTASYNC}
  12667. PFN_CRYPT_ASYNC_PARAM_FREE_FUNC = procedure(pszParamOid: LPSTR; pvParam: LPVOID); stdcall;
  12668. {$EXTERNALSYM PFN_CRYPT_ASYNC_PARAM_FREE_FUNC}
  12669. PFnCryptAsyncParamFreeFunc = PFN_CRYPT_ASYNC_PARAM_FREE_FUNC;
  12670. function CryptCreateAsyncHandle(dwFlags: DWORD; phAsync: PHCRYPTASYNC): BOOL; stdcall;
  12671. {$EXTERNALSYM CryptCreateAsyncHandle}
  12672. function CryptSetAsyncParam(hAsync: HCRYPTASYNC; pszParamOid: LPSTR;
  12673. pvParam: LPVOID; pfnFree: PFN_CRYPT_ASYNC_PARAM_FREE_FUNC): BOOL; stdcall;
  12674. {$EXTERNALSYM CryptSetAsyncParam}
  12675. function CryptGetAsyncParam(hAsync: HCRYPTASYNC; pszParamOid: LPSTR;
  12676. var ppvParam: LPVOID; var ppfnFree: PFN_CRYPT_ASYNC_PARAM_FREE_FUNC): BOOL; stdcall;
  12677. {$EXTERNALSYM CryptGetAsyncParam}
  12678. function CryptCloseAsyncHandle(hAsync: HCRYPTASYNC): BOOL; stdcall;
  12679. {$EXTERNALSYM CryptCloseAsyncHandle}
  12680. //
  12681. // Crypt32 Remote Object Retrieval Routines. This API allows retrieval of
  12682. // remote PKI objects where the location is given by an URL. The remote
  12683. // object retrieval manager exposes two provider models. One is the "Scheme
  12684. // Provider" model which allows for installable protocol providers as defined
  12685. // by the URL scheme e.g. ldap, http, ftp. The scheme provider entry point is
  12686. // the same as the CryptRetrieveObjectByUrl however the *ppvObject returned
  12687. // is ALWAYS a counted array of encoded bits (one per object retrieved). The
  12688. // second provider model is the "Context Provider" model which allows for
  12689. // installable creators of CAPI2 context handles (objects) based on the
  12690. // retrieved encoded bits. These are dispatched based on the object OID given
  12691. // in the call to CryptRetrieveObjectByUrl.
  12692. //
  12693. type
  12694. PCRYPT_BLOB_ARRAY = ^CRYPT_BLOB_ARRAY;
  12695. {$EXTERNALSYM PCRYPT_BLOB_ARRAY}
  12696. _CRYPT_BLOB_ARRAY = record
  12697. cBlob: DWORD;
  12698. rgBlob: PCRYPT_DATA_BLOB;
  12699. end;
  12700. {$EXTERNALSYM _CRYPT_BLOB_ARRAY}
  12701. CRYPT_BLOB_ARRAY = _CRYPT_BLOB_ARRAY;
  12702. {$EXTERNALSYM CRYPT_BLOB_ARRAY}
  12703. TCryptBlobArray = CRYPT_BLOB_ARRAY;
  12704. PCryptBlobArray = PCRYPT_BLOB_ARRAY;
  12705. PCRYPT_CREDENTIALS = ^CRYPT_CREDENTIALS;
  12706. {$EXTERNALSYM PCRYPT_CREDENTIALS}
  12707. _CRYPT_CREDENTIALS = record
  12708. cbSize: DWORD;
  12709. pszCredentialsOid: LPCSTR;
  12710. pvCredentials: LPVOID;
  12711. end;
  12712. {$EXTERNALSYM _CRYPT_CREDENTIALS}
  12713. CRYPT_CREDENTIALS = _CRYPT_CREDENTIALS;
  12714. {$EXTERNALSYM CRYPT_CREDENTIALS}
  12715. TCryptCredentials = CRYPT_CREDENTIALS;
  12716. PCryptCredentials = PCRYPT_CREDENTIALS;
  12717. const
  12718. CREDENTIAL_OID_PASSWORD_CREDENTIALS_A = LPCSTR(1);
  12719. {$EXTERNALSYM CREDENTIAL_OID_PASSWORD_CREDENTIALS_A}
  12720. CREDENTIAL_OID_PASSWORD_CREDENTIALS_W = LPCSTR(2);
  12721. {$EXTERNALSYM CREDENTIAL_OID_PASSWORD_CREDENTIALS_W}
  12722. {$IFDEF UNICODE}
  12723. CREDENTIAL_OID_PASSWORD_CREDENTIALS = CREDENTIAL_OID_PASSWORD_CREDENTIALS_W;
  12724. {$EXTERNALSYM CREDENTIAL_OID_PASSWORD_CREDENTIALS}
  12725. {$ELSE}
  12726. CREDENTIAL_OID_PASSWORD_CREDENTIALS = CREDENTIAL_OID_PASSWORD_CREDENTIALS_A;
  12727. {$EXTERNALSYM CREDENTIAL_OID_PASSWORD_CREDENTIALS}
  12728. {$ENDIF UNICODE}
  12729. type
  12730. PCRYPT_PASSWORD_CREDENTIALSA = ^CRYPT_PASSWORD_CREDENTIALSA;
  12731. {$EXTERNALSYM PCRYPT_PASSWORD_CREDENTIALSA}
  12732. _CRYPT_PASSWORD_CREDENTIALSA = record
  12733. cbSize: DWORD;
  12734. pszUsername: LPSTR;
  12735. pszPassword: LPSTR;
  12736. end;
  12737. {$EXTERNALSYM _CRYPT_PASSWORD_CREDENTIALSA}
  12738. CRYPT_PASSWORD_CREDENTIALSA = _CRYPT_PASSWORD_CREDENTIALSA;
  12739. {$EXTERNALSYM CRYPT_PASSWORD_CREDENTIALSA}
  12740. TCryptPasswordCredentialsA = CRYPT_PASSWORD_CREDENTIALSA;
  12741. PCryptPasswordCredentialsA = PCRYPT_PASSWORD_CREDENTIALSA;
  12742. PCRYPT_PASSWORD_CREDENTIALSW = ^CRYPT_PASSWORD_CREDENTIALSW;
  12743. {$EXTERNALSYM PCRYPT_PASSWORD_CREDENTIALSW}
  12744. _CRYPT_PASSWORD_CREDENTIALSW = record
  12745. cbSize: DWORD;
  12746. pszUsername: LPWSTR;
  12747. pszPassword: LPWSTR;
  12748. end;
  12749. {$EXTERNALSYM _CRYPT_PASSWORD_CREDENTIALSW}
  12750. CRYPT_PASSWORD_CREDENTIALSW = _CRYPT_PASSWORD_CREDENTIALSW;
  12751. {$EXTERNALSYM CRYPT_PASSWORD_CREDENTIALSW}
  12752. TCryptPasswordCredentialsW = CRYPT_PASSWORD_CREDENTIALSW;
  12753. PCryptPasswordCredentialsW = PCRYPT_PASSWORD_CREDENTIALSW;
  12754. {$IFDEF UNICODE}
  12755. CRYPT_PASSWORD_CREDENTIALS = CRYPT_PASSWORD_CREDENTIALSW;
  12756. {$EXTERNALSYM CRYPT_PASSWORD_CREDENTIALS}
  12757. PCRYPT_PASSWORD_CREDENTIALS = PCRYPT_PASSWORD_CREDENTIALSW;
  12758. {$EXTERNALSYM PCRYPT_PASSWORD_CREDENTIALS}
  12759. TCryptPasswordCredentials = TCryptPasswordCredentialsW;
  12760. PCryptPasswordCredentials = PCryptPasswordCredentialsW;
  12761. {$ELSE}
  12762. CRYPT_PASSWORD_CREDENTIALS = CRYPT_PASSWORD_CREDENTIALSA;
  12763. {$EXTERNALSYM CRYPT_PASSWORD_CREDENTIALS}
  12764. PCRYPT_PASSWORD_CREDENTIALS = PCRYPT_PASSWORD_CREDENTIALSA;
  12765. {$EXTERNALSYM PCRYPT_PASSWORD_CREDENTIALS}
  12766. TCryptPasswordCredentials = TCryptPasswordCredentialsA;
  12767. PCryptPasswordCredentials = PCryptPasswordCredentialsA;
  12768. {$ENDIF UNICODE}
  12769. //
  12770. // Scheme Provider Signatures
  12771. //
  12772. const
  12773. SCHEME_OID_RETRIEVE_ENCODED_OBJECT_FUNC = 'SchemeDllRetrieveEncodedObject';
  12774. {$EXTERNALSYM SCHEME_OID_RETRIEVE_ENCODED_OBJECT_FUNC}
  12775. type
  12776. PFN_FREE_ENCODED_OBJECT_FUNC = procedure(pszObjectOid: LPCSTR;
  12777. pObject: PCRYPT_BLOB_ARRAY; pvFreeContext: LPVOID); stdcall;
  12778. {$EXTERNALSYM PFN_FREE_ENCODED_OBJECT_FUNC}
  12779. PFnFreeEncodedObjectFunc = PFN_FREE_ENCODED_OBJECT_FUNC;
  12780. //
  12781. // SchemeDllRetrieveEncodedObject has the following signature:
  12782. //
  12783. // BOOL WINAPI SchemeDllRetrieveEncodedObject (
  12784. // IN LPCSTR pszUrl,
  12785. // IN LPCSTR pszObjectOid,
  12786. // IN DWORD dwRetrievalFlags,
  12787. // IN DWORD dwTimeout,
  12788. // OUT PCRYPT_BLOB_ARRAY pObject,
  12789. // OUT PFN_FREE_ENCODED_OBJECT_FUNC* ppfnFreeObject,
  12790. // OUT LPVOID* ppvFreeContext,
  12791. // IN HCRYPTASYNC hAsyncRetrieve,
  12792. // IN PCRYPT_CREDENTIALS pCredentials,
  12793. // IN LPVOID pvReserved
  12794. // )
  12795. //
  12796. //
  12797. // Context Provider Signatures
  12798. //
  12799. const
  12800. CONTEXT_OID_CREATE_OBJECT_CONTEXT_FUNC = 'ContextDllCreateObjectContext';
  12801. {$EXTERNALSYM CONTEXT_OID_CREATE_OBJECT_CONTEXT_FUNC}
  12802. CONTEXT_OID_CERTIFICATE = LPCSTR(1);
  12803. {$EXTERNALSYM CONTEXT_OID_CERTIFICATE}
  12804. CONTEXT_OID_CRL = LPCSTR(2);
  12805. {$EXTERNALSYM CONTEXT_OID_CRL}
  12806. CONTEXT_OID_CTL = LPCSTR(3);
  12807. {$EXTERNALSYM CONTEXT_OID_CTL}
  12808. CONTEXT_OID_PKCS7 = LPCSTR(4);
  12809. {$EXTERNALSYM CONTEXT_OID_PKCS7}
  12810. CONTEXT_OID_CAPI2_ANY = LPCSTR(5);
  12811. {$EXTERNALSYM CONTEXT_OID_CAPI2_ANY}
  12812. //
  12813. // ContextDllCreateObjectContext has the following signature:
  12814. //
  12815. // BOOL WINAPI ContextDllCreateObjectContext (
  12816. // IN LPCSTR pszObjectOid,
  12817. // IN DWORD dwRetrievalFlags,
  12818. // IN PCRYPT_BLOB_ARRAY pObject,
  12819. // OUT LPVOID* ppvContext
  12820. // )
  12821. //
  12822. //
  12823. // Remote Object Retrieval API
  12824. //
  12825. //
  12826. // Retrieval flags
  12827. //
  12828. CRYPT_RETRIEVE_MULTIPLE_OBJECTS = $00000001;
  12829. {$EXTERNALSYM CRYPT_RETRIEVE_MULTIPLE_OBJECTS}
  12830. CRYPT_CACHE_ONLY_RETRIEVAL = $00000002;
  12831. {$EXTERNALSYM CRYPT_CACHE_ONLY_RETRIEVAL}
  12832. CRYPT_WIRE_ONLY_RETRIEVAL = $00000004;
  12833. {$EXTERNALSYM CRYPT_WIRE_ONLY_RETRIEVAL}
  12834. CRYPT_DONT_CACHE_RESULT = $00000008;
  12835. {$EXTERNALSYM CRYPT_DONT_CACHE_RESULT}
  12836. CRYPT_ASYNC_RETRIEVAL = $00000010;
  12837. {$EXTERNALSYM CRYPT_ASYNC_RETRIEVAL}
  12838. //
  12839. // Data verification retrieval flags
  12840. //
  12841. // CRYPT_VERIFY_CONTEXT_SIGNATURE is used to get signature verification
  12842. // on the context created. In this case pszObjectOid must be non-NULL and
  12843. // pvVerify points to the signer certificate context
  12844. //
  12845. // CRYPT_VERIFY_DATA_HASH is used to get verification of the blob data
  12846. // retrieved by the protocol. The pvVerify points to an URL_DATA_HASH
  12847. // structure (TBD)
  12848. //
  12849. CRYPT_VERIFY_CONTEXT_SIGNATURE = $00000020;
  12850. {$EXTERNALSYM CRYPT_VERIFY_CONTEXT_SIGNATURE}
  12851. CRYPT_VERIFY_DATA_HASH = $00000040;
  12852. {$EXTERNALSYM CRYPT_VERIFY_DATA_HASH}
  12853. //
  12854. // Time Valid Object flags
  12855. //
  12856. CRYPT_KEEP_TIME_VALID = $00000080;
  12857. {$EXTERNALSYM CRYPT_KEEP_TIME_VALID}
  12858. CRYPT_DONT_VERIFY_SIGNATURE = $00000100;
  12859. {$EXTERNALSYM CRYPT_DONT_VERIFY_SIGNATURE}
  12860. CRYPT_DONT_CHECK_TIME_VALIDITY = $00000200;
  12861. {$EXTERNALSYM CRYPT_DONT_CHECK_TIME_VALIDITY}
  12862. function CryptRetrieveObjectByUrlA(pszUrl: LPCSTR; pszObjectOid: LPCSTR;
  12863. dwRetrievalFlags: DWORD; dwTimeout: DWORD; var ppvObject: LPVOID;
  12864. hAsyncRetrieve: HCRYPTASYNC; pCredentials: PCRYPT_CREDENTIALS;
  12865. pvVerify: LPVOID; pvReserved: LPVOID): BOOL; stdcall;
  12866. {$EXTERNALSYM CryptRetrieveObjectByUrlA}
  12867. function CryptRetrieveObjectByUrlW(pszUrl: LPCWSTR; pszObjectOid: LPCSTR;
  12868. dwRetrievalFlags: DWORD; dwTimeout: DWORD; var ppvObject: LPVOID;
  12869. hAsyncRetrieve: HCRYPTASYNC; pCredentials: PCRYPT_CREDENTIALS;
  12870. pvVerify: LPVOID; pvReserved: LPVOID): BOOL; stdcall;
  12871. {$EXTERNALSYM CryptRetrieveObjectByUrlW}
  12872. function CryptRetrieveObjectByUrl(pszUrl: LPCTSTR; pszObjectOid: LPCSTR;
  12873. dwRetrievalFlags: DWORD; dwTimeout: DWORD; var ppvObject: LPVOID;
  12874. hAsyncRetrieve: HCRYPTASYNC; pCredentials: PCRYPT_CREDENTIALS;
  12875. pvVerify: LPVOID; pvReserved: LPVOID): BOOL; stdcall;
  12876. {$EXTERNALSYM CryptRetrieveObjectByUrl}
  12877. //
  12878. // Call back function to cancel object retrieval
  12879. //
  12880. // The function can be installed on a per thread basis.
  12881. // If CryptInstallCancelRetrieval is called for multiple times, only the most recent
  12882. // installation will be kept.
  12883. //
  12884. // This is only effective for http, https, gopher, and ftp protocol.
  12885. // It is ignored by the rest of the protocols.
  12886. type
  12887. PFN_CRYPT_CANCEL_RETRIEVAL = function(dwFlags: DWORD; pvArg: Pointer): BOOL; stdcall;
  12888. {$EXTERNALSYM PFN_CRYPT_CANCEL_RETRIEVAL}
  12889. PFnCryptCancelRetrieval = PFN_CRYPT_CANCEL_RETRIEVAL;
  12890. //
  12891. // PFN_CRYPT_CANCEL_RETRIEVAL
  12892. //
  12893. // This function should return FALSE when the object retrieval should be continued
  12894. // and return TRUE when the object retrieval should be cancelled.
  12895. //
  12896. function CryptInstallCancelRetrieval(pfnCancel: PFN_CRYPT_CANCEL_RETRIEVAL;
  12897. pvArg: Pointer; dwFlags: DWORD; pvReserved: Pointer): BOOL; stdcall;
  12898. {$EXTERNALSYM CryptInstallCancelRetrieval}
  12899. function CryptUninstallCancelRetrieval(dwFlags: DWORD; pvReserved: Pointer): BOOL; stdcall;
  12900. {$EXTERNALSYM CryptUninstallCancelRetrieval}
  12901. function CryptCancelAsyncRetrieval(hAsyncRetrieval: HCRYPTASYNC): BOOL; stdcall;
  12902. {$EXTERNALSYM CryptCancelAsyncRetrieval}
  12903. //
  12904. // Remote Object Async Retrieval parameters
  12905. //
  12906. //
  12907. // A client that wants to be notified of asynchronous object retrieval
  12908. // completion sets this parameter on the async handle
  12909. //
  12910. const
  12911. CRYPT_PARAM_ASYNC_RETRIEVAL_COMPLETION = LPCSTR(1);
  12912. {$EXTERNALSYM CRYPT_PARAM_ASYNC_RETRIEVAL_COMPLETION}
  12913. type
  12914. PFN_CRYPT_ASYNC_RETRIEVAL_COMPLETION_FUNC = procedure(pvCompletion: LPVOID;
  12915. dwCompletionCode: DWORD; pszUrl: LPCSTR; pszObjectOid: LPSTR; pvObject: LPVOID); stdcall;
  12916. {$EXTERNALSYM PFN_CRYPT_ASYNC_RETRIEVAL_COMPLETION_FUNC}
  12917. PFnCryptASynchRetrievalCompletionFunc = PFN_CRYPT_ASYNC_RETRIEVAL_COMPLETION_FUNC;
  12918. PCRYPT_ASYNC_RETRIEVAL_COMPLETION = ^CRYPT_ASYNC_RETRIEVAL_COMPLETION;
  12919. {$EXTERNALSYM PCRYPT_ASYNC_RETRIEVAL_COMPLETION}
  12920. _CRYPT_ASYNC_RETRIEVAL_COMPLETION = record
  12921. pfnCompletion: PFN_CRYPT_ASYNC_RETRIEVAL_COMPLETION_FUNC;
  12922. pvCompletion: LPVOID;
  12923. end;
  12924. {$EXTERNALSYM _CRYPT_ASYNC_RETRIEVAL_COMPLETION}
  12925. CRYPT_ASYNC_RETRIEVAL_COMPLETION = _CRYPT_ASYNC_RETRIEVAL_COMPLETION;
  12926. {$EXTERNALSYM CRYPT_ASYNC_RETRIEVAL_COMPLETION}
  12927. TCryptAsyncRetrievalCompletion = CRYPT_ASYNC_RETRIEVAL_COMPLETION;
  12928. PCryptAsyncRetrievalCompletion = PCRYPT_ASYNC_RETRIEVAL_COMPLETION;
  12929. //
  12930. // This function is set on the async handle by a scheme provider that
  12931. // supports asynchronous retrieval
  12932. //
  12933. const
  12934. CRYPT_PARAM_CANCEL_ASYNC_RETRIEVAL = LPCSTR(2);
  12935. {$EXTERNALSYM CRYPT_PARAM_CANCEL_ASYNC_RETRIEVAL}
  12936. type
  12937. PFN_CANCEL_ASYNC_RETRIEVAL_FUNC = function(hAsyncRetrieve: HCRYPTASYNC): BOOL; stdcall;
  12938. {$EXTERNALSYM PFN_CANCEL_ASYNC_RETRIEVAL_FUNC}
  12939. PFnCancelASynchRetrievalFunc = PFN_CANCEL_ASYNC_RETRIEVAL_FUNC;
  12940. //
  12941. // Get the locator for a CAPI object
  12942. //
  12943. const
  12944. CRYPT_GET_URL_FROM_PROPERTY = $00000001;
  12945. {$EXTERNALSYM CRYPT_GET_URL_FROM_PROPERTY}
  12946. CRYPT_GET_URL_FROM_EXTENSION = $00000002;
  12947. {$EXTERNALSYM CRYPT_GET_URL_FROM_EXTENSION}
  12948. CRYPT_GET_URL_FROM_UNAUTH_ATTRIBUTE = $00000004;
  12949. {$EXTERNALSYM CRYPT_GET_URL_FROM_UNAUTH_ATTRIBUTE}
  12950. CRYPT_GET_URL_FROM_AUTH_ATTRIBUTE = $00000008;
  12951. {$EXTERNALSYM CRYPT_GET_URL_FROM_AUTH_ATTRIBUTE}
  12952. type
  12953. PCRYPT_URL_ARRAY = ^CRYPT_URL_ARRAY;
  12954. {$EXTERNALSYM PCRYPT_URL_ARRAY}
  12955. _CRYPT_URL_ARRAY = record
  12956. cUrl: DWORD;
  12957. rgwszUrl: LPWSTR;
  12958. end;
  12959. {$EXTERNALSYM _CRYPT_URL_ARRAY}
  12960. CRYPT_URL_ARRAY = _CRYPT_URL_ARRAY;
  12961. {$EXTERNALSYM CRYPT_URL_ARRAY}
  12962. TCryptUrlArray = CRYPT_URL_ARRAY;
  12963. PCryptUrlArray = PCRYPT_URL_ARRAY;
  12964. PCRYPT_URL_INFO = ^CRYPT_URL_INFO;
  12965. {$EXTERNALSYM PCRYPT_URL_INFO}
  12966. _CRYPT_URL_INFO = record
  12967. cbSize: DWORD;
  12968. end;
  12969. {$EXTERNALSYM _CRYPT_URL_INFO}
  12970. CRYPT_URL_INFO = _CRYPT_URL_INFO;
  12971. {$EXTERNALSYM CRYPT_URL_INFO}
  12972. TCryptUrlInfo = CRYPT_URL_INFO;
  12973. PCryptUrlInfo = PCRYPT_URL_INFO;
  12974. function CryptGetObjectUrl(pszUrlOid: LPCSTR; pvPara: LPVOID; dwFlags: DWORD;
  12975. pUrlArray: PCRYPT_URL_ARRAY; var pcbUrlArray: DWORD; pUrlInfo: PCRYPT_URL_INFO;
  12976. pcbUrlInfo: LPDWORD; pvReserved: LPVOID): BOOL; stdcall;
  12977. {$EXTERNALSYM CryptGetObjectUrl}
  12978. const
  12979. URL_OID_GET_OBJECT_URL_FUNC = 'UrlDllGetObjectUrl';
  12980. {$EXTERNALSYM URL_OID_GET_OBJECT_URL_FUNC}
  12981. //
  12982. // UrlDllGetObjectUrl has the same signature as CryptGetObjectUrl
  12983. //
  12984. //
  12985. // URL_OID_CERTIFICATE_ISSUER
  12986. //
  12987. // pvPara == PCCERT_CONTEXT, certificate whose issuer's URL is being requested
  12988. //
  12989. // This will be retrieved from the authority info access extension or property
  12990. // on the certificate
  12991. //
  12992. // URL_OID_CERTIFICATE_CRL_DIST_POINT
  12993. //
  12994. // pvPara == PCCERT_CONTEXT, certificate whose CRL distribution point is being
  12995. // requested
  12996. //
  12997. // This will be retrieved from the CRL distribution point extension or property
  12998. // on the certificate
  12999. //
  13000. // URL_OID_CTL_ISSUER
  13001. //
  13002. // pvPara == PCCTL_CONTEXT, Signer Index, CTL whose issuer's URL (identified
  13003. // by the signer index) is being requested
  13004. //
  13005. // This will be retrieved from an authority info access attribute method encoded
  13006. // in each signer info in the PKCS7 (CTL)
  13007. //
  13008. // URL_OID_CTL_NEXT_UPDATE
  13009. //
  13010. // pvPara == PCCTL_CONTEXT, Signer Index, CTL whose next update URL is being
  13011. // requested and an optional signer index in case we need to check signer
  13012. // info attributes
  13013. //
  13014. // This will be retrieved from an authority info access CTL extension, property,
  13015. // or signer info attribute method
  13016. //
  13017. // URL_OID_CRL_ISSUER
  13018. //
  13019. // pvPara == PCCRL_CONTEXT, CRL whose issuer's URL is being requested
  13020. //
  13021. // This will be retrieved from a property on the CRL which has been inherited
  13022. // from the subject cert (either from the subject cert issuer or the subject
  13023. // cert distribution point extension). It will be encoded as an authority
  13024. // info access extension method.
  13025. //
  13026. const
  13027. URL_OID_CERTIFICATE_ISSUER = LPCSTR(1);
  13028. {$EXTERNALSYM URL_OID_CERTIFICATE_ISSUER}
  13029. URL_OID_CERTIFICATE_CRL_DIST_POINT = LPCSTR(2);
  13030. {$EXTERNALSYM URL_OID_CERTIFICATE_CRL_DIST_POINT}
  13031. URL_OID_CTL_ISSUER = LPCSTR(3);
  13032. {$EXTERNALSYM URL_OID_CTL_ISSUER}
  13033. URL_OID_CTL_NEXT_UPDATE = LPCSTR(4);
  13034. {$EXTERNALSYM URL_OID_CTL_NEXT_UPDATE}
  13035. URL_OID_CRL_ISSUER = LPCSTR(5);
  13036. {$EXTERNALSYM URL_OID_CRL_ISSUER}
  13037. //
  13038. // Get a time valid CAPI2 object
  13039. //
  13040. function CryptGetTimeValidObject(pszTimeValidOid: LPCSTR; pvPara: LPVOID;
  13041. pIssuer: PCCERT_CONTEXT; pftValidFor: LPFILETIME; dwFlags, dwTimeout: DWORD;
  13042. ppvObject: LPLPVOID; pCredentials: PCRYPT_CREDENTIALS; pvReserved: LPVOID): BOOL; stdcall;
  13043. {$EXTERNALSYM CryptGetTimeValidObject}
  13044. const
  13045. TIME_VALID_OID_GET_OBJECT_FUNC = 'TimeValidDllGetObject';
  13046. {$EXTERNALSYM TIME_VALID_OID_GET_OBJECT_FUNC}
  13047. //
  13048. // TimeValidDllGetObject has the same signature as CryptGetTimeValidObject
  13049. //
  13050. //
  13051. // TIME_VALID_OID_GET_CTL
  13052. //
  13053. // pvPara == PCCTL_CONTEXT, the current CTL
  13054. //
  13055. // TIME_VALID_OID_GET_CRL
  13056. //
  13057. // pvPara == PCCRL_CONTEXT, the current CRL
  13058. //
  13059. // TIME_VALID_OID_GET_CRL_FROM_CERT
  13060. //
  13061. // pvPara == PCCERT_CONTEXT, the subject cert
  13062. //
  13063. TIME_VALID_OID_GET_CTL = LPCSTR(1);
  13064. {$EXTERNALSYM TIME_VALID_OID_GET_CTL}
  13065. TIME_VALID_OID_GET_CRL = LPCSTR(2);
  13066. {$EXTERNALSYM TIME_VALID_OID_GET_CRL}
  13067. TIME_VALID_OID_GET_CRL_FROM_CERT = LPCSTR(3);
  13068. {$EXTERNALSYM TIME_VALID_OID_GET_CRL_FROM_CERT}
  13069. function CryptFlushTimeValidObject(pszFlushTimeValidOid: LPCSTR; pvPara: LPVOID;
  13070. pIssuer: PCCERT_CONTEXT; dwFlags: DWORD; pvReserved: LPVOID): BOOL; stdcall;
  13071. {$EXTERNALSYM CryptFlushTimeValidObject}
  13072. const
  13073. TIME_VALID_OID_FLUSH_OBJECT_FUNC = 'TimeValidDllFlushObject';
  13074. {$EXTERNALSYM TIME_VALID_OID_FLUSH_OBJECT_FUNC}
  13075. //
  13076. // TimeValidDllFlushObject has the same signature as CryptFlushTimeValidObject
  13077. //
  13078. //
  13079. // TIME_VALID_OID_FLUSH_CTL
  13080. //
  13081. // pvPara == PCCTL_CONTEXT, the CTL to flush
  13082. //
  13083. // TIME_VALID_OID_FLUSH_CRL
  13084. //
  13085. // pvPara == PCCRL_CONTEXT, the CRL to flush
  13086. //
  13087. // TIME_VALID_OID_FLUSH_CRL_FROM_CERT
  13088. //
  13089. TIME_VALID_OID_FLUSH_CTL = LPCSTR(1);
  13090. {$EXTERNALSYM TIME_VALID_OID_FLUSH_CTL}
  13091. TIME_VALID_OID_FLUSH_CRL = LPCSTR(2);
  13092. {$EXTERNALSYM TIME_VALID_OID_FLUSH_CRL}
  13093. TIME_VALID_OID_FLUSH_CRL_FROM_CERT = LPCSTR(3);
  13094. {$EXTERNALSYM TIME_VALID_OID_FLUSH_CRL_FROM_CERT}
  13095. //-------------------------------------------------------------------------
  13096. // Data Protection APIs
  13097. //-------------------------------------------------------------------------
  13098. //
  13099. // Data protection APIs enable applications to easily secure data.
  13100. //
  13101. // The base provider provides protection based on the users' logon
  13102. // credentials. The data secured with these APIs follow the same
  13103. // roaming characteristics as HKCU -- if HKCU roams, the data
  13104. // protected by the base provider may roam as well. This makes
  13105. // the API ideal for the munging of data stored in the registry.
  13106. //
  13107. //
  13108. // Prompt struct -- what to tell users about the access
  13109. //
  13110. type
  13111. PCRYPTPROTECT_PROMPTSTRUCT = ^CRYPTPROTECT_PROMPTSTRUCT;
  13112. {$EXTERNALSYM PCRYPTPROTECT_PROMPTSTRUCT}
  13113. _CRYPTPROTECT_PROMPTSTRUCT = record
  13114. cbSize: DWORD;
  13115. dwPromptFlags: DWORD;
  13116. hwndApp: HWND;
  13117. szPrompt: LPCWSTR;
  13118. end;
  13119. {$EXTERNALSYM _CRYPTPROTECT_PROMPTSTRUCT}
  13120. CRYPTPROTECT_PROMPTSTRUCT = _CRYPTPROTECT_PROMPTSTRUCT;
  13121. {$EXTERNALSYM CRYPTPROTECT_PROMPTSTRUCT}
  13122. TCryptProtectPromptStruct = CRYPTPROTECT_PROMPTSTRUCT;
  13123. PCryptProtectPromptStruct = PCRYPTPROTECT_PROMPTSTRUCT;
  13124. //
  13125. // base provider action
  13126. //
  13127. const
  13128. CRYPTPROTECT_DEFAULT_PROVIDER: GUID = (
  13129. D1:$df9d8cd0; D2:$1501; D3:$11d1; D4:($8c, $7a, $00, $c0, $4f, $c2, $97, $eb));
  13130. {$EXTERNALSYM CRYPTPROTECT_DEFAULT_PROVIDER}
  13131. //
  13132. // CryptProtect PromptStruct dwPromtFlags
  13133. //
  13134. //
  13135. // prompt on unprotect
  13136. CRYPTPROTECT_PROMPT_ON_UNPROTECT = $1; // 1<<0
  13137. {$EXTERNALSYM CRYPTPROTECT_PROMPT_ON_UNPROTECT}
  13138. //
  13139. // prompt on protect
  13140. CRYPTPROTECT_PROMPT_ON_PROTECT = $2; // 1<<1
  13141. {$EXTERNALSYM CRYPTPROTECT_PROMPT_ON_PROTECT}
  13142. CRYPTPROTECT_PROMPT_RESERVED = $04; // reserved, do not use.
  13143. {$EXTERNALSYM CRYPTPROTECT_PROMPT_RESERVED}
  13144. //
  13145. // only allow strong variant UI protection (user supplied password currently).
  13146. CRYPTPROTECT_PROMPT_STRONG = $08; // 1<<3
  13147. {$EXTERNALSYM CRYPTPROTECT_PROMPT_STRONG}
  13148. //
  13149. // CryptProtectData and CryptUnprotectData dwFlags
  13150. //
  13151. // for remote-access situations where ui is not an option
  13152. // if UI was specified on protect or unprotect operation, the call
  13153. // will fail and GetLastError() will indicate ERROR_PASSWORD_RESTRICTION
  13154. CRYPTPROTECT_UI_FORBIDDEN = $1;
  13155. {$EXTERNALSYM CRYPTPROTECT_UI_FORBIDDEN}
  13156. //
  13157. // per machine protected data -- any user on machine where CryptProtectData
  13158. // took place may CryptUnprotectData
  13159. CRYPTPROTECT_LOCAL_MACHINE = $4;
  13160. {$EXTERNALSYM CRYPTPROTECT_LOCAL_MACHINE}
  13161. //
  13162. // force credential synchronize during CryptProtectData()
  13163. // Synchronize is only operation that occurs during this operation
  13164. CRYPTPROTECT_CRED_SYNC = $8;
  13165. {$EXTERNALSYM CRYPTPROTECT_CRED_SYNC}
  13166. // flags reserved for system use
  13167. CRYPTPROTECT_FIRST_RESERVED_FLAGVAL = $0FFFFFFF;
  13168. {$EXTERNALSYM CRYPTPROTECT_FIRST_RESERVED_FLAGVAL}
  13169. CRYPTPROTECT_LAST_RESERVED_FLAGVAL = DWORD($FFFFFFFF);
  13170. {$EXTERNALSYM CRYPTPROTECT_LAST_RESERVED_FLAGVAL}
  13171. //
  13172. // flags specific to base provider
  13173. //
  13174. function CryptProtectData(pDataIn: PDATA_BLOB; szDataDescr: LPCWSTR;
  13175. pOptionalEntropy: PDATA_BLOB; pvReserved: PVOID;
  13176. pPromptStruct: PCRYPTPROTECT_PROMPTSTRUCT; dwFlags: DWORD; pDataOut: PDATA_BLOB): BOOL; stdcall;
  13177. {$EXTERNALSYM CryptProtectData}
  13178. function CryptUnprotectData(pDataIn: PDATA_BLOB; ppszDataDescr: LPLPWSTR;
  13179. pOptionalEntropy: PDATA_BLOB; pvReserved: PVOID;
  13180. pPromptStruct: PCRYPTPROTECT_PROMPTSTRUCT; dwFlags: DWORD; pDataOut: PDATA_BLOB): BOOL; stdcall;
  13181. {$EXTERNALSYM CryptUnprotectData}
  13182. //+=========================================================================
  13183. // Helper functions to build certificates
  13184. //==========================================================================
  13185. //+-------------------------------------------------------------------------
  13186. //
  13187. // Builds a self-signed certificate and returns a PCCERT_CONTEXT representing
  13188. // the certificate. A hProv must be specified to build the cert context.
  13189. //
  13190. // pSubjectIssuerBlob is the DN for the certifcate. If an alternate subject
  13191. // name is desired it must be specified as an extension in the pExtensions
  13192. // parameter. pSubjectIssuerBlob can NOT be NULL, so minimually an empty DN
  13193. // must be specified.
  13194. //
  13195. // By default:
  13196. // pKeyProvInfo - The CSP is queried for the KeyProvInfo parameters. Only the Provider,
  13197. // Provider Type and Container is queried. Many CSPs don't support these
  13198. // queries and will cause a failure. In such cases the pKeyProvInfo
  13199. // must be specified (RSA BASE works fine).
  13200. //
  13201. // pSignatureAlgorithm - will default to SHA1RSA
  13202. // pStartTime will default to the current time
  13203. // pEndTime will default to 1 year
  13204. // pEntensions will be empty.
  13205. //
  13206. // The returned PCCERT_CONTEXT will reference the private keys by setting the
  13207. // CERT_KEY_PROV_INFO_PROP_ID. However, if this property is not desired specify the
  13208. // CERT_CREATE_SELFSIGN_NO_KEY_INFO in dwFlags.
  13209. //
  13210. // If the cert being built is only a dummy placeholder cert for speed it may not
  13211. // need to be signed. Signing of the cert is skipped if CERT_CREATE_SELFSIGN_NO_SIGN
  13212. // is specified in dwFlags.
  13213. //
  13214. //--------------------------------------------------------------------------
  13215. function CertCreateSelfSignCertificate(hProv: HCRYPTPROV;
  13216. pSubjectIssuerBlob: PCERT_NAME_BLOB; dwFlags: DWORD;
  13217. pKeyProvInfo: PCRYPT_KEY_PROV_INFO; pSignatureAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER;
  13218. pStartTime, pEndTime: PSYSTEMTIME; pExtensions: PCERT_EXTENSIONS): PCCERT_CONTEXT; stdcall;
  13219. {$EXTERNALSYM CertCreateSelfSignCertificate}
  13220. const
  13221. CERT_CREATE_SELFSIGN_NO_SIGN = 1;
  13222. {$EXTERNALSYM CERT_CREATE_SELFSIGN_NO_SIGN}
  13223. CERT_CREATE_SELFSIGN_NO_KEY_INFO = 2;
  13224. {$EXTERNALSYM CERT_CREATE_SELFSIGN_NO_KEY_INFO}
  13225. //+=========================================================================
  13226. // Key Identifier Property Data Structures and APIs
  13227. //==========================================================================
  13228. //+-------------------------------------------------------------------------
  13229. // Get the property for the specified Key Identifier.
  13230. //
  13231. // The Key Identifier is the SHA1 hash of the encoded CERT_PUBLIC_KEY_INFO.
  13232. // The Key Identifier for a certificate can be obtained by getting the
  13233. // certificate's CERT_KEY_IDENTIFIER_PROP_ID. The
  13234. // CryptCreateKeyIdentifierFromCSP API can be called to create the Key
  13235. // Identifier from a CSP Public Key Blob.
  13236. //
  13237. // A Key Identifier can have the same properties as a certificate context.
  13238. // CERT_KEY_PROV_INFO_PROP_ID is the property of most interest.
  13239. // For CERT_KEY_PROV_INFO_PROP_ID, pvData points to a CRYPT_KEY_PROV_INFO
  13240. // structure. Elements pointed to by fields in the pvData structure follow the
  13241. // structure. Therefore, *pcbData will exceed the size of the structure.
  13242. //
  13243. // If CRYPT_KEYID_ALLOC_FLAG is set, then, *pvData is updated with a
  13244. // pointer to allocated memory. LocalFree() must be called to free the
  13245. // allocated memory.
  13246. //
  13247. // By default, searches the CurrentUser's list of Key Identifiers.
  13248. // CRYPT_KEYID_MACHINE_FLAG can be set to search the LocalMachine's list
  13249. // of Key Identifiers. When CRYPT_KEYID_MACHINE_FLAG is set, pwszComputerName
  13250. // can also be set to specify the name of a remote computer to be searched
  13251. // instead of the local machine.
  13252. //--------------------------------------------------------------------------
  13253. function CryptGetKeyIdentifierProperty(pKeyIdentifier: PCRYPT_HASH_BLOB;
  13254. dwPropId: DWORD; dwFlags: DWORD; pwszComputerName: LPCWSTR; pvReserved: Pointer;
  13255. pvData: Pointer; var pcbData: DWORD): BOOL; stdcall;
  13256. {$EXTERNALSYM CryptGetKeyIdentifierProperty}
  13257. // When the following flag is set, searches the LocalMachine instead of the
  13258. // CurrentUser. This flag is applicable to all the KeyIdentifierProperty APIs.
  13259. const
  13260. CRYPT_KEYID_MACHINE_FLAG = $00000020;
  13261. {$EXTERNALSYM CRYPT_KEYID_MACHINE_FLAG}
  13262. // When the following flag is set, *pvData is updated with a pointer to
  13263. // allocated memory. LocalFree() must be called to free the allocated memory.
  13264. CRYPT_KEYID_ALLOC_FLAG = $00008000;
  13265. {$EXTERNALSYM CRYPT_KEYID_ALLOC_FLAG}
  13266. //+-------------------------------------------------------------------------
  13267. // Set the property for the specified Key Identifier.
  13268. //
  13269. // For CERT_KEY_PROV_INFO_PROP_ID pvData points to the
  13270. // CRYPT_KEY_PROV_INFO data structure. For all other properties, pvData
  13271. // points to a CRYPT_DATA_BLOB.
  13272. //
  13273. // Setting pvData == NULL, deletes the property.
  13274. //
  13275. // Set CRYPT_KEYID_MACHINE_FLAG to set the property for a LocalMachine
  13276. // Key Identifier. Set pwszComputerName, to select a remote computer.
  13277. //
  13278. // If CRYPT_KEYID_DELETE_FLAG is set, the Key Identifier and all its
  13279. // properties is deleted.
  13280. //
  13281. // If CRYPT_KEYID_SET_NEW_FLAG is set, the set fails if the property already
  13282. // exists. For an existing property, FALSE is returned with LastError set to
  13283. // CRYPT_E_EXISTS.
  13284. //--------------------------------------------------------------------------
  13285. function CryptSetKeyIdentifierProperty(pKeyIdentifier: PCRYPT_HASH_BLOB;
  13286. dwPropId: DWORD; dwFlags: DWORD; pwszComputerName: LPCWSTR; pvReserved: Pointer;
  13287. pvData: Pointer): BOOL; stdcall;
  13288. {$EXTERNALSYM CryptSetKeyIdentifierProperty}
  13289. // When the following flag is set, the Key Identifier and all its properties
  13290. // are deleted.
  13291. const
  13292. CRYPT_KEYID_DELETE_FLAG = $00000010;
  13293. {$EXTERNALSYM CRYPT_KEYID_DELETE_FLAG}
  13294. // When the following flag is set, the set fails if the property already
  13295. // exists.
  13296. CRYPT_KEYID_SET_NEW_FLAG = $00002000;
  13297. {$EXTERNALSYM CRYPT_KEYID_SET_NEW_FLAG}
  13298. //+-------------------------------------------------------------------------
  13299. // For CERT_KEY_PROV_INFO_PROP_ID, rgppvData[] points to a
  13300. // CRYPT_KEY_PROV_INFO.
  13301. //
  13302. // Return FALSE to stop the enumeration.
  13303. //--------------------------------------------------------------------------
  13304. type
  13305. PFN_CRYPT_ENUM_KEYID_PROP = function(pKeyIdentifier: PCRYPT_HASH_BLOB;
  13306. dwFlags: DWORD; pvReserved: Pointer; pvArg: Pointer; cProp: DWORD;
  13307. rgdwPropId: LPDWORD; rgpvData: Pointer; rgcbData: LPDWORD): BOOL; stdcall;
  13308. {$EXTERNALSYM PFN_CRYPT_ENUM_KEYID_PROP}
  13309. PFnCryptEnumKeyIdProp = PFN_CRYPT_ENUM_KEYID_PROP;
  13310. //+-------------------------------------------------------------------------
  13311. // Enumerate the Key Identifiers.
  13312. //
  13313. // If pKeyIdentifier is NULL, enumerates all Key Identifers. Otherwise,
  13314. // calls the callback for the specified KeyIdentifier. If dwPropId is
  13315. // 0, calls the callback with all the properties. Otherwise, only calls
  13316. // the callback with the specified property (cProp = 1).
  13317. // Furthermore, when dwPropId is specified, skips KeyIdentifiers not
  13318. // having the property.
  13319. //
  13320. // Set CRYPT_KEYID_MACHINE_FLAG to enumerate the LocalMachine
  13321. // Key Identifiers. Set pwszComputerName, to enumerate Key Identifiers on
  13322. // a remote computer.
  13323. //--------------------------------------------------------------------------
  13324. function CryptEnumKeyIdentifierProperties(pKeyIdentifier: PCRYPT_HASH_BLOB;
  13325. dwPropId: DWORD; dwFlags: DWORD; pwszComputerName: LPCWSTR; pvReserved: Pointer;
  13326. pvArg: Pointer; pfnEnum: PFN_CRYPT_ENUM_KEYID_PROP): BOOL; stdcall;
  13327. {$EXTERNALSYM CryptEnumKeyIdentifierProperties}
  13328. //+-------------------------------------------------------------------------
  13329. // Create a KeyIdentifier from the CSP Public Key Blob.
  13330. //
  13331. // Converts the CSP PUBLICKEYSTRUC into a X.509 CERT_PUBLIC_KEY_INFO and
  13332. // encodes. The encoded CERT_PUBLIC_KEY_INFO is SHA1 hashed to obtain
  13333. // the Key Identifier.
  13334. //
  13335. // By default, the pPubKeyStruc->aiKeyAlg is used to find the appropriate
  13336. // public key Object Identifier. pszPubKeyOID can be set to override
  13337. // the default OID obtained from the aiKeyAlg.
  13338. //--------------------------------------------------------------------------
  13339. function CryptCreateKeyIdentifierFromCSP(dwCertEncodingType: DWORD;
  13340. pszPubKeyOID: LPCSTR; pPubKeyStruc: PPUBLICKEYSTRUC; cbPubKeyStruc: DWORD;
  13341. dwFlags: DWORD; pvReserved: Pointer; pbHash: LPBYTE; pcbHash: DWORD): BOOL; stdcall;
  13342. {$EXTERNALSYM CryptCreateKeyIdentifierFromCSP}
  13343. //+=========================================================================
  13344. // Certificate Chaining Infrastructure
  13345. //==========================================================================
  13346. //
  13347. // The chain engine defines the store namespace and cache partitioning for
  13348. // the Certificate Chaining infrastructure. A default chain engine
  13349. // is defined for the process which uses all default system stores e.g.
  13350. // Root, CA, Trust, for chain building and caching. If an application
  13351. // wishes to define its own store namespace or have its own partitioned
  13352. // cache then it can create its own chain engine. It is advisable to create
  13353. // a chain engine at application startup and use it throughout the lifetime
  13354. // of the application in order to get optimal caching behavior
  13355. //
  13356. type
  13357. HCERTCHAINENGINE = HANDLE;
  13358. {$EXTERNALSYM HCERTCHAINENGINE}
  13359. const
  13360. HCCE_CURRENT_USER = HCERTCHAINENGINE(0);
  13361. {$EXTERNALSYM HCCE_CURRENT_USER}
  13362. HCCE_LOCAL_MACHINE = HCERTCHAINENGINE($1);
  13363. {$EXTERNALSYM HCCE_LOCAL_MACHINE}
  13364. //
  13365. // Create a certificate chain engine.
  13366. //
  13367. //
  13368. // Configuration parameters for the certificate chain engine
  13369. //
  13370. // hRestrictedRoot - restrict the root store (must be a subset of "Root")
  13371. //
  13372. // hRestrictedTrust - restrict the store for CTLs
  13373. //
  13374. // hRestrictedOther - restrict the store for certs and CRLs
  13375. //
  13376. // cAdditionalStore, rghAdditionalStore - additional stores
  13377. //
  13378. // NOTE: The algorithm used to define the stores for the engine is as
  13379. // follows:
  13380. //
  13381. // hRoot = hRestrictedRoot or System Store "Root"
  13382. //
  13383. // hTrust = hRestrictedTrust or hWorld (defined later)
  13384. //
  13385. // hOther = hRestrictedOther or (hRestrictedTrust == NULL) ? hWorld :
  13386. // hRestrictedTrust + hWorld
  13387. //
  13388. // hWorld = hRoot + "CA" + "My" + "Trust" + rghAdditionalStore
  13389. //
  13390. // dwFlags - flags
  13391. //
  13392. // CERT_CHAIN_CACHE_END_CERT - information will be cached on
  13393. // the end cert as well as the other
  13394. // certs in the chain
  13395. //
  13396. // CERT_CHAIN_THREAD_STORE_SYNC - use separate thread for store syncs
  13397. // and related cache updates
  13398. //
  13399. // CERT_CHAIN_CACHE_ONLY_URL_RETRIEVAL - don't hit the wire to get
  13400. // URL based objects
  13401. //
  13402. // dwUrlRetrievalTimeout - timeout for wire based URL object retrievals
  13403. //
  13404. const
  13405. CERT_CHAIN_CACHE_END_CERT = $00000001;
  13406. {$EXTERNALSYM CERT_CHAIN_CACHE_END_CERT}
  13407. CERT_CHAIN_THREAD_STORE_SYNC = $00000002;
  13408. {$EXTERNALSYM CERT_CHAIN_THREAD_STORE_SYNC}
  13409. CERT_CHAIN_CACHE_ONLY_URL_RETRIEVAL = $00000004;
  13410. {$EXTERNALSYM CERT_CHAIN_CACHE_ONLY_URL_RETRIEVAL}
  13411. CERT_CHAIN_USE_LOCAL_MACHINE_STORE = $00000008;
  13412. {$EXTERNALSYM CERT_CHAIN_USE_LOCAL_MACHINE_STORE}
  13413. CERT_CHAIN_ENABLE_CACHE_AUTO_UPDATE = $00000010;
  13414. {$EXTERNALSYM CERT_CHAIN_ENABLE_CACHE_AUTO_UPDATE}
  13415. type
  13416. PCERT_CHAIN_ENGINE_CONFIG = ^CERT_CHAIN_ENGINE_CONFIG;
  13417. {$EXTERNALSYM PCERT_CHAIN_ENGINE_CONFIG}
  13418. _CERT_CHAIN_ENGINE_CONFIG = record
  13419. cbSize: DWORD;
  13420. hRestrictedRoot: HCERTSTORE;
  13421. hRestrictedTrust: HCERTSTORE;
  13422. hRestrictedOther: HCERTSTORE;
  13423. cAdditionalStore: DWORD;
  13424. rghAdditionalStore: PHCERTSTORE;
  13425. dwFlags: DWORD;
  13426. dwUrlRetrievalTimeout: DWORD;
  13427. MaximumCachedCertificates: DWORD;
  13428. CycleDetectionModulus: DWORD;
  13429. end;
  13430. {$EXTERNALSYM _CERT_CHAIN_ENGINE_CONFIG}
  13431. CERT_CHAIN_ENGINE_CONFIG = _CERT_CHAIN_ENGINE_CONFIG;
  13432. {$EXTERNALSYM CERT_CHAIN_ENGINE_CONFIG}
  13433. TCertChainEngineConfig = CERT_CHAIN_ENGINE_CONFIG;
  13434. PCertChainEngineConfig = PCERT_CHAIN_ENGINE_CONFIG;
  13435. function CertCreateCertificateChainEngine(pConfig: PCERT_CHAIN_ENGINE_CONFIG;
  13436. var phChainEngine: HCERTCHAINENGINE): BOOL; stdcall;
  13437. {$EXTERNALSYM CertCreateCertificateChainEngine}
  13438. //
  13439. // Free a certificate trust engine
  13440. //
  13441. procedure CertFreeCertificateChainEngine(hChainEngine: HCERTCHAINENGINE); stdcall;
  13442. {$EXTERNALSYM CertFreeCertificateChainEngine}
  13443. //
  13444. // Resync the certificate chain engine. This resync's the stores backing
  13445. // the engine and updates the engine caches.
  13446. //
  13447. function CertResyncCertificateChainEngine(hChainEngine: HCERTCHAINENGINE): BOOL; stdcall;
  13448. {$EXTERNALSYM CertResyncCertificateChainEngine}
  13449. //
  13450. // When an application requests a certificate chain, the data structure
  13451. // returned is in the form of a CERT_CHAIN_CONTEXT. This contains
  13452. // an array of CERT_SIMPLE_CHAIN where each simple chain goes from
  13453. // an end cert to a self signed cert and the chain context connects simple
  13454. // chains via trust lists. Each simple chain contains the chain of
  13455. // certificates, summary trust information about the chain and trust information
  13456. // about each certificate element in the chain.
  13457. //
  13458. //
  13459. // Trust status bits
  13460. //
  13461. type
  13462. PCERT_TRUST_STATUS = ^CERT_TRUST_STATUS;
  13463. {$EXTERNALSYM PCERT_TRUST_STATUS}
  13464. _CERT_TRUST_STATUS = record
  13465. dwErrorStatus: DWORD;
  13466. dwInfoStatus: DWORD;
  13467. end;
  13468. {$EXTERNALSYM _CERT_TRUST_STATUS}
  13469. CERT_TRUST_STATUS = _CERT_TRUST_STATUS;
  13470. {$EXTERNALSYM CERT_TRUST_STATUS}
  13471. TCertTrustStatus = CERT_TRUST_STATUS;
  13472. PCertTrustStatus = PCERT_TRUST_STATUS;
  13473. //
  13474. // The following are error status bits
  13475. //
  13476. // These can be applied to certificates and chains
  13477. const
  13478. CERT_TRUST_NO_ERROR = $00000000;
  13479. {$EXTERNALSYM CERT_TRUST_NO_ERROR}
  13480. CERT_TRUST_IS_NOT_TIME_VALID = $00000001;
  13481. {$EXTERNALSYM CERT_TRUST_IS_NOT_TIME_VALID}
  13482. CERT_TRUST_IS_NOT_TIME_NESTED = $00000002;
  13483. {$EXTERNALSYM CERT_TRUST_IS_NOT_TIME_NESTED}
  13484. CERT_TRUST_IS_REVOKED = $00000004;
  13485. {$EXTERNALSYM CERT_TRUST_IS_REVOKED}
  13486. CERT_TRUST_IS_NOT_SIGNATURE_VALID = $00000008;
  13487. {$EXTERNALSYM CERT_TRUST_IS_NOT_SIGNATURE_VALID}
  13488. CERT_TRUST_IS_NOT_VALID_FOR_USAGE = $00000010;
  13489. {$EXTERNALSYM CERT_TRUST_IS_NOT_VALID_FOR_USAGE}
  13490. CERT_TRUST_IS_UNTRUSTED_ROOT = $00000020;
  13491. {$EXTERNALSYM CERT_TRUST_IS_UNTRUSTED_ROOT}
  13492. CERT_TRUST_REVOCATION_STATUS_UNKNOWN = $00000040;
  13493. {$EXTERNALSYM CERT_TRUST_REVOCATION_STATUS_UNKNOWN}
  13494. CERT_TRUST_IS_CYCLIC = $00000080;
  13495. {$EXTERNALSYM CERT_TRUST_IS_CYCLIC}
  13496. // These can be applied to chains only
  13497. CERT_TRUST_IS_PARTIAL_CHAIN = $00010000;
  13498. {$EXTERNALSYM CERT_TRUST_IS_PARTIAL_CHAIN}
  13499. CERT_TRUST_CTL_IS_NOT_TIME_VALID = $00020000;
  13500. {$EXTERNALSYM CERT_TRUST_CTL_IS_NOT_TIME_VALID}
  13501. CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID = $00040000;
  13502. {$EXTERNALSYM CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID}
  13503. CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE = $00080000;
  13504. {$EXTERNALSYM CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE}
  13505. //
  13506. // The following are info status bits
  13507. //
  13508. // These can be applied to certificates only
  13509. CERT_TRUST_HAS_EXACT_MATCH_ISSUER = $00000001;
  13510. {$EXTERNALSYM CERT_TRUST_HAS_EXACT_MATCH_ISSUER}
  13511. CERT_TRUST_HAS_KEY_MATCH_ISSUER = $00000002;
  13512. {$EXTERNALSYM CERT_TRUST_HAS_KEY_MATCH_ISSUER}
  13513. CERT_TRUST_HAS_NAME_MATCH_ISSUER = $00000004;
  13514. {$EXTERNALSYM CERT_TRUST_HAS_NAME_MATCH_ISSUER}
  13515. CERT_TRUST_IS_SELF_SIGNED = $00000008;
  13516. {$EXTERNALSYM CERT_TRUST_IS_SELF_SIGNED}
  13517. // These can be applied to chains only
  13518. CERT_TRUST_IS_COMPLEX_CHAIN = $00010000;
  13519. {$EXTERNALSYM CERT_TRUST_IS_COMPLEX_CHAIN}
  13520. //
  13521. // Each certificate context in a simple chain has a corresponding chain element
  13522. // in the simple chain context
  13523. //
  13524. // dwErrorStatus has CERT_TRUST_IS_REVOKED, pRevocationInfo set
  13525. // dwErrorStatus has CERT_TRUST_REVOCATION_STATUS_UNKNOWN, pRevocationInfo set
  13526. //
  13527. // BUGBUG: Note that the post processing revocation supported in the first
  13528. // version only sets cbSize and dwRevocationResult. Everything else
  13529. // is NULL
  13530. //
  13531. //
  13532. // Revocation Information
  13533. //
  13534. type
  13535. PCERT_REVOCATION_INFO = ^CERT_REVOCATION_INFO;
  13536. {$EXTERNALSYM PCERT_REVOCATION_INFO}
  13537. _CERT_REVOCATION_INFO = record
  13538. cbSize: DWORD;
  13539. dwRevocationResult: DWORD;
  13540. pszRevocationOid: LPCSTR;
  13541. pvOidSpecificInfo: LPVOID;
  13542. end;
  13543. {$EXTERNALSYM _CERT_REVOCATION_INFO}
  13544. CERT_REVOCATION_INFO = _CERT_REVOCATION_INFO;
  13545. {$EXTERNALSYM CERT_REVOCATION_INFO}
  13546. TCertRevocationInfo = CERT_REVOCATION_INFO;
  13547. PCertRevocationInfo = PCERT_REVOCATION_INFO;
  13548. //
  13549. // Trust List Information
  13550. //
  13551. PCERT_TRUST_LIST_INFO = ^CERT_TRUST_LIST_INFO;
  13552. {$EXTERNALSYM PCERT_TRUST_LIST_INFO}
  13553. _CERT_TRUST_LIST_INFO = record
  13554. cbSize: DWORD;
  13555. pCtlEntry: PCTL_ENTRY;
  13556. pCtlContext: PCCTL_CONTEXT;
  13557. end;
  13558. {$EXTERNALSYM _CERT_TRUST_LIST_INFO}
  13559. CERT_TRUST_LIST_INFO = _CERT_TRUST_LIST_INFO;
  13560. {$EXTERNALSYM CERT_TRUST_LIST_INFO}
  13561. TCertTrustListInfo = CERT_TRUST_LIST_INFO;
  13562. PCertTrustListInfo = PCERT_TRUST_LIST_INFO;
  13563. //
  13564. // Chain Element
  13565. //
  13566. PCERT_CHAIN_ELEMENT = ^CERT_CHAIN_ELEMENT;
  13567. {$EXTERNALSYM PCERT_CHAIN_ELEMENT}
  13568. _CERT_CHAIN_ELEMENT = record
  13569. cbSize: DWORD;
  13570. pCertContext: PCCERT_CONTEXT;
  13571. TrustStatus: CERT_TRUST_STATUS;
  13572. pRevocationInfo: PCERT_REVOCATION_INFO;
  13573. end;
  13574. {$EXTERNALSYM _CERT_CHAIN_ELEMENT}
  13575. CERT_CHAIN_ELEMENT = _CERT_CHAIN_ELEMENT;
  13576. {$EXTERNALSYM CERT_CHAIN_ELEMENT}
  13577. TCertChainElement = CERT_CHAIN_ELEMENT;
  13578. PCertChainElement = PCERT_CHAIN_ELEMENT;
  13579. //
  13580. // The simple chain is an array of chain elements and a summary trust status
  13581. // for the chain
  13582. //
  13583. // rgpElements[0] is the end certificate chain element
  13584. //
  13585. // rgpElements[cElement-1] is the self-signed "root" certificate chain element
  13586. //
  13587. PCERT_SIMPLE_CHAIN = ^CERT_SIMPLE_CHAIN;
  13588. {$EXTERNALSYM PCERT_SIMPLE_CHAIN}
  13589. _CERT_SIMPLE_CHAIN = record
  13590. cbSize: DWORD;
  13591. TrustStatus: CERT_TRUST_STATUS;
  13592. cElement: DWORD;
  13593. rgpElement: PCERT_CHAIN_ELEMENT;
  13594. pTrustListInfo: PCERT_TRUST_LIST_INFO;
  13595. end;
  13596. {$EXTERNALSYM _CERT_SIMPLE_CHAIN}
  13597. CERT_SIMPLE_CHAIN = _CERT_SIMPLE_CHAIN;
  13598. {$EXTERNALSYM CERT_SIMPLE_CHAIN}
  13599. TCertSimpleChain = CERT_SIMPLE_CHAIN;
  13600. PCertSimpleChain = PCERT_SIMPLE_CHAIN;
  13601. //
  13602. // And the chain context contains an array of simple chains and summary trust
  13603. // status for all the connected simple chains
  13604. //
  13605. // rgpChains[0] is the end certificate simple chain
  13606. //
  13607. // rgpChains[cChain-1] is the final (possibly trust list signer) chain which
  13608. // ends in a certificate which is contained in the root store
  13609. //
  13610. PCERT_CHAIN_CONTEXT = ^CERT_CHAIN_CONTEXT;
  13611. {$EXTERNALSYM PCERT_CHAIN_CONTEXT}
  13612. _CERT_CHAIN_CONTEXT = record
  13613. cbSize: DWORD;
  13614. TrustStatus: CERT_TRUST_STATUS;
  13615. cChain: DWORD;
  13616. rgpChain: PCERT_SIMPLE_CHAIN;
  13617. end;
  13618. {$EXTERNALSYM _CERT_CHAIN_CONTEXT}
  13619. CERT_CHAIN_CONTEXT = _CERT_CHAIN_CONTEXT;
  13620. {$EXTERNALSYM CERT_CHAIN_CONTEXT}
  13621. TCertChainContext = CERT_CHAIN_CONTEXT;
  13622. PCertChainContext = PCERT_CHAIN_CONTEXT;
  13623. PCCERT_CHAIN_CONTEXT = ^CERT_CHAIN_CONTEXT;
  13624. {$EXTERNALSYM PCCERT_CHAIN_CONTEXT}
  13625. PPCCERT_CHAIN_CONTEXT = ^PCERT_CHAIN_CONTEXT;
  13626. {$NODEFINE PPCCERT_CHAIN_CONTEXT}
  13627. //
  13628. // When building a chain, the there are various parameters used for finding
  13629. // issuing certificates and trust lists. They are identified in the
  13630. // following structure
  13631. //
  13632. // Default usage match type is AND with value zero
  13633. const
  13634. USAGE_MATCH_TYPE_AND = $00000000;
  13635. {$EXTERNALSYM USAGE_MATCH_TYPE_AND}
  13636. USAGE_MATCH_TYPE_OR = $00000001;
  13637. {$EXTERNALSYM USAGE_MATCH_TYPE_OR}
  13638. type
  13639. PCERT_USAGE_MATCH = ^CERT_USAGE_MATCH;
  13640. {$EXTERNALSYM PCERT_USAGE_MATCH}
  13641. _CERT_USAGE_MATCH = record
  13642. dwType: DWORD;
  13643. Usage: CERT_ENHKEY_USAGE;
  13644. end;
  13645. {$EXTERNALSYM _CERT_USAGE_MATCH}
  13646. CERT_USAGE_MATCH = _CERT_USAGE_MATCH;
  13647. {$EXTERNALSYM CERT_USAGE_MATCH}
  13648. TCertUsageMatch = CERT_USAGE_MATCH;
  13649. PCertUsageMatch = PCERT_USAGE_MATCH;
  13650. PCTL_USAGE_MATCH = ^CTL_USAGE_MATCH;
  13651. {$EXTERNALSYM PCTL_USAGE_MATCH}
  13652. _CTL_USAGE_MATCH = record
  13653. dwType: DWORD;
  13654. Usage: CTL_USAGE;
  13655. end;
  13656. {$EXTERNALSYM _CTL_USAGE_MATCH}
  13657. CTL_USAGE_MATCH = _CTL_USAGE_MATCH;
  13658. {$EXTERNALSYM CTL_USAGE_MATCH}
  13659. TCtlUsageMatch = CTL_USAGE_MATCH;
  13660. PCtlUsageMatch = PCTL_USAGE_MATCH;
  13661. PCERT_CHAIN_PARA = ^CERT_CHAIN_PARA;
  13662. {$EXTERNALSYM PCERT_CHAIN_PARA}
  13663. _CERT_CHAIN_PARA = record
  13664. cbSize: DWORD;
  13665. RequestedUsage: CERT_USAGE_MATCH;
  13666. end;
  13667. {$EXTERNALSYM _CERT_CHAIN_PARA}
  13668. CERT_CHAIN_PARA = _CERT_CHAIN_PARA;
  13669. {$EXTERNALSYM CERT_CHAIN_PARA}
  13670. TCertChainPara = CERT_CHAIN_PARA;
  13671. PCertChainPara = PCERT_CHAIN_PARA;
  13672. //
  13673. // The following API is used for retrieving certificate chains
  13674. //
  13675. // Parameters:
  13676. //
  13677. // hChainEngine - the chain engine (namespace and cache) to use, NULL
  13678. // mean use the default chain engine
  13679. //
  13680. // pCertContext - the context we are retrieving the chain for, it
  13681. // will be the zero index element in the chain
  13682. //
  13683. // pTime - the point in time that we want the chain validated
  13684. // for. Note that the time does not affect trust list,
  13685. // revocation, or root store checking. NULL means use
  13686. // the current system time
  13687. //
  13688. // hAdditionalStore - additional store to use when looking up objects
  13689. //
  13690. // pChainPara - parameters for chain building
  13691. //
  13692. // dwFlags - flags such as should revocation checking be done
  13693. // on the chain?
  13694. //
  13695. // pvReserved - reserved parameter, must be NULL
  13696. //
  13697. // ppChainContext - chain context returned
  13698. //
  13699. // CERT_CHAIN_CACHE_END_CERT can be used here as well
  13700. // Revocation flags are in the high nibble
  13701. const
  13702. CERT_CHAIN_REVOCATION_CHECK_END_CERT = $10000000;
  13703. {$EXTERNALSYM CERT_CHAIN_REVOCATION_CHECK_END_CERT}
  13704. CERT_CHAIN_REVOCATION_CHECK_CHAIN = $20000000;
  13705. {$EXTERNALSYM CERT_CHAIN_REVOCATION_CHECK_CHAIN}
  13706. CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT = $40000000;
  13707. {$EXTERNALSYM CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT}
  13708. CERT_CHAIN_REVOCATION_CHECK_CACHE_ONLY = DWORD($80000000);
  13709. {$EXTERNALSYM CERT_CHAIN_REVOCATION_CHECK_CACHE_ONLY}
  13710. function CertGetCertificateChain(hChainEngine: HCERTCHAINENGINE;
  13711. pCertContext: PCCERT_CONTEXT; pTime: LPFILETIME; hAdditionalStore: HCERTSTORE;
  13712. pChainPara: PCERT_CHAIN_PARA; dwFlags: DWORD; pvReserved: LPVOID;
  13713. ppChainContext: PPCCERT_CHAIN_CONTEXT): BOOL; stdcall;
  13714. {$EXTERNALSYM CertGetCertificateChain}
  13715. //
  13716. // Free a certificate chain
  13717. //
  13718. procedure CertFreeCertificateChain(pChainContext: PCCERT_CHAIN_CONTEXT); stdcall;
  13719. {$EXTERNALSYM CertFreeCertificateChain}
  13720. //
  13721. // Duplicate (add a reference to) a certificate chain
  13722. //
  13723. function CertDuplicateCertificateChain(pChainContext: PCCERT_CHAIN_CONTEXT): PCCERT_CHAIN_CONTEXT; stdcall;
  13724. {$EXTERNALSYM CertDuplicateCertificateChain}
  13725. //
  13726. // Specific Revocation Type OID and structure definitions
  13727. //
  13728. //
  13729. // CRL Revocation OID
  13730. //
  13731. const
  13732. REVOCATION_OID_CRL_REVOCATION = LPCSTR(1);
  13733. {$EXTERNALSYM REVOCATION_OID_CRL_REVOCATION}
  13734. //
  13735. // For the CRL revocation OID the pvRevocationPara is NULL
  13736. //
  13737. //
  13738. // CRL Revocation Info
  13739. //
  13740. type
  13741. PCRL_REVOCATION_INFO = ^CRL_REVOCATION_INFO;
  13742. {$EXTERNALSYM PCRL_REVOCATION_INFO}
  13743. _CRL_REVOCATION_INFO = record
  13744. pCrlEntry: PCRL_ENTRY;
  13745. pCrlContext: PCCRL_CONTEXT;
  13746. pCrlIssuerChain: PCCERT_CHAIN_CONTEXT;
  13747. end;
  13748. {$EXTERNALSYM _CRL_REVOCATION_INFO}
  13749. CRL_REVOCATION_INFO = _CRL_REVOCATION_INFO;
  13750. {$EXTERNALSYM CRL_REVOCATION_INFO}
  13751. TCrlRevocationInfo = CRL_REVOCATION_INFO;
  13752. PCrlRevocationInfo = PCRL_REVOCATION_INFO;
  13753. //+-------------------------------------------------------------------------
  13754. // Find the first or next certificate chain context in the store.
  13755. //
  13756. // The chain context is found according to the dwFindFlags, dwFindType and
  13757. // its pvFindPara. See below for a list of the find types and its parameters.
  13758. //
  13759. // If the first or next chain context isn't found, NULL is returned.
  13760. // Otherwise, a pointer to a read only CERT_CHAIN_CONTEXT is returned.
  13761. // CERT_CHAIN_CONTEXT must be freed by calling CertFreeCertificateChain
  13762. // or is freed when passed as the
  13763. // pPrevChainContext on a subsequent call. CertDuplicateCertificateChain
  13764. // can be called to make a duplicate.
  13765. //
  13766. // pPrevChainContext MUST BE NULL on the first
  13767. // call to find the chain context. To find the next chain context, the
  13768. // pPrevChainContext is set to the CERT_CHAIN_CONTEXT returned by a previous
  13769. // call.
  13770. //
  13771. // NOTE: a NON-NULL pPrevChainContext is always CertFreeCertificateChain'ed by
  13772. // this function, even for an error.
  13773. //--------------------------------------------------------------------------
  13774. function CertFindChainInStore(hCertStore: HCERTSTORE; dwCertEncodingType: DWORD;
  13775. dwFindFlags: DWORD; dwFindType: DWORD; pvFindPara: Pointer;
  13776. pPrevChainContext: PCCERT_CHAIN_CONTEXT): PCCERT_CHAIN_CONTEXT; stdcall;
  13777. {$EXTERNALSYM CertFindChainInStore}
  13778. const
  13779. CERT_CHAIN_FIND_BY_ISSUER = 1;
  13780. {$EXTERNALSYM CERT_CHAIN_FIND_BY_ISSUER}
  13781. //+-------------------------------------------------------------------------
  13782. // CERT_CHAIN_FIND_BY_ISSUER
  13783. //
  13784. // Find a certificate chain having a private key for the end certificate and
  13785. // matching one of the given issuer names. A matching dwKeySpec and
  13786. // enhanced key usage can also be specified. Additionally a callback can
  13787. // be provided for even more caller provided filtering before building the
  13788. // chain.
  13789. //
  13790. // By default, only the issuers in the first simple chain are compared
  13791. // for a name match. CERT_CHAIN_FIND_BY_ISSUER_COMPLEX_CHAIN_FLAG can
  13792. // be set in dwFindFlags to match issuers in all the simple chains.
  13793. //
  13794. // CERT_CHAIN_FIND_BY_ISSUER_NO_KEY_FLAG can be set in dwFindFlags to
  13795. // not check if the end certificate has a private key.
  13796. //
  13797. // CERT_CHAIN_FIND_BY_ISSUER_COMPARE_KEY_FLAG can be set in dwFindFlags
  13798. // to compare the public key in the end certificate with the crypto
  13799. // provider's public key. The dwAcquirePrivateKeyFlags can be set
  13800. // in CERT_CHAIN_FIND_BY_ISSUER_PARA to enable caching of the private key's
  13801. // HKEY returned by the CSP.
  13802. //
  13803. // If dwCertEncodingType == 0, defaults to X509_ASN_ENCODING for the
  13804. // array of encoded issuer names.
  13805. //
  13806. // By default, the hCertStore passed to CertFindChainInStore, is passed
  13807. // as an additional store to CertGetCertificateChain.
  13808. // CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_FLAG can be set in dwFindFlags
  13809. // to improve performance by only searching the cached system stores
  13810. // (root, my, ca, trust) to find the issuer certificates. If you are doing
  13811. // a find in the "my" system store, than, this flag should be set to
  13812. // improve performance.
  13813. //
  13814. // Setting CERT_CHAIN_FIND_BY_ISSUER_LOCAL_MACHINE_FLAG in dwFindFlags
  13815. // restricts CertGetCertificateChain to search the Local Machine
  13816. // cached system stores instead of the Current User's.
  13817. //
  13818. // Setting CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_URL_FLAG in dwFindFlags
  13819. // restricts CertGetCertificateChain to only search the URL cache
  13820. // and not hit the wire.
  13821. //--------------------------------------------------------------------------
  13822. // Returns FALSE to skip this certificate. Otherwise, returns TRUE to
  13823. // build a chain for this certificate.
  13824. type
  13825. PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK = function(pCert: PCCERT_CONTEXT;
  13826. pvFindArg: Pointer): BOOL; stdcall;
  13827. {$EXTERNALSYM PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK}
  13828. PFnCertChainFindByIssuerCallback = PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK;
  13829. PCERT_CHAIN_FIND_BY_ISSUER_PARA = ^CERT_CHAIN_FIND_BY_ISSUER_PARA;
  13830. {$EXTERNALSYM PCERT_CHAIN_FIND_BY_ISSUER_PARA}
  13831. _CERT_CHAIN_FIND_BY_ISSUER_PARA = record
  13832. cbSize: DWORD;
  13833. // If pszUsageIdentifier == NULL, matches any usage.
  13834. pszUsageIdentifier: LPCSTR;
  13835. // If dwKeySpec == 0, matches any KeySpec
  13836. dwKeySpec: DWORD;
  13837. // When CERT_CHAIN_FIND_BY_ISSUER_COMPARE_KEY_FLAG is set in dwFindFlags,
  13838. // CryptAcquireCertificatePrivateKey is called to do the public key
  13839. // comparison. The following flags can be set to enable caching
  13840. // of the acquired private key. See the API for more details on these
  13841. // flags.
  13842. dwAcquirePrivateKeyFlags: DWORD;
  13843. // Pointer to an array of X509, ASN.1 encoded issuer name blobs. If
  13844. // cIssuer == 0, matches any issuer
  13845. cIssuer: DWORD;
  13846. rgIssuer: PCERT_NAME_BLOB;
  13847. // If NULL or Callback returns TRUE, builds the chain for the end
  13848. // certificate having a private key with the specified KeySpec and
  13849. // enhanced key usage.
  13850. pfnFindCallback: PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK;
  13851. pvFindArg: Pointer;
  13852. end;
  13853. {$EXTERNALSYM _CERT_CHAIN_FIND_BY_ISSUER_PARA}
  13854. CERT_CHAIN_FIND_BY_ISSUER_PARA = _CERT_CHAIN_FIND_BY_ISSUER_PARA;
  13855. {$EXTERNALSYM CERT_CHAIN_FIND_BY_ISSUER_PARA}
  13856. TCertChainFindByIssuerPara = CERT_CHAIN_FIND_BY_ISSUER_PARA;
  13857. PCertChainFindByIssuerPara = PCERT_CHAIN_FIND_BY_ISSUER_PARA;
  13858. // The following dwFindFlags can be set for CERT_CHAIN_FIND_BY_ISSUER
  13859. // If set, compares the public key in the end certificate with the crypto
  13860. // provider's public key. This comparison is the last check made on the
  13861. // build chain.
  13862. const
  13863. CERT_CHAIN_FIND_BY_ISSUER_COMPARE_KEY_FLAG = $0001;
  13864. {$EXTERNALSYM CERT_CHAIN_FIND_BY_ISSUER_COMPARE_KEY_FLAG}
  13865. // If not set, only checks the first simple chain for an issuer name match.
  13866. // When set, also checks second and subsequent simple chains.
  13867. CERT_CHAIN_FIND_BY_ISSUER_COMPLEX_CHAIN_FLAG = $0002;
  13868. {$EXTERNALSYM CERT_CHAIN_FIND_BY_ISSUER_COMPLEX_CHAIN_FLAG}
  13869. // If set, CertGetCertificateChain only searches the URL cache and
  13870. // doesn't hit the wire.
  13871. CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_URL_FLAG = $0004;
  13872. {$EXTERNALSYM CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_URL_FLAG}
  13873. // If set, CertGetCertificateChain only opens the Local Machine
  13874. // certificate stores instead of the Current User's.
  13875. CERT_CHAIN_FIND_BY_ISSUER_LOCAL_MACHINE_FLAG = $0008;
  13876. {$EXTERNALSYM CERT_CHAIN_FIND_BY_ISSUER_LOCAL_MACHINE_FLAG}
  13877. // If set, no check is made to see if the end certificate has a private
  13878. // key associated with it.
  13879. CERT_CHAIN_FIND_BY_ISSUER_NO_KEY_FLAG = $4000;
  13880. {$EXTERNALSYM CERT_CHAIN_FIND_BY_ISSUER_NO_KEY_FLAG}
  13881. // By default, the hCertStore passed to CertFindChainInStore, is passed
  13882. // as the additional store to CertGetCertificateChain. This flag can be
  13883. // set to improve performance by only searching the cached system stores
  13884. // (root, my, ca, trust) to find the issuer certificates. If not set, then,
  13885. // the hCertStore is always searched in addition to the cached system
  13886. // stores.
  13887. CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_FLAG = $8000;
  13888. {$EXTERNALSYM CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_FLAG}
  13889. //+=========================================================================
  13890. // Certificate Chain Policy Data Structures and APIs
  13891. //==========================================================================
  13892. type
  13893. PCERT_CHAIN_POLICY_PARA = ^CERT_CHAIN_POLICY_PARA;
  13894. {$EXTERNALSYM PCERT_CHAIN_POLICY_PARA}
  13895. _CERT_CHAIN_POLICY_PARA = record
  13896. cbSize: DWORD;
  13897. dwFlags: DWORD;
  13898. pvExtraPolicyPara: Pointer; // pszPolicyOID specific
  13899. end;
  13900. {$EXTERNALSYM _CERT_CHAIN_POLICY_PARA}
  13901. CERT_CHAIN_POLICY_PARA = _CERT_CHAIN_POLICY_PARA;
  13902. {$EXTERNALSYM CERT_CHAIN_POLICY_PARA}
  13903. TCertChainPolicyPara = CERT_CHAIN_POLICY_PARA;
  13904. PCertChainPolicyPara = PCERT_CHAIN_POLICY_PARA;
  13905. // If both lChainIndex and lElementIndex are set to -1, the dwError applies
  13906. // to the whole chain context. If only lElementIndex is set to -1, the
  13907. // dwError applies to the lChainIndex'ed chain. Otherwise, the dwError applies
  13908. // to the certificate element at
  13909. // pChainContext->rgpChain[lChainIndex]->rgpElement[lElementIndex].
  13910. PCERT_CHAIN_POLICY_STATUS = ^CERT_CHAIN_POLICY_STATUS;
  13911. {$EXTERNALSYM PCERT_CHAIN_POLICY_STATUS}
  13912. _CERT_CHAIN_POLICY_STATUS = record
  13913. cbSize: DWORD;
  13914. dwError: DWORD;
  13915. lChainIndex: LONG;
  13916. lElementIndex: LONG;
  13917. pvExtraPolicyStatus: Pointer; // pszPolicyOID specific
  13918. end;
  13919. {$EXTERNALSYM _CERT_CHAIN_POLICY_STATUS}
  13920. CERT_CHAIN_POLICY_STATUS = _CERT_CHAIN_POLICY_STATUS;
  13921. {$EXTERNALSYM CERT_CHAIN_POLICY_STATUS}
  13922. TCertChainPolicyStatus = CERT_CHAIN_POLICY_STATUS;
  13923. PCertChainPolicyStatus = PCERT_CHAIN_POLICY_STATUS;
  13924. // Common chain policy flags
  13925. const
  13926. CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG = $00000001;
  13927. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG}
  13928. CERT_CHAIN_POLICY_IGNORE_CTL_NOT_TIME_VALID_FLAG = $00000002;
  13929. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_CTL_NOT_TIME_VALID_FLAG}
  13930. CERT_CHAIN_POLICY_IGNORE_NOT_TIME_NESTED_FLAG = $00000004;
  13931. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_NOT_TIME_NESTED_FLAG}
  13932. CERT_CHAIN_POLICY_IGNORE_ALL_NOT_TIME_VALID_FLAGS = (
  13933. CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG or
  13934. CERT_CHAIN_POLICY_IGNORE_CTL_NOT_TIME_VALID_FLAG or
  13935. CERT_CHAIN_POLICY_IGNORE_NOT_TIME_NESTED_FLAG);
  13936. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_ALL_NOT_TIME_VALID_FLAGS}
  13937. CERT_CHAIN_POLICY_ALLOW_UNKNOWN_CA_FLAG = $00000010;
  13938. {$EXTERNALSYM CERT_CHAIN_POLICY_ALLOW_UNKNOWN_CA_FLAG}
  13939. CERT_CHAIN_POLICY_IGNORE_WRONG_USAGE_FLAG = $00000020;
  13940. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_WRONG_USAGE_FLAG}
  13941. CERT_CHAIN_POLICY_IGNORE_END_REV_UNKNOWN_FLAG = $00000100;
  13942. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_END_REV_UNKNOWN_FLAG}
  13943. CERT_CHAIN_POLICY_IGNORE_CTL_SIGNER_REV_UNKNOWN_FLAG = $00000200;
  13944. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_CTL_SIGNER_REV_UNKNOWN_FLAG}
  13945. CERT_CHAIN_POLICY_IGNORE_CA_REV_UNKNOWN_FLAG = $00000400;
  13946. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_CA_REV_UNKNOWN_FLAG}
  13947. CERT_CHAIN_POLICY_IGNORE_ROOT_REV_UNKNOWN_FLAG = $00000800;
  13948. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_ROOT_REV_UNKNOWN_FLAG}
  13949. CERT_CHAIN_POLICY_IGNORE_ALL_REV_UNKNOWN_FLAGS = (
  13950. CERT_CHAIN_POLICY_IGNORE_END_REV_UNKNOWN_FLAG or
  13951. CERT_CHAIN_POLICY_IGNORE_CTL_SIGNER_REV_UNKNOWN_FLAG or
  13952. CERT_CHAIN_POLICY_IGNORE_CA_REV_UNKNOWN_FLAG or
  13953. CERT_CHAIN_POLICY_IGNORE_ROOT_REV_UNKNOWN_FLAG);
  13954. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_ALL_REV_UNKNOWN_FLAGS}
  13955. CERT_CHAIN_POLICY_ALLOW_TESTROOT_FLAG = $00008000;
  13956. {$EXTERNALSYM CERT_CHAIN_POLICY_ALLOW_TESTROOT_FLAG}
  13957. CERT_CHAIN_POLICY_TRUST_TESTROOT_FLAG = $00004000;
  13958. {$EXTERNALSYM CERT_CHAIN_POLICY_TRUST_TESTROOT_FLAG}
  13959. //+-------------------------------------------------------------------------
  13960. // Verify that the certificate chain satisfies the specified policy
  13961. // requirements. If we were able to verify the chain policy, TRUE is returned
  13962. // and the dwError field of the pPolicyStatus is updated. A dwError of 0
  13963. // (ERROR_SUCCESS, S_OK) indicates the chain satisfies the specified policy.
  13964. //
  13965. // If dwError applies to the entire chain context, both lChainIndex and
  13966. // lElementIndex are set to -1. If dwError applies to a simple chain,
  13967. // lElementIndex is set to -1 and lChainIndex is set to the index of the
  13968. // first offending chain having the error. If dwError applies to a
  13969. // certificate element, lChainIndex and lElementIndex are updated to
  13970. // index the first offending certificate having the error, where, the
  13971. // the certificate element is at:
  13972. // pChainContext->rgpChain[lChainIndex]->rgpElement[lElementIndex].
  13973. //
  13974. // The dwFlags in pPolicyPara can be set to change the default policy checking
  13975. // behaviour. In addition, policy specific parameters can be passed in
  13976. // the pvExtraPolicyPara field of pPolicyPara.
  13977. //
  13978. // In addition to returning dwError, in pPolicyStatus, policy OID specific
  13979. // extra status may be returned via pvExtraPolicyStatus.
  13980. //--------------------------------------------------------------------------
  13981. function CertVerifyCertificateChainPolicy(pszPolicyOID: LPCSTR;
  13982. pChainContext: PCCERT_CHAIN_CONTEXT; pPolicyPara: PCERT_CHAIN_POLICY_PARA;
  13983. pPolicyStatus: PCERT_CHAIN_POLICY_STATUS): BOOL; stdcall;
  13984. {$EXTERNALSYM CertVerifyCertificateChainPolicy}
  13985. // Predefined OID Function Names
  13986. const
  13987. CRYPT_OID_VERIFY_CERTIFICATE_CHAIN_POLICY_FUNC = 'CertDllVerifyCertificateChainPolicy';
  13988. {$EXTERNALSYM CRYPT_OID_VERIFY_CERTIFICATE_CHAIN_POLICY_FUNC}
  13989. // CertDllVerifyCertificateChainPolicy has same function signature as
  13990. // CertVerifyCertificateChainPolicy.
  13991. //+-------------------------------------------------------------------------
  13992. // Predefined verify chain policies
  13993. //--------------------------------------------------------------------------
  13994. CERT_CHAIN_POLICY_BASE = LPCSTR(1);
  13995. {$EXTERNALSYM CERT_CHAIN_POLICY_BASE}
  13996. CERT_CHAIN_POLICY_AUTHENTICODE = LPCSTR(2);
  13997. {$EXTERNALSYM CERT_CHAIN_POLICY_AUTHENTICODE}
  13998. CERT_CHAIN_POLICY_AUTHENTICODE_TS = LPCSTR(3);
  13999. {$EXTERNALSYM CERT_CHAIN_POLICY_AUTHENTICODE_TS}
  14000. CERT_CHAIN_POLICY_SSL = LPCSTR(4);
  14001. {$EXTERNALSYM CERT_CHAIN_POLICY_SSL}
  14002. CERT_CHAIN_POLICY_BASIC_CONSTRAINTS = LPCSTR(5);
  14003. {$EXTERNALSYM CERT_CHAIN_POLICY_BASIC_CONSTRAINTS}
  14004. CERT_CHAIN_POLICY_NT_AUTH = LPCSTR(6);
  14005. {$EXTERNALSYM CERT_CHAIN_POLICY_NT_AUTH}
  14006. //+-------------------------------------------------------------------------
  14007. // CERT_CHAIN_POLICY_BASE
  14008. //
  14009. // Implements the base chain policy verification checks. dwFlags can
  14010. // be set in pPolicyPara to alter the default policy checking behaviour.
  14011. //--------------------------------------------------------------------------
  14012. //+-------------------------------------------------------------------------
  14013. // CERT_CHAIN_POLICY_AUTHENTICODE
  14014. //
  14015. // Implements the Authenticode chain policy verification checks.
  14016. //
  14017. // pvExtraPolicyPara may optionally be set to point to the following
  14018. // AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA.
  14019. //
  14020. // pvExtraPolicyStatus may optionally be set to point to the following
  14021. // AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS.
  14022. //--------------------------------------------------------------------------
  14023. // dwRegPolicySettings are defined in wintrust.h
  14024. type
  14025. PAUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA = ^AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA;
  14026. {$EXTERNALSYM PAUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA}
  14027. _AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA = record
  14028. cbSize: DWORD;
  14029. dwRegPolicySettings: DWORD;
  14030. pSignerInfo: PCMSG_SIGNER_INFO; // optional
  14031. end;
  14032. {$EXTERNALSYM _AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA}
  14033. AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA = _AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA;
  14034. {$EXTERNALSYM AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA}
  14035. TAuthenticodeExtraCertChainPolicyPara = AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA;
  14036. PAuthenticodeExtraCertChainPolicyPara = PAUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA;
  14037. PAUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS = ^AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS;
  14038. {$EXTERNALSYM PAUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS}
  14039. _AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS = record
  14040. cbSize: DWORD;
  14041. fCommercial: BOOL; // obtained from signer statement
  14042. end;
  14043. {$EXTERNALSYM _AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS}
  14044. AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS = _AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS;
  14045. {$EXTERNALSYM AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS}
  14046. TAuthenticodeExtraCertChainPolicyStatus = AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS;
  14047. PAuthenticodeExtraCertChainPolicyStatus = PAUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS;
  14048. //+-------------------------------------------------------------------------
  14049. // CERT_CHAIN_POLICY_AUTHENTICODE_TS
  14050. //
  14051. // Implements the Authenticode Time Stamp chain policy verification checks.
  14052. //
  14053. // pvExtraPolicyPara may optionally be set to point to the following
  14054. // AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA.
  14055. //
  14056. // pvExtraPolicyStatus isn't used and must be set to NULL.
  14057. //--------------------------------------------------------------------------
  14058. // dwRegPolicySettings are defined in wintrust.h
  14059. PAUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA = ^AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA;
  14060. {$EXTERNALSYM PAUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA}
  14061. _AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA = record
  14062. cbSize: DWORD;
  14063. dwRegPolicySettings: DWORD;
  14064. fCommercial: BOOL;
  14065. end;
  14066. {$EXTERNALSYM _AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA}
  14067. AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA = _AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA;
  14068. {$EXTERNALSYM AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA}
  14069. TAuthenticodeTsExtraCertChainPolicyPara = AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA;
  14070. PAuthenticodeTsExtraCertChainPolicyPara = PAUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA;
  14071. //+-------------------------------------------------------------------------
  14072. // CERT_CHAIN_POLICY_SSL
  14073. //
  14074. // Implements the SSL client/server chain policy verification checks.
  14075. //
  14076. // pvExtraPolicyPara may optionally be set to point to the following
  14077. // SSL_EXTRA_CERT_CHAIN_POLICY_PARA data structure
  14078. //--------------------------------------------------------------------------
  14079. // fdwChecks flags are defined in wininet.h
  14080. const
  14081. AUTHTYPE_CLIENT = 1;
  14082. {$EXTERNALSYM AUTHTYPE_CLIENT}
  14083. AUTHTYPE_SERVER = 2;
  14084. {$EXTERNALSYM AUTHTYPE_SERVER}
  14085. type
  14086. PHTTPSPolicyCallbackData = ^HTTPSPolicyCallbackData;
  14087. {$EXTERNALSYM PHTTPSPolicyCallbackData}
  14088. _HTTPSPolicyCallbackData = record
  14089. //union {
  14090. //cbStruct: DWORD; // sizeof(HTTPSPolicyCallbackData);
  14091. cbSize: DWORD; // sizeof(HTTPSPolicyCallbackData);
  14092. //};
  14093. dwAuthType: DWORD;
  14094. fdwChecks: DWORD;
  14095. pwszServerName: PWCHAR; // used to check against CN=xxxx
  14096. end;
  14097. {$EXTERNALSYM _HTTPSPolicyCallbackData}
  14098. HTTPSPolicyCallbackData = _HTTPSPolicyCallbackData;
  14099. {$EXTERNALSYM HTTPSPolicyCallbackData}
  14100. THttpsPolicyCallbackData = HTTPSPolicyCallbackData;
  14101. SSL_EXTRA_CERT_CHAIN_POLICY_PARA = HTTPSPolicyCallbackData;
  14102. {$EXTERNALSYM SSL_EXTRA_CERT_CHAIN_POLICY_PARA}
  14103. PSSL_EXTRA_CERT_CHAIN_POLICY_PARA = PHTTPSPolicyCallbackData;
  14104. {$EXTERNALSYM PSSL_EXTRA_CERT_CHAIN_POLICY_PARA}
  14105. TSSLExtraCertChainPolicyPara = SSL_EXTRA_CERT_CHAIN_POLICY_PARA;
  14106. PSSLExtraCertChainPolicyPara = PSSL_EXTRA_CERT_CHAIN_POLICY_PARA;
  14107. //+-------------------------------------------------------------------------
  14108. // CERT_CHAIN_POLICY_BASIC_CONSTRAINTS
  14109. //
  14110. // Implements the basic constraints chain policy.
  14111. //
  14112. // Iterates through all the certificates in the chain checking for either
  14113. // a szOID_BASIC_CONSTRAINTS or a szOID_BASIC_CONSTRAINTS2 extension. If
  14114. // neither extension is present, the certificate is assumed to have
  14115. // valid policy. Otherwise, for the first certificate element, checks if
  14116. // it matches the expected CA_FLAG or END_ENTITY_FLAG specified in
  14117. // pPolicyPara->dwFlags. If neither or both flags are set, then, the first
  14118. // element can be either a CA or END_ENTITY. All other elements must be
  14119. // a CA. If the PathLenConstraint is present in the extension, its
  14120. // checked.
  14121. //
  14122. // The first elements in the remaining simple chains (ie, the certificate
  14123. // used to sign the CTL) are checked to be an END_ENTITY.
  14124. //
  14125. // If this verification fails, dwError will be set to
  14126. // TRUST_E_BASIC_CONSTRAINTS.
  14127. //--------------------------------------------------------------------------
  14128. const
  14129. BASIC_CONSTRAINTS_CERT_CHAIN_POLICY_CA_FLAG = DWORD($80000000);
  14130. {$EXTERNALSYM BASIC_CONSTRAINTS_CERT_CHAIN_POLICY_CA_FLAG}
  14131. BASIC_CONSTRAINTS_CERT_CHAIN_POLICY_END_ENTITY_FLAG = $40000000;
  14132. {$EXTERNALSYM BASIC_CONSTRAINTS_CERT_CHAIN_POLICY_END_ENTITY_FLAG}
  14133. //+-------------------------------------------------------------------------
  14134. // CERT_CHAIN_POLICY_NT_AUTH
  14135. //
  14136. // Implements the NT Authentication chain policy.
  14137. //
  14138. // The NT Authentication chain policy consists of 3 distinct chain
  14139. // verifications in the following order:
  14140. // [1] CERT_CHAIN_POLICY_BASE - Implements the base chain policy
  14141. // verification checks. The LOWORD of dwFlags can be set in
  14142. // pPolicyPara to alter the default policy checking behaviour. See
  14143. // CERT_CHAIN_POLICY_BASE for more details.
  14144. //
  14145. // [2] CERT_CHAIN_POLICY_BASIC_CONSTRAINTS - Implements the basic
  14146. // constraints chain policy. The HIWORD of dwFlags can be set
  14147. // to specify if the first element must be either a CA or END_ENTITY.
  14148. // See CERT_CHAIN_POLICY_BASIC_CONSTRAINTS for more details.
  14149. //
  14150. // [3] Checks if the second element in the chain, the CA that issued
  14151. // the end certificate, is a trusted CA for NT
  14152. // Authentication. A CA is considered to be trusted if it exists in
  14153. // the "NTAuth" system registry store found in the
  14154. // CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE store location.
  14155. // If this verification fails, whereby the CA isn't trusted,
  14156. // dwError is set to CERT_E_UNTRUSTEDCA.
  14157. //--------------------------------------------------------------------------
  14158. {$ENDIF JWA_INTERFACESECTION}
  14159. {$IFNDEF JWA_INCLUDEMODE}
  14160. implementation
  14161. uses
  14162. JwaWinDLLNames;
  14163. {$ENDIF !JWA_INCLUDEMODE}
  14164. {$IFDEF JWA_IMPLEMENTATIONSECTION}
  14165. function GET_ALG_CLASS(x: DWORD): DWORD;
  14166. begin
  14167. Result := (x and (7 shl 13));
  14168. end;
  14169. function GET_ALG_TYPE(x: DWORD): DWORD;
  14170. begin
  14171. Result := (x and (15 shl 9));
  14172. end;
  14173. function GET_ALG_SID(x: DWORD): DWORD;
  14174. begin
  14175. Result := x and 511;
  14176. end;
  14177. function RCRYPT_SUCCEEDED(rt: BOOL): BOOL;
  14178. begin
  14179. Result := (rt = CRYPT_SUCCEED);
  14180. end;
  14181. function RCRYPT_FAILED(rt: BOOL): BOOL;
  14182. begin
  14183. Result := (rt = CRYPT_FAILED)
  14184. end;
  14185. function IS_CERT_RDN_CHAR_STRING(X: DWORD): Boolean;
  14186. begin
  14187. Result := (X and CERT_RDN_TYPE_MASK) >= CERT_RDN_NUMERIC_STRING;
  14188. end;
  14189. function GET_CERT_ENCODING_TYPE(X: DWORD): DWORD;
  14190. begin
  14191. Result := X and CERT_ENCODING_TYPE_MASK;
  14192. end;
  14193. function GET_CMSG_ENCODING_TYPE(X: DWORD): DWORD;
  14194. begin
  14195. Result := X and CMSG_ENCODING_TYPE_MASK;
  14196. end;
  14197. function GET_CERT_UNICODE_RDN_ERR_INDEX(X: DWORD): DWORD;
  14198. begin
  14199. Result := (X shr CERT_UNICODE_RDN_ERR_INDEX_SHIFT) and CERT_UNICODE_RDN_ERR_INDEX_MASK;
  14200. end;
  14201. function GET_CERT_UNICODE_ATTR_ERR_INDEX(X: DWORD): DWORD;
  14202. begin
  14203. Result := (X shr CERT_UNICODE_ATTR_ERR_INDEX_SHIFT) and CERT_UNICODE_ATTR_ERR_INDEX_MASK;
  14204. end;
  14205. function GET_CERT_UNICODE_VALUE_ERR_INDEX(X: DWORD): DWORD;
  14206. begin
  14207. Result := X and CERT_UNICODE_VALUE_ERR_INDEX_MASK;
  14208. end;
  14209. function GET_CERT_ALT_NAME_ENTRY_ERR_INDEX(X: DWORD): DWORD;
  14210. begin
  14211. Result := (X shr CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT) and CERT_ALT_NAME_ENTRY_ERR_INDEX_MASK;
  14212. end;
  14213. function GET_CERT_ALT_NAME_VALUE_ERR_INDEX(X: DWORD): DWORD;
  14214. begin
  14215. Result := X and CERT_ALT_NAME_VALUE_ERR_INDEX_MASK;
  14216. end;
  14217. function IS_CRL_DIST_POINT_ERR_CRL_ISSUER(X: DWORD): Boolean;
  14218. begin
  14219. Result := (X and CRL_DIST_POINT_ERR_CRL_ISSUER_BIT) <> 0;
  14220. end;
  14221. function GET_CRL_DIST_POINT_ERR_INDEX(X: DWORD): DWORD;
  14222. begin
  14223. Result := ((X shr CRL_DIST_POINT_ERR_INDEX_SHIFT) and CRL_DIST_POINT_ERR_INDEX_MASK);
  14224. end;
  14225. function IS_CERT_HASH_PROP_ID(X: DWORD): Boolean;
  14226. begin
  14227. Result := (CERT_SHA1_HASH_PROP_ID = X) or (CERT_MD5_HASH_PROP_ID = X) or
  14228. (CERT_SIGNATURE_HASH_PROP_ID = X);
  14229. end;
  14230. {$IFDEF DYNAMIC_LINK}
  14231. var
  14232. _CryptAcquireContextA: Pointer;
  14233. function CryptAcquireContextA;
  14234. begin
  14235. GetProcedureAddress(_CryptAcquireContextA, advapi32, 'CryptAcquireContextA');
  14236. asm
  14237. MOV ESP, EBP
  14238. POP EBP
  14239. JMP [_CryptAcquireContextA]
  14240. end;
  14241. end;
  14242. var
  14243. _CryptAcquireContextW: Pointer;
  14244. function CryptAcquireContextW;
  14245. begin
  14246. GetProcedureAddress(_CryptAcquireContextW, advapi32, 'CryptAcquireContextW');
  14247. asm
  14248. MOV ESP, EBP
  14249. POP EBP
  14250. JMP [_CryptAcquireContextW]
  14251. end;
  14252. end;
  14253. var
  14254. _CryptAcquireContext: Pointer;
  14255. function CryptAcquireContext;
  14256. begin
  14257. GetProcedureAddress(_CryptAcquireContext, advapi32, 'CryptAcquireContext' + AWSuffix);
  14258. asm
  14259. MOV ESP, EBP
  14260. POP EBP
  14261. JMP [_CryptAcquireContext]
  14262. end;
  14263. end;
  14264. var
  14265. _CryptReleaseContext: Pointer;
  14266. function CryptReleaseContext;
  14267. begin
  14268. GetProcedureAddress(_CryptReleaseContext, advapi32, 'CryptReleaseContext');
  14269. asm
  14270. MOV ESP, EBP
  14271. POP EBP
  14272. JMP [_CryptReleaseContext]
  14273. end;
  14274. end;
  14275. var
  14276. _CryptGenKey: Pointer;
  14277. function CryptGenKey;
  14278. begin
  14279. GetProcedureAddress(_CryptGenKey, advapi32, 'CryptGenKey');
  14280. asm
  14281. MOV ESP, EBP
  14282. POP EBP
  14283. JMP [_CryptGenKey]
  14284. end;
  14285. end;
  14286. var
  14287. _CryptDeriveKey: Pointer;
  14288. function CryptDeriveKey;
  14289. begin
  14290. GetProcedureAddress(_CryptDeriveKey, advapi32, 'CryptDeriveKey');
  14291. asm
  14292. MOV ESP, EBP
  14293. POP EBP
  14294. JMP [_CryptDeriveKey]
  14295. end;
  14296. end;
  14297. var
  14298. _CryptDestroyKey: Pointer;
  14299. function CryptDestroyKey;
  14300. begin
  14301. GetProcedureAddress(_CryptDestroyKey, advapi32, 'CryptDestroyKey');
  14302. asm
  14303. MOV ESP, EBP
  14304. POP EBP
  14305. JMP [_CryptDestroyKey]
  14306. end;
  14307. end;
  14308. var
  14309. _CryptSetKeyParam: Pointer;
  14310. function CryptSetKeyParam;
  14311. begin
  14312. GetProcedureAddress(_CryptSetKeyParam, crypt32, 'CryptSetKeyParam');
  14313. asm
  14314. MOV ESP, EBP
  14315. POP EBP
  14316. JMP [_CryptSetKeyParam]
  14317. end;
  14318. end;
  14319. var
  14320. _CryptGetKeyParam: Pointer;
  14321. function CryptGetKeyParam;
  14322. begin
  14323. GetProcedureAddress(_CryptGetKeyParam, advapi32, 'CryptGetKeyParam');
  14324. asm
  14325. MOV ESP, EBP
  14326. POP EBP
  14327. JMP [_CryptGetKeyParam]
  14328. end;
  14329. end;
  14330. var
  14331. _CryptSetHashParam: Pointer;
  14332. function CryptSetHashParam;
  14333. begin
  14334. GetProcedureAddress(_CryptSetHashParam, advapi32, 'CryptSetHashParam');
  14335. asm
  14336. MOV ESP, EBP
  14337. POP EBP
  14338. JMP [_CryptSetHashParam]
  14339. end;
  14340. end;
  14341. var
  14342. _CryptGetHashParam: Pointer;
  14343. function CryptGetHashParam;
  14344. begin
  14345. GetProcedureAddress(_CryptGetHashParam, advapi32, 'CryptGetHashParam');
  14346. asm
  14347. MOV ESP, EBP
  14348. POP EBP
  14349. JMP [_CryptGetHashParam]
  14350. end;
  14351. end;
  14352. var
  14353. _CryptSetProvParam: Pointer;
  14354. function CryptSetProvParam;
  14355. begin
  14356. GetProcedureAddress(_CryptSetProvParam, advapi32, 'CryptSetProvParam');
  14357. asm
  14358. MOV ESP, EBP
  14359. POP EBP
  14360. JMP [_CryptSetProvParam]
  14361. end;
  14362. end;
  14363. var
  14364. _CryptGetProvParam: Pointer;
  14365. function CryptGetProvParam;
  14366. begin
  14367. GetProcedureAddress(_CryptGetProvParam, advapi32, 'CryptGetProvParam');
  14368. asm
  14369. MOV ESP, EBP
  14370. POP EBP
  14371. JMP [_CryptGetProvParam]
  14372. end;
  14373. end;
  14374. var
  14375. _CryptGenRandom: Pointer;
  14376. function CryptGenRandom;
  14377. begin
  14378. GetProcedureAddress(_CryptGenRandom, advapi32, 'CryptGenRandom');
  14379. asm
  14380. MOV ESP, EBP
  14381. POP EBP
  14382. JMP [_CryptGenRandom]
  14383. end;
  14384. end;
  14385. var
  14386. _CryptGetUserKey: Pointer;
  14387. function CryptGetUserKey;
  14388. begin
  14389. GetProcedureAddress(_CryptGetUserKey, advapi32, 'CryptGetUserKey');
  14390. asm
  14391. MOV ESP, EBP
  14392. POP EBP
  14393. JMP [_CryptGetUserKey]
  14394. end;
  14395. end;
  14396. var
  14397. _CryptExportKey: Pointer;
  14398. function CryptExportKey;
  14399. begin
  14400. GetProcedureAddress(_CryptExportKey, advapi32, 'CryptExportKey');
  14401. asm
  14402. MOV ESP, EBP
  14403. POP EBP
  14404. JMP [_CryptExportKey]
  14405. end;
  14406. end;
  14407. var
  14408. _CryptImportKey: Pointer;
  14409. function CryptImportKey;
  14410. begin
  14411. GetProcedureAddress(_CryptImportKey, advapi32, 'CryptImportKey');
  14412. asm
  14413. MOV ESP, EBP
  14414. POP EBP
  14415. JMP [_CryptImportKey]
  14416. end;
  14417. end;
  14418. var
  14419. _CryptEncrypt: Pointer;
  14420. function CryptEncrypt;
  14421. begin
  14422. GetProcedureAddress(_CryptEncrypt, advapi32, 'CryptEncrypt');
  14423. asm
  14424. MOV ESP, EBP
  14425. POP EBP
  14426. JMP [_CryptEncrypt]
  14427. end;
  14428. end;
  14429. var
  14430. _CryptDecrypt: Pointer;
  14431. function CryptDecrypt;
  14432. begin
  14433. GetProcedureAddress(_CryptDecrypt, advapi32, 'CryptDecrypt');
  14434. asm
  14435. MOV ESP, EBP
  14436. POP EBP
  14437. JMP [_CryptDecrypt]
  14438. end;
  14439. end;
  14440. var
  14441. _CryptCreateHash: Pointer;
  14442. function CryptCreateHash;
  14443. begin
  14444. GetProcedureAddress(_CryptCreateHash, advapi32, 'CryptCreateHash');
  14445. asm
  14446. MOV ESP, EBP
  14447. POP EBP
  14448. JMP [_CryptCreateHash]
  14449. end;
  14450. end;
  14451. var
  14452. _CryptHashData: Pointer;
  14453. function CryptHashData;
  14454. begin
  14455. GetProcedureAddress(_CryptHashData, advapi32, 'CryptHashData');
  14456. asm
  14457. MOV ESP, EBP
  14458. POP EBP
  14459. JMP [_CryptHashData]
  14460. end;
  14461. end;
  14462. var
  14463. _CryptHashSessionKey: Pointer;
  14464. function CryptHashSessionKey;
  14465. begin
  14466. GetProcedureAddress(_CryptHashSessionKey, advapi32, 'CryptHashSessionKey');
  14467. asm
  14468. MOV ESP, EBP
  14469. POP EBP
  14470. JMP [_CryptHashSessionKey]
  14471. end;
  14472. end;
  14473. var
  14474. _CryptDestroyHash: Pointer;
  14475. function CryptDestroyHash;
  14476. begin
  14477. GetProcedureAddress(_CryptDestroyHash, advapi32, 'CryptDestroyHash');
  14478. asm
  14479. MOV ESP, EBP
  14480. POP EBP
  14481. JMP [_CryptDestroyHash]
  14482. end;
  14483. end;
  14484. var
  14485. _CryptSignHashA: Pointer;
  14486. function CryptSignHashA;
  14487. begin
  14488. GetProcedureAddress(_CryptSignHashA, advapi32, 'CryptSignHashA');
  14489. asm
  14490. MOV ESP, EBP
  14491. POP EBP
  14492. JMP [_CryptSignHashA]
  14493. end;
  14494. end;
  14495. var
  14496. _CryptSignHashW: Pointer;
  14497. function CryptSignHashW;
  14498. begin
  14499. GetProcedureAddress(_CryptSignHashW, advapi32, 'CryptSignHashW');
  14500. asm
  14501. MOV ESP, EBP
  14502. POP EBP
  14503. JMP [_CryptSignHashW]
  14504. end;
  14505. end;
  14506. var
  14507. _CryptSignHash: Pointer;
  14508. function CryptSignHash;
  14509. begin
  14510. GetProcedureAddress(_CryptSignHash, advapi32, 'CryptSignHash' + AWSuffix);
  14511. asm
  14512. MOV ESP, EBP
  14513. POP EBP
  14514. JMP [_CryptSignHash]
  14515. end;
  14516. end;
  14517. var
  14518. _CryptVerifySignatureA: Pointer;
  14519. function CryptVerifySignatureA;
  14520. begin
  14521. GetProcedureAddress(_CryptVerifySignatureA, advapi32, 'CryptVerifySignatureA');
  14522. asm
  14523. MOV ESP, EBP
  14524. POP EBP
  14525. JMP [_CryptVerifySignatureA]
  14526. end;
  14527. end;
  14528. var
  14529. _CryptVerifySignatureW: Pointer;
  14530. function CryptVerifySignatureW;
  14531. begin
  14532. GetProcedureAddress(_CryptVerifySignatureW, advapi32, 'CryptVerifySignatureW');
  14533. asm
  14534. MOV ESP, EBP
  14535. POP EBP
  14536. JMP [_CryptVerifySignatureW]
  14537. end;
  14538. end;
  14539. var
  14540. _CryptVerifySignature: Pointer;
  14541. function CryptVerifySignature;
  14542. begin
  14543. GetProcedureAddress(_CryptVerifySignature, advapi32, 'CryptVerifySignature' + AWSuffix);
  14544. asm
  14545. MOV ESP, EBP
  14546. POP EBP
  14547. JMP [_CryptVerifySignature]
  14548. end;
  14549. end;
  14550. var
  14551. _CryptSetProviderA: Pointer;
  14552. function CryptSetProviderA;
  14553. begin
  14554. GetProcedureAddress(_CryptSetProviderA, advapi32, 'CryptSetProviderA');
  14555. asm
  14556. MOV ESP, EBP
  14557. POP EBP
  14558. JMP [_CryptSetProviderA]
  14559. end;
  14560. end;
  14561. var
  14562. _CryptSetProviderW: Pointer;
  14563. function CryptSetProviderW;
  14564. begin
  14565. GetProcedureAddress(_CryptSetProviderW, advapi32, 'CryptSetProviderW');
  14566. asm
  14567. MOV ESP, EBP
  14568. POP EBP
  14569. JMP [_CryptSetProviderW]
  14570. end;
  14571. end;
  14572. var
  14573. _CryptSetProvider: Pointer;
  14574. function CryptSetProvider;
  14575. begin
  14576. GetProcedureAddress(_CryptSetProvider, advapi32, 'CryptSetProvider' + AWSuffix);
  14577. asm
  14578. MOV ESP, EBP
  14579. POP EBP
  14580. JMP [_CryptSetProvider]
  14581. end;
  14582. end;
  14583. var
  14584. _CryptSetProviderExA: Pointer;
  14585. function CryptSetProviderExA;
  14586. begin
  14587. GetProcedureAddress(_CryptSetProviderExA, advapi32, 'CryptSetProviderExA');
  14588. asm
  14589. MOV ESP, EBP
  14590. POP EBP
  14591. JMP [_CryptSetProviderExA]
  14592. end;
  14593. end;
  14594. var
  14595. _CryptSetProviderExW: Pointer;
  14596. function CryptSetProviderExW;
  14597. begin
  14598. GetProcedureAddress(_CryptSetProviderExW, advapi32, 'CryptSetProviderExW');
  14599. asm
  14600. MOV ESP, EBP
  14601. POP EBP
  14602. JMP [_CryptSetProviderExW]
  14603. end;
  14604. end;
  14605. var
  14606. _CryptSetProviderEx: Pointer;
  14607. function CryptSetProviderEx;
  14608. begin
  14609. GetProcedureAddress(_CryptSetProviderEx, advapi32, 'CryptSetProviderEx' + AWSuffix);
  14610. asm
  14611. MOV ESP, EBP
  14612. POP EBP
  14613. JMP [_CryptSetProviderEx]
  14614. end;
  14615. end;
  14616. var
  14617. _CryptGetDefaultProviderA: Pointer;
  14618. function CryptGetDefaultProviderA;
  14619. begin
  14620. GetProcedureAddress(_CryptGetDefaultProviderA, advapi32, 'CryptGetDefaultProviderA');
  14621. asm
  14622. MOV ESP, EBP
  14623. POP EBP
  14624. JMP [_CryptGetDefaultProviderA]
  14625. end;
  14626. end;
  14627. var
  14628. _CryptGetDefaultProviderW: Pointer;
  14629. function CryptGetDefaultProviderW;
  14630. begin
  14631. GetProcedureAddress(_CryptGetDefaultProviderW, advapi32, 'CryptGetDefaultProviderW');
  14632. asm
  14633. MOV ESP, EBP
  14634. POP EBP
  14635. JMP [_CryptGetDefaultProviderW]
  14636. end;
  14637. end;
  14638. var
  14639. _CryptGetDefaultProvider: Pointer;
  14640. function CryptGetDefaultProvider;
  14641. begin
  14642. GetProcedureAddress(_CryptGetDefaultProvider, advapi32, 'CryptGetDefaultProvider' + AWSuffix);
  14643. asm
  14644. MOV ESP, EBP
  14645. POP EBP
  14646. JMP [_CryptGetDefaultProvider]
  14647. end;
  14648. end;
  14649. var
  14650. _CryptEnumProviderTypesA: Pointer;
  14651. function CryptEnumProviderTypesA;
  14652. begin
  14653. GetProcedureAddress(_CryptEnumProviderTypesA, advapi32, 'CryptEnumProviderTypesA');
  14654. asm
  14655. MOV ESP, EBP
  14656. POP EBP
  14657. JMP [_CryptEnumProviderTypesA]
  14658. end;
  14659. end;
  14660. var
  14661. _CryptEnumProviderTypesW: Pointer;
  14662. function CryptEnumProviderTypesW;
  14663. begin
  14664. GetProcedureAddress(_CryptEnumProviderTypesW, advapi32, 'CryptEnumProviderTypesW');
  14665. asm
  14666. MOV ESP, EBP
  14667. POP EBP
  14668. JMP [_CryptEnumProviderTypesW]
  14669. end;
  14670. end;
  14671. var
  14672. _CryptEnumProviderTypes: Pointer;
  14673. function CryptEnumProviderTypes;
  14674. begin
  14675. GetProcedureAddress(_CryptEnumProviderTypes, advapi32, 'CryptEnumProviderTypes' + AWSuffix);
  14676. asm
  14677. MOV ESP, EBP
  14678. POP EBP
  14679. JMP [_CryptEnumProviderTypes]
  14680. end;
  14681. end;
  14682. var
  14683. _CryptEnumProvidersA: Pointer;
  14684. function CryptEnumProvidersA;
  14685. begin
  14686. GetProcedureAddress(_CryptEnumProvidersA, advapi32, 'CryptEnumProvidersA');
  14687. asm
  14688. MOV ESP, EBP
  14689. POP EBP
  14690. JMP [_CryptEnumProvidersA]
  14691. end;
  14692. end;
  14693. var
  14694. _CryptEnumProvidersW: Pointer;
  14695. function CryptEnumProvidersW;
  14696. begin
  14697. GetProcedureAddress(_CryptEnumProvidersW, advapi32, 'CryptEnumProvidersW');
  14698. asm
  14699. MOV ESP, EBP
  14700. POP EBP
  14701. JMP [_CryptEnumProvidersW]
  14702. end;
  14703. end;
  14704. var
  14705. _CryptEnumProviders: Pointer;
  14706. function CryptEnumProviders;
  14707. begin
  14708. GetProcedureAddress(_CryptEnumProviders, advapi32, 'CryptEnumProviders' + AWSuffix);
  14709. asm
  14710. MOV ESP, EBP
  14711. POP EBP
  14712. JMP [_CryptEnumProviders]
  14713. end;
  14714. end;
  14715. var
  14716. _CryptContextAddRef: Pointer;
  14717. function CryptContextAddRef;
  14718. begin
  14719. GetProcedureAddress(_CryptContextAddRef, advapi32, 'CryptContextAddRef');
  14720. asm
  14721. MOV ESP, EBP
  14722. POP EBP
  14723. JMP [_CryptContextAddRef]
  14724. end;
  14725. end;
  14726. var
  14727. _CryptDuplicateKey: Pointer;
  14728. function CryptDuplicateKey;
  14729. begin
  14730. GetProcedureAddress(_CryptDuplicateKey, advapi32, 'CryptDuplicateKey');
  14731. asm
  14732. MOV ESP, EBP
  14733. POP EBP
  14734. JMP [_CryptDuplicateKey]
  14735. end;
  14736. end;
  14737. var
  14738. _CryptDuplicateHash: Pointer;
  14739. function CryptDuplicateHash;
  14740. begin
  14741. GetProcedureAddress(_CryptDuplicateHash, advapi32, 'CryptDuplicateHash');
  14742. asm
  14743. MOV ESP, EBP
  14744. POP EBP
  14745. JMP [_CryptDuplicateHash]
  14746. end;
  14747. end;
  14748. var
  14749. _CryptFormatObject: Pointer;
  14750. function CryptFormatObject;
  14751. begin
  14752. GetProcedureAddress(_CryptFormatObject, crypt32, 'CryptFormatObject');
  14753. asm
  14754. MOV ESP, EBP
  14755. POP EBP
  14756. JMP [_CryptFormatObject]
  14757. end;
  14758. end;
  14759. var
  14760. _CryptEncodeObjectEx: Pointer;
  14761. function CryptEncodeObjectEx;
  14762. begin
  14763. GetProcedureAddress(_CryptEncodeObjectEx, crypt32, 'CryptEncodeObjectEx');
  14764. asm
  14765. MOV ESP, EBP
  14766. POP EBP
  14767. JMP [_CryptEncodeObjectEx]
  14768. end;
  14769. end;
  14770. var
  14771. _CryptEncodeObject: Pointer;
  14772. function CryptEncodeObject;
  14773. begin
  14774. GetProcedureAddress(_CryptEncodeObject, crypt32, 'CryptEncodeObject');
  14775. asm
  14776. MOV ESP, EBP
  14777. POP EBP
  14778. JMP [_CryptEncodeObject]
  14779. end;
  14780. end;
  14781. var
  14782. _CryptDecodeObjectEx: Pointer;
  14783. function CryptDecodeObjectEx;
  14784. begin
  14785. GetProcedureAddress(_CryptDecodeObjectEx, crypt32, 'CryptDecodeObjectEx');
  14786. asm
  14787. MOV ESP, EBP
  14788. POP EBP
  14789. JMP [_CryptDecodeObjectEx]
  14790. end;
  14791. end;
  14792. var
  14793. _CryptDecodeObject: Pointer;
  14794. function CryptDecodeObject;
  14795. begin
  14796. GetProcedureAddress(_CryptDecodeObject, crypt32, 'CryptDecodeObject');
  14797. asm
  14798. MOV ESP, EBP
  14799. POP EBP
  14800. JMP [_CryptDecodeObject]
  14801. end;
  14802. end;
  14803. var
  14804. _CryptInstallOIDFunctionAddress: Pointer;
  14805. function CryptInstallOIDFunctionAddress;
  14806. begin
  14807. GetProcedureAddress(_CryptInstallOIDFunctionAddress, crypt32, 'CryptInstallOIDFunctionAddress');
  14808. asm
  14809. MOV ESP, EBP
  14810. POP EBP
  14811. JMP [_CryptInstallOIDFunctionAddress]
  14812. end;
  14813. end;
  14814. var
  14815. _CryptInitOIDFunctionSet: Pointer;
  14816. function CryptInitOIDFunctionSet;
  14817. begin
  14818. GetProcedureAddress(_CryptInitOIDFunctionSet, crypt32, 'CryptInitOIDFunctionSet');
  14819. asm
  14820. MOV ESP, EBP
  14821. POP EBP
  14822. JMP [_CryptInitOIDFunctionSet]
  14823. end;
  14824. end;
  14825. var
  14826. _CryptGetOIDFunctionAddress: Pointer;
  14827. function CryptGetOIDFunctionAddress;
  14828. begin
  14829. GetProcedureAddress(_CryptGetOIDFunctionAddress, crypt32, 'CryptGetOIDFunctionAddress');
  14830. asm
  14831. MOV ESP, EBP
  14832. POP EBP
  14833. JMP [_CryptGetOIDFunctionAddress]
  14834. end;
  14835. end;
  14836. var
  14837. _CryptGetDefaultOIDDllList: Pointer;
  14838. function CryptGetDefaultOIDDllList;
  14839. begin
  14840. GetProcedureAddress(_CryptGetDefaultOIDDllList, crypt32, 'CryptGetDefaultOIDDllList');
  14841. asm
  14842. MOV ESP, EBP
  14843. POP EBP
  14844. JMP [_CryptGetDefaultOIDDllList]
  14845. end;
  14846. end;
  14847. var
  14848. _CryptGetDefaultOIDFunctionAddr: Pointer;
  14849. function CryptGetDefaultOIDFunctionAddress;
  14850. begin
  14851. GetProcedureAddress(_CryptGetDefaultOIDFunctionAddr, crypt32, 'CryptGetDefaultOIDFunctionAddress');
  14852. asm
  14853. MOV ESP, EBP
  14854. POP EBP
  14855. JMP [_CryptGetDefaultOIDFunctionAddr]
  14856. end;
  14857. end;
  14858. var
  14859. _CryptFreeOIDFunctionAddress: Pointer;
  14860. function CryptFreeOIDFunctionAddress;
  14861. begin
  14862. GetProcedureAddress(_CryptFreeOIDFunctionAddress, crypt32, 'CryptFreeOIDFunctionAddress');
  14863. asm
  14864. MOV ESP, EBP
  14865. POP EBP
  14866. JMP [_CryptFreeOIDFunctionAddress]
  14867. end;
  14868. end;
  14869. var
  14870. _CryptRegisterOIDFunction: Pointer;
  14871. function CryptRegisterOIDFunction;
  14872. begin
  14873. GetProcedureAddress(_CryptRegisterOIDFunction, crypt32, 'CryptRegisterOIDFunction');
  14874. asm
  14875. MOV ESP, EBP
  14876. POP EBP
  14877. JMP [_CryptRegisterOIDFunction]
  14878. end;
  14879. end;
  14880. var
  14881. _CryptUnregisterOIDFunction: Pointer;
  14882. function CryptUnregisterOIDFunction;
  14883. begin
  14884. GetProcedureAddress(_CryptUnregisterOIDFunction, crypt32, 'CryptUnregisterOIDFunction');
  14885. asm
  14886. MOV ESP, EBP
  14887. POP EBP
  14888. JMP [_CryptUnregisterOIDFunction]
  14889. end;
  14890. end;
  14891. var
  14892. _CryptRegisterDefaultOIDFunction: Pointer;
  14893. function CryptRegisterDefaultOIDFunction;
  14894. begin
  14895. GetProcedureAddress(_CryptRegisterDefaultOIDFunction, crypt32, 'CryptRegisterDefaultOIDFunction');
  14896. asm
  14897. MOV ESP, EBP
  14898. POP EBP
  14899. JMP [_CryptRegisterDefaultOIDFunction]
  14900. end;
  14901. end;
  14902. var
  14903. _CryptUnregisterDefaultOIDFunc: Pointer;
  14904. function CryptUnregisterDefaultOIDFunction;
  14905. begin
  14906. GetProcedureAddress(_CryptUnregisterDefaultOIDFunc, crypt32, 'CryptUnregisterDefaultOIDFunction');
  14907. asm
  14908. MOV ESP, EBP
  14909. POP EBP
  14910. JMP [_CryptUnregisterDefaultOIDFunc]
  14911. end;
  14912. end;
  14913. var
  14914. _CryptSetOIDFunctionValue: Pointer;
  14915. function CryptSetOIDFunctionValue;
  14916. begin
  14917. GetProcedureAddress(_CryptSetOIDFunctionValue, crypt32, 'CryptSetOIDFunctionValue');
  14918. asm
  14919. MOV ESP, EBP
  14920. POP EBP
  14921. JMP [_CryptSetOIDFunctionValue]
  14922. end;
  14923. end;
  14924. var
  14925. _CryptGetOIDFunctionValue: Pointer;
  14926. function CryptGetOIDFunctionValue;
  14927. begin
  14928. GetProcedureAddress(_CryptGetOIDFunctionValue, crypt32, 'CryptGetOIDFunctionValue');
  14929. asm
  14930. MOV ESP, EBP
  14931. POP EBP
  14932. JMP [_CryptGetOIDFunctionValue]
  14933. end;
  14934. end;
  14935. var
  14936. _CryptEnumOIDFunction: Pointer;
  14937. function CryptEnumOIDFunction;
  14938. begin
  14939. GetProcedureAddress(_CryptEnumOIDFunction, crypt32, 'CryptEnumOIDFunction');
  14940. asm
  14941. MOV ESP, EBP
  14942. POP EBP
  14943. JMP [_CryptEnumOIDFunction]
  14944. end;
  14945. end;
  14946. var
  14947. _CryptFindOIDInfo: Pointer;
  14948. function CryptFindOIDInfo;
  14949. begin
  14950. GetProcedureAddress(_CryptFindOIDInfo, crypt32, 'CryptFindOIDInfo');
  14951. asm
  14952. MOV ESP, EBP
  14953. POP EBP
  14954. JMP [_CryptFindOIDInfo]
  14955. end;
  14956. end;
  14957. var
  14958. _CryptRegisterOIDInfo: Pointer;
  14959. function CryptRegisterOIDInfo;
  14960. begin
  14961. GetProcedureAddress(_CryptRegisterOIDInfo, crypt32, 'CryptRegisterOIDInfo');
  14962. asm
  14963. MOV ESP, EBP
  14964. POP EBP
  14965. JMP [_CryptRegisterOIDInfo]
  14966. end;
  14967. end;
  14968. var
  14969. _CryptUnregisterOIDInfo: Pointer;
  14970. function CryptUnregisterOIDInfo;
  14971. begin
  14972. GetProcedureAddress(_CryptUnregisterOIDInfo, crypt32, 'CryptUnregisterOIDInfo');
  14973. asm
  14974. MOV ESP, EBP
  14975. POP EBP
  14976. JMP [_CryptUnregisterOIDInfo]
  14977. end;
  14978. end;
  14979. var
  14980. _CryptEnumOIDInfo: Pointer;
  14981. function CryptEnumOIDInfo;
  14982. begin
  14983. GetProcedureAddress(_CryptEnumOIDInfo, crypt32, 'CryptEnumOIDInfo');
  14984. asm
  14985. MOV ESP, EBP
  14986. POP EBP
  14987. JMP [_CryptEnumOIDInfo]
  14988. end;
  14989. end;
  14990. var
  14991. _CryptFindLocalizedName: Pointer;
  14992. function CryptFindLocalizedName;
  14993. begin
  14994. GetProcedureAddress(_CryptFindLocalizedName, crypt32, 'CryptFindLocalizedName');
  14995. asm
  14996. MOV ESP, EBP
  14997. POP EBP
  14998. JMP [_CryptFindLocalizedName]
  14999. end;
  15000. end;
  15001. var
  15002. _CryptMsgOpenToEncode: Pointer;
  15003. function CryptMsgOpenToEncode;
  15004. begin
  15005. GetProcedureAddress(_CryptMsgOpenToEncode, crypt32, 'CryptMsgOpenToEncode');
  15006. asm
  15007. MOV ESP, EBP
  15008. POP EBP
  15009. JMP [_CryptMsgOpenToEncode]
  15010. end;
  15011. end;
  15012. var
  15013. _CryptMsgCalculateEncodedLength: Pointer;
  15014. function CryptMsgCalculateEncodedLength;
  15015. begin
  15016. GetProcedureAddress(_CryptMsgCalculateEncodedLength, crypt32, 'CryptMsgCalculateEncodedLength');
  15017. asm
  15018. MOV ESP, EBP
  15019. POP EBP
  15020. JMP [_CryptMsgCalculateEncodedLength]
  15021. end;
  15022. end;
  15023. var
  15024. _CryptMsgOpenToDecode: Pointer;
  15025. function CryptMsgOpenToDecode;
  15026. begin
  15027. GetProcedureAddress(_CryptMsgOpenToDecode, crypt32, 'CryptMsgOpenToDecode');
  15028. asm
  15029. MOV ESP, EBP
  15030. POP EBP
  15031. JMP [_CryptMsgOpenToDecode]
  15032. end;
  15033. end;
  15034. var
  15035. _CryptMsgDuplicate: Pointer;
  15036. function CryptMsgDuplicate;
  15037. begin
  15038. GetProcedureAddress(_CryptMsgDuplicate, crypt32, 'CryptMsgDuplicate');
  15039. asm
  15040. MOV ESP, EBP
  15041. POP EBP
  15042. JMP [_CryptMsgDuplicate]
  15043. end;
  15044. end;
  15045. var
  15046. _CryptMsgClose: Pointer;
  15047. function CryptMsgClose;
  15048. begin
  15049. GetProcedureAddress(_CryptMsgClose, crypt32, 'CryptMsgClose');
  15050. asm
  15051. MOV ESP, EBP
  15052. POP EBP
  15053. JMP [_CryptMsgClose]
  15054. end;
  15055. end;
  15056. var
  15057. _CryptMsgUpdate: Pointer;
  15058. function CryptMsgUpdate;
  15059. begin
  15060. GetProcedureAddress(_CryptMsgUpdate, crypt32, 'CryptMsgUpdate');
  15061. asm
  15062. MOV ESP, EBP
  15063. POP EBP
  15064. JMP [_CryptMsgUpdate]
  15065. end;
  15066. end;
  15067. var
  15068. _CryptMsgGetParam: Pointer;
  15069. function CryptMsgGetParam;
  15070. begin
  15071. GetProcedureAddress(_CryptMsgGetParam, crypt32, 'CryptMsgGetParam');
  15072. asm
  15073. MOV ESP, EBP
  15074. POP EBP
  15075. JMP [_CryptMsgGetParam]
  15076. end;
  15077. end;
  15078. var
  15079. _CryptMsgControl: Pointer;
  15080. function CryptMsgControl;
  15081. begin
  15082. GetProcedureAddress(_CryptMsgControl, crypt32, 'CryptMsgControl');
  15083. asm
  15084. MOV ESP, EBP
  15085. POP EBP
  15086. JMP [_CryptMsgControl]
  15087. end;
  15088. end;
  15089. var
  15090. _CryptMsgVerifyCountersigEnc: Pointer;
  15091. function CryptMsgVerifyCountersignatureEncoded;
  15092. begin
  15093. GetProcedureAddress(_CryptMsgVerifyCountersigEnc, crypt32, 'CryptMsgVerifyCountersignatureEncoded');
  15094. asm
  15095. MOV ESP, EBP
  15096. POP EBP
  15097. JMP [_CryptMsgVerifyCountersigEnc]
  15098. end;
  15099. end;
  15100. var
  15101. _CryptMsgVerifyCountersigEncEx: Pointer;
  15102. function CryptMsgVerifyCountersignatureEncodedEx;
  15103. begin
  15104. GetProcedureAddress(_CryptMsgVerifyCountersigEncEx, crypt32, 'CryptMsgVerifyCountersignatureEncodedEx');
  15105. asm
  15106. MOV ESP, EBP
  15107. POP EBP
  15108. JMP [_CryptMsgVerifyCountersigEncEx]
  15109. end;
  15110. end;
  15111. var
  15112. _CryptMsgCountersign: Pointer;
  15113. function CryptMsgCountersign;
  15114. begin
  15115. GetProcedureAddress(_CryptMsgCountersign, crypt32, 'CryptMsgCountersign');
  15116. asm
  15117. MOV ESP, EBP
  15118. POP EBP
  15119. JMP [_CryptMsgCountersign]
  15120. end;
  15121. end;
  15122. var
  15123. _CryptMsgCountersignEncoded: Pointer;
  15124. function CryptMsgCountersignEncoded;
  15125. begin
  15126. GetProcedureAddress(_CryptMsgCountersignEncoded, crypt32, 'CryptMsgCountersignEncoded');
  15127. asm
  15128. MOV ESP, EBP
  15129. POP EBP
  15130. JMP [_CryptMsgCountersignEncoded]
  15131. end;
  15132. end;
  15133. var
  15134. _CertOpenStore: Pointer;
  15135. function CertOpenStore;
  15136. begin
  15137. GetProcedureAddress(_CertOpenStore, crypt32, 'CertOpenStore');
  15138. asm
  15139. MOV ESP, EBP
  15140. POP EBP
  15141. JMP [_CertOpenStore]
  15142. end;
  15143. end;
  15144. var
  15145. _CertDuplicateStore: Pointer;
  15146. function CertDuplicateStore;
  15147. begin
  15148. GetProcedureAddress(_CertDuplicateStore, crypt32, 'CertDuplicateStore');
  15149. asm
  15150. MOV ESP, EBP
  15151. POP EBP
  15152. JMP [_CertDuplicateStore]
  15153. end;
  15154. end;
  15155. var
  15156. _CertSaveStore: Pointer;
  15157. function CertSaveStore;
  15158. begin
  15159. GetProcedureAddress(_CertSaveStore, crypt32, 'CertSaveStore');
  15160. asm
  15161. MOV ESP, EBP
  15162. POP EBP
  15163. JMP [_CertSaveStore]
  15164. end;
  15165. end;
  15166. var
  15167. _CertCloseStore: Pointer;
  15168. function CertCloseStore;
  15169. begin
  15170. GetProcedureAddress(_CertCloseStore, crypt32, 'CertCloseStore');
  15171. asm
  15172. MOV ESP, EBP
  15173. POP EBP
  15174. JMP [_CertCloseStore]
  15175. end;
  15176. end;
  15177. var
  15178. _CertGetSubjectCertFromStore: Pointer;
  15179. function CertGetSubjectCertificateFromStore;
  15180. begin
  15181. GetProcedureAddress(_CertGetSubjectCertFromStore, crypt32, 'CertGetSubjectCertificateFromStore');
  15182. asm
  15183. MOV ESP, EBP
  15184. POP EBP
  15185. JMP [_CertGetSubjectCertFromStore]
  15186. end;
  15187. end;
  15188. var
  15189. _CertEnumCertificatesInStore: Pointer;
  15190. function CertEnumCertificatesInStore;
  15191. begin
  15192. GetProcedureAddress(_CertEnumCertificatesInStore, crypt32, 'CertEnumCertificatesInStore');
  15193. asm
  15194. MOV ESP, EBP
  15195. POP EBP
  15196. JMP [_CertEnumCertificatesInStore]
  15197. end;
  15198. end;
  15199. var
  15200. _CertFindCertificateInStore: Pointer;
  15201. function CertFindCertificateInStore;
  15202. begin
  15203. GetProcedureAddress(_CertFindCertificateInStore, crypt32, 'CertFindCertificateInStore');
  15204. asm
  15205. MOV ESP, EBP
  15206. POP EBP
  15207. JMP [_CertFindCertificateInStore]
  15208. end;
  15209. end;
  15210. var
  15211. _CertGetIssuerCertFromStore: Pointer;
  15212. function CertGetIssuerCertificateFromStore;
  15213. begin
  15214. GetProcedureAddress(_CertGetIssuerCertFromStore, crypt32, 'CertGetIssuerCertificateFromStore');
  15215. asm
  15216. MOV ESP, EBP
  15217. POP EBP
  15218. JMP [_CertGetIssuerCertFromStore]
  15219. end;
  15220. end;
  15221. var
  15222. _CertVerifySubjectCertContext: Pointer;
  15223. function CertVerifySubjectCertificateContext;
  15224. begin
  15225. GetProcedureAddress(_CertVerifySubjectCertContext, crypt32, 'CertVerifySubjectCertificateContext');
  15226. asm
  15227. MOV ESP, EBP
  15228. POP EBP
  15229. JMP [_CertVerifySubjectCertContext]
  15230. end;
  15231. end;
  15232. var
  15233. _CertDuplicateCertificateContext: Pointer;
  15234. function CertDuplicateCertificateContext;
  15235. begin
  15236. GetProcedureAddress(_CertDuplicateCertificateContext, crypt32, 'CertDuplicateCertificateContext');
  15237. asm
  15238. MOV ESP, EBP
  15239. POP EBP
  15240. JMP [_CertDuplicateCertificateContext]
  15241. end;
  15242. end;
  15243. var
  15244. _CertCreateCertificateContext: Pointer;
  15245. function CertCreateCertificateContext;
  15246. begin
  15247. GetProcedureAddress(_CertCreateCertificateContext, crypt32, 'CertCreateCertificateContext');
  15248. asm
  15249. MOV ESP, EBP
  15250. POP EBP
  15251. JMP [_CertCreateCertificateContext]
  15252. end;
  15253. end;
  15254. var
  15255. _CertFreeCertificateContext: Pointer;
  15256. function CertFreeCertificateContext;
  15257. begin
  15258. GetProcedureAddress(_CertFreeCertificateContext, crypt32, 'CertFreeCertificateContext');
  15259. asm
  15260. MOV ESP, EBP
  15261. POP EBP
  15262. JMP [_CertFreeCertificateContext]
  15263. end;
  15264. end;
  15265. var
  15266. _CertSetCertContextProperty: Pointer;
  15267. function CertSetCertificateContextProperty;
  15268. begin
  15269. GetProcedureAddress(_CertSetCertContextProperty, crypt32, 'CertSetCertificateContextProperty');
  15270. asm
  15271. MOV ESP, EBP
  15272. POP EBP
  15273. JMP [_CertSetCertContextProperty]
  15274. end;
  15275. end;
  15276. var
  15277. _CertGetCertContextProperty: Pointer;
  15278. function CertGetCertificateContextProperty;
  15279. begin
  15280. GetProcedureAddress(_CertGetCertContextProperty, crypt32, 'CertGetCertificateContextProperty');
  15281. asm
  15282. MOV ESP, EBP
  15283. POP EBP
  15284. JMP [_CertGetCertContextProperty]
  15285. end;
  15286. end;
  15287. var
  15288. _CertEnumCertContextProperties: Pointer;
  15289. function CertEnumCertificateContextProperties;
  15290. begin
  15291. GetProcedureAddress(_CertEnumCertContextProperties, crypt32, 'CertEnumCertificateContextProperties');
  15292. asm
  15293. MOV ESP, EBP
  15294. POP EBP
  15295. JMP [_CertEnumCertContextProperties]
  15296. end;
  15297. end;
  15298. var
  15299. _CertGetCRLFromStore: Pointer;
  15300. function CertGetCRLFromStore;
  15301. begin
  15302. GetProcedureAddress(_CertGetCRLFromStore, crypt32, 'CertGetCRLFromStore');
  15303. asm
  15304. MOV ESP, EBP
  15305. POP EBP
  15306. JMP [_CertGetCRLFromStore]
  15307. end;
  15308. end;
  15309. var
  15310. _CertEnumCRLsInStore: Pointer;
  15311. function CertEnumCRLsInStore;
  15312. begin
  15313. GetProcedureAddress(_CertEnumCRLsInStore, crypt32, 'CertEnumCRLsInStore');
  15314. asm
  15315. MOV ESP, EBP
  15316. POP EBP
  15317. JMP [_CertEnumCRLsInStore]
  15318. end;
  15319. end;
  15320. var
  15321. _CertFindCRLInStore: Pointer;
  15322. function CertFindCRLInStore;
  15323. begin
  15324. GetProcedureAddress(_CertFindCRLInStore, crypt32, 'CertFindCRLInStore');
  15325. asm
  15326. MOV ESP, EBP
  15327. POP EBP
  15328. JMP [_CertFindCRLInStore]
  15329. end;
  15330. end;
  15331. var
  15332. _CertDuplicateCRLContext: Pointer;
  15333. function CertDuplicateCRLContext;
  15334. begin
  15335. GetProcedureAddress(_CertDuplicateCRLContext, crypt32, 'CertDuplicateCRLContext');
  15336. asm
  15337. MOV ESP, EBP
  15338. POP EBP
  15339. JMP [_CertDuplicateCRLContext]
  15340. end;
  15341. end;
  15342. var
  15343. _CertCreateCRLContext: Pointer;
  15344. function CertCreateCRLContext;
  15345. begin
  15346. GetProcedureAddress(_CertCreateCRLContext, crypt32, 'CertCreateCRLContext');
  15347. asm
  15348. MOV ESP, EBP
  15349. POP EBP
  15350. JMP [_CertCreateCRLContext]
  15351. end;
  15352. end;
  15353. var
  15354. _CertFreeCRLContext: Pointer;
  15355. function CertFreeCRLContext;
  15356. begin
  15357. GetProcedureAddress(_CertFreeCRLContext, crypt32, 'CertFreeCRLContext');
  15358. asm
  15359. MOV ESP, EBP
  15360. POP EBP
  15361. JMP [_CertFreeCRLContext]
  15362. end;
  15363. end;
  15364. var
  15365. _CertSetCRLContextProperty: Pointer;
  15366. function CertSetCRLContextProperty;
  15367. begin
  15368. GetProcedureAddress(_CertSetCRLContextProperty, crypt32, 'CertSetCRLContextProperty');
  15369. asm
  15370. MOV ESP, EBP
  15371. POP EBP
  15372. JMP [_CertSetCRLContextProperty]
  15373. end;
  15374. end;
  15375. var
  15376. _CertGetCRLContextProperty: Pointer;
  15377. function CertGetCRLContextProperty;
  15378. begin
  15379. GetProcedureAddress(_CertGetCRLContextProperty, crypt32, 'CertGetCRLContextProperty');
  15380. asm
  15381. MOV ESP, EBP
  15382. POP EBP
  15383. JMP [_CertGetCRLContextProperty]
  15384. end;
  15385. end;
  15386. var
  15387. _CertEnumCRLContextProperties: Pointer;
  15388. function CertEnumCRLContextProperties;
  15389. begin
  15390. GetProcedureAddress(_CertEnumCRLContextProperties, crypt32, 'CertEnumCRLContextProperties');
  15391. asm
  15392. MOV ESP, EBP
  15393. POP EBP
  15394. JMP [_CertEnumCRLContextProperties]
  15395. end;
  15396. end;
  15397. var
  15398. _CertFindCertificateInCRL: Pointer;
  15399. function CertFindCertificateInCRL;
  15400. begin
  15401. GetProcedureAddress(_CertFindCertificateInCRL, crypt32, 'CertFindCertificateInCRL');
  15402. asm
  15403. MOV ESP, EBP
  15404. POP EBP
  15405. JMP [_CertFindCertificateInCRL]
  15406. end;
  15407. end;
  15408. var
  15409. _CertAddEncodedCertToStore: Pointer;
  15410. function CertAddEncodedCertificateToStore;
  15411. begin
  15412. GetProcedureAddress(_CertAddEncodedCertToStore, crypt32, 'CertAddEncodedCertificateToStore');
  15413. asm
  15414. MOV ESP, EBP
  15415. POP EBP
  15416. JMP [_CertAddEncodedCertToStore]
  15417. end;
  15418. end;
  15419. var
  15420. _CertAddCertContextToStore: Pointer;
  15421. function CertAddCertificateContextToStore;
  15422. begin
  15423. GetProcedureAddress(_CertAddCertContextToStore, crypt32, 'CertAddCertificateContextToStore');
  15424. asm
  15425. MOV ESP, EBP
  15426. POP EBP
  15427. JMP [_CertAddCertContextToStore]
  15428. end;
  15429. end;
  15430. var
  15431. _CertAddSerializedElementToStore: Pointer;
  15432. function CertAddSerializedElementToStore;
  15433. begin
  15434. GetProcedureAddress(_CertAddSerializedElementToStore, crypt32, 'CertAddSerializedElementToStore');
  15435. asm
  15436. MOV ESP, EBP
  15437. POP EBP
  15438. JMP [_CertAddSerializedElementToStore]
  15439. end;
  15440. end;
  15441. var
  15442. _CertDeleteCertificateFromStore: Pointer;
  15443. function CertDeleteCertificateFromStore;
  15444. begin
  15445. GetProcedureAddress(_CertDeleteCertificateFromStore, crypt32, 'CertDeleteCertificateFromStore');
  15446. asm
  15447. MOV ESP, EBP
  15448. POP EBP
  15449. JMP [_CertDeleteCertificateFromStore]
  15450. end;
  15451. end;
  15452. var
  15453. _CertAddEncodedCRLToStore: Pointer;
  15454. function CertAddEncodedCRLToStore;
  15455. begin
  15456. GetProcedureAddress(_CertAddEncodedCRLToStore, crypt32, 'CertAddEncodedCRLToStore');
  15457. asm
  15458. MOV ESP, EBP
  15459. POP EBP
  15460. JMP [_CertAddEncodedCRLToStore]
  15461. end;
  15462. end;
  15463. var
  15464. _CertAddCRLContextToStore: Pointer;
  15465. function CertAddCRLContextToStore;
  15466. begin
  15467. GetProcedureAddress(_CertAddCRLContextToStore, crypt32, 'CertAddCRLContextToStore');
  15468. asm
  15469. MOV ESP, EBP
  15470. POP EBP
  15471. JMP [_CertAddCRLContextToStore]
  15472. end;
  15473. end;
  15474. var
  15475. _CertDeleteCRLFromStore: Pointer;
  15476. function CertDeleteCRLFromStore;
  15477. begin
  15478. GetProcedureAddress(_CertDeleteCRLFromStore, crypt32, 'CertDeleteCRLFromStore');
  15479. asm
  15480. MOV ESP, EBP
  15481. POP EBP
  15482. JMP [_CertDeleteCRLFromStore]
  15483. end;
  15484. end;
  15485. var
  15486. _CertSerializeCertStoreElement: Pointer;
  15487. function CertSerializeCertificateStoreElement;
  15488. begin
  15489. GetProcedureAddress(_CertSerializeCertStoreElement, crypt32, 'CertSerializeCertificateStoreElement');
  15490. asm
  15491. MOV ESP, EBP
  15492. POP EBP
  15493. JMP [_CertSerializeCertStoreElement]
  15494. end;
  15495. end;
  15496. var
  15497. _CertSerializeCRLStoreElement: Pointer;
  15498. function CertSerializeCRLStoreElement;
  15499. begin
  15500. GetProcedureAddress(_CertSerializeCRLStoreElement, crypt32, 'CertSerializeCRLStoreElement');
  15501. asm
  15502. MOV ESP, EBP
  15503. POP EBP
  15504. JMP [_CertSerializeCRLStoreElement]
  15505. end;
  15506. end;
  15507. var
  15508. _CertDuplicateCTLContext: Pointer;
  15509. function CertDuplicateCTLContext;
  15510. begin
  15511. GetProcedureAddress(_CertDuplicateCTLContext, crypt32, 'CertDuplicateCTLContext');
  15512. asm
  15513. MOV ESP, EBP
  15514. POP EBP
  15515. JMP [_CertDuplicateCTLContext]
  15516. end;
  15517. end;
  15518. var
  15519. _CertCreateCTLContext: Pointer;
  15520. function CertCreateCTLContext;
  15521. begin
  15522. GetProcedureAddress(_CertCreateCTLContext, crypt32, 'CertCreateCTLContext');
  15523. asm
  15524. MOV ESP, EBP
  15525. POP EBP
  15526. JMP [_CertCreateCTLContext]
  15527. end;
  15528. end;
  15529. var
  15530. _CertFreeCTLContext: Pointer;
  15531. function CertFreeCTLContext;
  15532. begin
  15533. GetProcedureAddress(_CertFreeCTLContext, crypt32, 'CertFreeCTLContext');
  15534. asm
  15535. MOV ESP, EBP
  15536. POP EBP
  15537. JMP [_CertFreeCTLContext]
  15538. end;
  15539. end;
  15540. var
  15541. _CertSetCTLContextProperty: Pointer;
  15542. function CertSetCTLContextProperty;
  15543. begin
  15544. GetProcedureAddress(_CertSetCTLContextProperty, crypt32, 'CertSetCTLContextProperty');
  15545. asm
  15546. MOV ESP, EBP
  15547. POP EBP
  15548. JMP [_CertSetCTLContextProperty]
  15549. end;
  15550. end;
  15551. var
  15552. _CertGetCTLContextProperty: Pointer;
  15553. function CertGetCTLContextProperty;
  15554. begin
  15555. GetProcedureAddress(_CertGetCTLContextProperty, crypt32, 'CertGetCTLContextProperty');
  15556. asm
  15557. MOV ESP, EBP
  15558. POP EBP
  15559. JMP [_CertGetCTLContextProperty]
  15560. end;
  15561. end;
  15562. var
  15563. _CertEnumCTLContextProperties: Pointer;
  15564. function CertEnumCTLContextProperties;
  15565. begin
  15566. GetProcedureAddress(_CertEnumCTLContextProperties, crypt32, 'CertEnumCTLContextProperties');
  15567. asm
  15568. MOV ESP, EBP
  15569. POP EBP
  15570. JMP [_CertEnumCTLContextProperties]
  15571. end;
  15572. end;
  15573. var
  15574. _CertEnumCTLsInStore: Pointer;
  15575. function CertEnumCTLsInStore;
  15576. begin
  15577. GetProcedureAddress(_CertEnumCTLsInStore, crypt32, 'CertEnumCTLsInStore');
  15578. asm
  15579. MOV ESP, EBP
  15580. POP EBP
  15581. JMP [_CertEnumCTLsInStore]
  15582. end;
  15583. end;
  15584. var
  15585. _CertFindSubjectInCTL: Pointer;
  15586. function CertFindSubjectInCTL;
  15587. begin
  15588. GetProcedureAddress(_CertFindSubjectInCTL, crypt32, 'CertFindSubjectInCTL');
  15589. asm
  15590. MOV ESP, EBP
  15591. POP EBP
  15592. JMP [_CertFindSubjectInCTL]
  15593. end;
  15594. end;
  15595. var
  15596. _CertFindCTLInStore: Pointer;
  15597. function CertFindCTLInStore;
  15598. begin
  15599. GetProcedureAddress(_CertFindCTLInStore, crypt32, 'CertFindCTLInStore');
  15600. asm
  15601. MOV ESP, EBP
  15602. POP EBP
  15603. JMP [_CertFindCTLInStore]
  15604. end;
  15605. end;
  15606. var
  15607. _CertAddEncodedCTLToStore: Pointer;
  15608. function CertAddEncodedCTLToStore;
  15609. begin
  15610. GetProcedureAddress(_CertAddEncodedCTLToStore, crypt32, 'CertAddEncodedCTLToStore');
  15611. asm
  15612. MOV ESP, EBP
  15613. POP EBP
  15614. JMP [_CertAddEncodedCTLToStore]
  15615. end;
  15616. end;
  15617. var
  15618. _CertAddCTLContextToStore: Pointer;
  15619. function CertAddCTLContextToStore;
  15620. begin
  15621. GetProcedureAddress(_CertAddCTLContextToStore, crypt32, 'CertAddCTLContextToStore');
  15622. asm
  15623. MOV ESP, EBP
  15624. POP EBP
  15625. JMP [_CertAddCTLContextToStore]
  15626. end;
  15627. end;
  15628. var
  15629. _CertSerializeCTLStoreElement: Pointer;
  15630. function CertSerializeCTLStoreElement;
  15631. begin
  15632. GetProcedureAddress(_CertSerializeCTLStoreElement, crypt32, 'CertSerializeCTLStoreElement');
  15633. asm
  15634. MOV ESP, EBP
  15635. POP EBP
  15636. JMP [_CertSerializeCTLStoreElement]
  15637. end;
  15638. end;
  15639. var
  15640. _CertDeleteCTLFromStore: Pointer;
  15641. function CertDeleteCTLFromStore;
  15642. begin
  15643. GetProcedureAddress(_CertDeleteCTLFromStore, crypt32, 'CertDeleteCTLFromStore');
  15644. asm
  15645. MOV ESP, EBP
  15646. POP EBP
  15647. JMP [_CertDeleteCTLFromStore]
  15648. end;
  15649. end;
  15650. var
  15651. _CertAddCertificateLinkToStore: Pointer;
  15652. function CertAddCertificateLinkToStore;
  15653. begin
  15654. GetProcedureAddress(_CertAddCertificateLinkToStore, crypt32, 'CertAddCertificateLinkToStore');
  15655. asm
  15656. MOV ESP, EBP
  15657. POP EBP
  15658. JMP [_CertAddCertificateLinkToStore]
  15659. end;
  15660. end;
  15661. var
  15662. _CertAddCRLLinkToStore: Pointer;
  15663. function CertAddCRLLinkToStore;
  15664. begin
  15665. GetProcedureAddress(_CertAddCRLLinkToStore, crypt32, 'CertAddCRLLinkToStore');
  15666. asm
  15667. MOV ESP, EBP
  15668. POP EBP
  15669. JMP [_CertAddCRLLinkToStore]
  15670. end;
  15671. end;
  15672. var
  15673. _CertAddCTLLinkToStore: Pointer;
  15674. function CertAddCTLLinkToStore;
  15675. begin
  15676. GetProcedureAddress(_CertAddCTLLinkToStore, crypt32, 'CertAddCTLLinkToStore');
  15677. asm
  15678. MOV ESP, EBP
  15679. POP EBP
  15680. JMP [_CertAddCTLLinkToStore]
  15681. end;
  15682. end;
  15683. var
  15684. _CertAddStoreToCollection: Pointer;
  15685. function CertAddStoreToCollection;
  15686. begin
  15687. GetProcedureAddress(_CertAddStoreToCollection, crypt32, 'CertAddStoreToCollection');
  15688. asm
  15689. MOV ESP, EBP
  15690. POP EBP
  15691. JMP [_CertAddStoreToCollection]
  15692. end;
  15693. end;
  15694. var
  15695. _CertRemoveStoreFromCollection: Pointer;
  15696. procedure CertRemoveStoreFromCollection;
  15697. begin
  15698. GetProcedureAddress(_CertRemoveStoreFromCollection, crypt32, 'CertRemoveStoreFromCollection');
  15699. asm
  15700. MOV ESP, EBP
  15701. POP EBP
  15702. JMP [_CertRemoveStoreFromCollection]
  15703. end;
  15704. end;
  15705. var
  15706. _CertControlStore: Pointer;
  15707. function CertControlStore;
  15708. begin
  15709. GetProcedureAddress(_CertControlStore, crypt32, 'CertControlStore');
  15710. asm
  15711. MOV ESP, EBP
  15712. POP EBP
  15713. JMP [_CertControlStore]
  15714. end;
  15715. end;
  15716. var
  15717. _CertSetStoreProperty: Pointer;
  15718. function CertSetStoreProperty;
  15719. begin
  15720. GetProcedureAddress(_CertSetStoreProperty, crypt32, 'CertSetStoreProperty');
  15721. asm
  15722. MOV ESP, EBP
  15723. POP EBP
  15724. JMP [_CertSetStoreProperty]
  15725. end;
  15726. end;
  15727. var
  15728. _CertGetStoreProperty: Pointer;
  15729. function CertGetStoreProperty;
  15730. begin
  15731. GetProcedureAddress(_CertGetStoreProperty, crypt32, 'CertGetStoreProperty');
  15732. asm
  15733. MOV ESP, EBP
  15734. POP EBP
  15735. JMP [_CertGetStoreProperty]
  15736. end;
  15737. end;
  15738. var
  15739. _CertCreateContext: Pointer;
  15740. function CertCreateContext;
  15741. begin
  15742. GetProcedureAddress(_CertCreateContext, crypt32, 'CertCreateContext');
  15743. asm
  15744. MOV ESP, EBP
  15745. POP EBP
  15746. JMP [_CertCreateContext]
  15747. end;
  15748. end;
  15749. var
  15750. _CertRegisterSystemStore: Pointer;
  15751. function CertRegisterSystemStore;
  15752. begin
  15753. GetProcedureAddress(_CertRegisterSystemStore, crypt32, 'CertRegisterSystemStore');
  15754. asm
  15755. MOV ESP, EBP
  15756. POP EBP
  15757. JMP [_CertRegisterSystemStore]
  15758. end;
  15759. end;
  15760. var
  15761. _CertRegisterPhysicalStore: Pointer;
  15762. function CertRegisterPhysicalStore;
  15763. begin
  15764. GetProcedureAddress(_CertRegisterPhysicalStore, crypt32, 'CertRegisterPhysicalStore');
  15765. asm
  15766. MOV ESP, EBP
  15767. POP EBP
  15768. JMP [_CertRegisterPhysicalStore]
  15769. end;
  15770. end;
  15771. var
  15772. _CertUnregisterSystemStore: Pointer;
  15773. function CertUnregisterSystemStore;
  15774. begin
  15775. GetProcedureAddress(_CertUnregisterSystemStore, crypt32, 'CertUnregisterSystemStore');
  15776. asm
  15777. MOV ESP, EBP
  15778. POP EBP
  15779. JMP [_CertUnregisterSystemStore]
  15780. end;
  15781. end;
  15782. var
  15783. _CertUnregisterPhysicalStore: Pointer;
  15784. function CertUnregisterPhysicalStore;
  15785. begin
  15786. GetProcedureAddress(_CertUnregisterPhysicalStore, crypt32, 'CertUnregisterPhysicalStore');
  15787. asm
  15788. MOV ESP, EBP
  15789. POP EBP
  15790. JMP [_CertUnregisterPhysicalStore]
  15791. end;
  15792. end;
  15793. var
  15794. _CertEnumSystemStoreLocation: Pointer;
  15795. function CertEnumSystemStoreLocation;
  15796. begin
  15797. GetProcedureAddress(_CertEnumSystemStoreLocation, crypt32, 'CertEnumSystemStoreLocation');
  15798. asm
  15799. MOV ESP, EBP
  15800. POP EBP
  15801. JMP [_CertEnumSystemStoreLocation]
  15802. end;
  15803. end;
  15804. var
  15805. _CertEnumSystemStore: Pointer;
  15806. function CertEnumSystemStore;
  15807. begin
  15808. GetProcedureAddress(_CertEnumSystemStore, crypt32, 'CertEnumSystemStore');
  15809. asm
  15810. MOV ESP, EBP
  15811. POP EBP
  15812. JMP [_CertEnumSystemStore]
  15813. end;
  15814. end;
  15815. var
  15816. _CertEnumPhysicalStore: Pointer;
  15817. function CertEnumPhysicalStore;
  15818. begin
  15819. GetProcedureAddress(_CertEnumPhysicalStore, crypt32, 'CertEnumPhysicalStore');
  15820. asm
  15821. MOV ESP, EBP
  15822. POP EBP
  15823. JMP [_CertEnumPhysicalStore]
  15824. end;
  15825. end;
  15826. var
  15827. _CertGetEnhancedKeyUsage: Pointer;
  15828. function CertGetEnhancedKeyUsage;
  15829. begin
  15830. GetProcedureAddress(_CertGetEnhancedKeyUsage, crypt32, 'CertGetEnhancedKeyUsage');
  15831. asm
  15832. MOV ESP, EBP
  15833. POP EBP
  15834. JMP [_CertGetEnhancedKeyUsage]
  15835. end;
  15836. end;
  15837. var
  15838. _CertSetEnhancedKeyUsage: Pointer;
  15839. function CertSetEnhancedKeyUsage;
  15840. begin
  15841. GetProcedureAddress(_CertSetEnhancedKeyUsage, crypt32, 'CertSetEnhancedKeyUsage');
  15842. asm
  15843. MOV ESP, EBP
  15844. POP EBP
  15845. JMP [_CertSetEnhancedKeyUsage]
  15846. end;
  15847. end;
  15848. var
  15849. _CertAddEnhKeyUsageIdentifier: Pointer;
  15850. function CertAddEnhancedKeyUsageIdentifier;
  15851. begin
  15852. GetProcedureAddress(_CertAddEnhKeyUsageIdentifier, crypt32, 'CertAddEnhancedKeyUsageIdentifier');
  15853. asm
  15854. MOV ESP, EBP
  15855. POP EBP
  15856. JMP [_CertAddEnhKeyUsageIdentifier]
  15857. end;
  15858. end;
  15859. var
  15860. _CertRemoveEnhKeyUsageIdent: Pointer;
  15861. function CertRemoveEnhancedKeyUsageIdentifier;
  15862. begin
  15863. GetProcedureAddress(_CertRemoveEnhKeyUsageIdent, crypt32, 'CertRemoveEnhancedKeyUsageIdentifier');
  15864. asm
  15865. MOV ESP, EBP
  15866. POP EBP
  15867. JMP [_CertRemoveEnhKeyUsageIdent]
  15868. end;
  15869. end;
  15870. var
  15871. _CertGetValidUsages: Pointer;
  15872. function CertGetValidUsages;
  15873. begin
  15874. GetProcedureAddress(_CertGetValidUsages, crypt32, 'CertGetValidUsages');
  15875. asm
  15876. MOV ESP, EBP
  15877. POP EBP
  15878. JMP [_CertGetValidUsages]
  15879. end;
  15880. end;
  15881. var
  15882. _CryptMsgGetAndVerifySigner: Pointer;
  15883. function CryptMsgGetAndVerifySigner;
  15884. begin
  15885. GetProcedureAddress(_CryptMsgGetAndVerifySigner, crypt32, 'CryptMsgGetAndVerifySigner');
  15886. asm
  15887. MOV ESP, EBP
  15888. POP EBP
  15889. JMP [_CryptMsgGetAndVerifySigner]
  15890. end;
  15891. end;
  15892. var
  15893. _CryptMsgSignCTL: Pointer;
  15894. function CryptMsgSignCTL;
  15895. begin
  15896. GetProcedureAddress(_CryptMsgSignCTL, crypt32, 'CryptMsgSignCTL');
  15897. asm
  15898. MOV ESP, EBP
  15899. POP EBP
  15900. JMP [_CryptMsgSignCTL]
  15901. end;
  15902. end;
  15903. var
  15904. _CryptMsgEncodeAndSignCTL: Pointer;
  15905. function CryptMsgEncodeAndSignCTL;
  15906. begin
  15907. GetProcedureAddress(_CryptMsgEncodeAndSignCTL, crypt32, 'CryptMsgEncodeAndSignCTL');
  15908. asm
  15909. MOV ESP, EBP
  15910. POP EBP
  15911. JMP [_CryptMsgEncodeAndSignCTL]
  15912. end;
  15913. end;
  15914. var
  15915. _CertFindSubjectInSortedCTL: Pointer;
  15916. function CertFindSubjectInSortedCTL;
  15917. begin
  15918. GetProcedureAddress(_CertFindSubjectInSortedCTL, crypt32, 'CertFindSubjectInSortedCTL');
  15919. asm
  15920. MOV ESP, EBP
  15921. POP EBP
  15922. JMP [_CertFindSubjectInSortedCTL]
  15923. end;
  15924. end;
  15925. var
  15926. _CertEnumSubjectInSortedCTL: Pointer;
  15927. function CertEnumSubjectInSortedCTL;
  15928. begin
  15929. GetProcedureAddress(_CertEnumSubjectInSortedCTL, crypt32, 'CertEnumSubjectInSortedCTL');
  15930. asm
  15931. MOV ESP, EBP
  15932. POP EBP
  15933. JMP [_CertEnumSubjectInSortedCTL]
  15934. end;
  15935. end;
  15936. var
  15937. _CertVerifyCTLUsage: Pointer;
  15938. function CertVerifyCTLUsage;
  15939. begin
  15940. GetProcedureAddress(_CertVerifyCTLUsage, crypt32, 'CertVerifyCTLUsage');
  15941. asm
  15942. MOV ESP, EBP
  15943. POP EBP
  15944. JMP [_CertVerifyCTLUsage]
  15945. end;
  15946. end;
  15947. var
  15948. _CertVerifyRevocation: Pointer;
  15949. function CertVerifyRevocation;
  15950. begin
  15951. GetProcedureAddress(_CertVerifyRevocation, crypt32, 'CertVerifyRevocation');
  15952. asm
  15953. MOV ESP, EBP
  15954. POP EBP
  15955. JMP [_CertVerifyRevocation]
  15956. end;
  15957. end;
  15958. var
  15959. _CertCompareIntegerBlob: Pointer;
  15960. function CertCompareIntegerBlob;
  15961. begin
  15962. GetProcedureAddress(_CertCompareIntegerBlob, crypt32, 'CertCompareIntegerBlob');
  15963. asm
  15964. MOV ESP, EBP
  15965. POP EBP
  15966. JMP [_CertCompareIntegerBlob]
  15967. end;
  15968. end;
  15969. var
  15970. _CertCompareCertificate: Pointer;
  15971. function CertCompareCertificate;
  15972. begin
  15973. GetProcedureAddress(_CertCompareCertificate, crypt32, 'CertCompareCertificate');
  15974. asm
  15975. MOV ESP, EBP
  15976. POP EBP
  15977. JMP [_CertCompareCertificate]
  15978. end;
  15979. end;
  15980. var
  15981. _CertCompareCertificateName: Pointer;
  15982. function CertCompareCertificateName;
  15983. begin
  15984. GetProcedureAddress(_CertCompareCertificateName, crypt32, 'CertCompareCertificateName');
  15985. asm
  15986. MOV ESP, EBP
  15987. POP EBP
  15988. JMP [_CertCompareCertificateName]
  15989. end;
  15990. end;
  15991. var
  15992. _CertIsRDNAttrsInCertificateName: Pointer;
  15993. function CertIsRDNAttrsInCertificateName;
  15994. begin
  15995. GetProcedureAddress(_CertIsRDNAttrsInCertificateName, crypt32, 'CertIsRDNAttrsInCertificateName');
  15996. asm
  15997. MOV ESP, EBP
  15998. POP EBP
  15999. JMP [_CertIsRDNAttrsInCertificateName]
  16000. end;
  16001. end;
  16002. var
  16003. _CertComparePublicKeyInfo: Pointer;
  16004. function CertComparePublicKeyInfo;
  16005. begin
  16006. GetProcedureAddress(_CertComparePublicKeyInfo, crypt32, 'CertComparePublicKeyInfo');
  16007. asm
  16008. MOV ESP, EBP
  16009. POP EBP
  16010. JMP [_CertComparePublicKeyInfo]
  16011. end;
  16012. end;
  16013. var
  16014. _CertGetPublicKeyLength: Pointer;
  16015. function CertGetPublicKeyLength;
  16016. begin
  16017. GetProcedureAddress(_CertGetPublicKeyLength, crypt32, 'CertGetPublicKeyLength');
  16018. asm
  16019. MOV ESP, EBP
  16020. POP EBP
  16021. JMP [_CertGetPublicKeyLength]
  16022. end;
  16023. end;
  16024. var
  16025. _CryptVerifyCertificateSignature: Pointer;
  16026. function CryptVerifyCertificateSignature;
  16027. begin
  16028. GetProcedureAddress(_CryptVerifyCertificateSignature, crypt32, 'CryptVerifyCertificateSignature');
  16029. asm
  16030. MOV ESP, EBP
  16031. POP EBP
  16032. JMP [_CryptVerifyCertificateSignature]
  16033. end;
  16034. end;
  16035. var
  16036. _CryptVerifyCertSignatureEx: Pointer;
  16037. function CryptVerifyCertificateSignatureEx;
  16038. begin
  16039. GetProcedureAddress(_CryptVerifyCertSignatureEx, crypt32, 'CryptVerifyCertificateSignatureEx');
  16040. asm
  16041. MOV ESP, EBP
  16042. POP EBP
  16043. JMP [_CryptVerifyCertSignatureEx]
  16044. end;
  16045. end;
  16046. var
  16047. _CryptHashToBeSigned: Pointer;
  16048. function CryptHashToBeSigned;
  16049. begin
  16050. GetProcedureAddress(_CryptHashToBeSigned, crypt32, 'CryptHashToBeSigned');
  16051. asm
  16052. MOV ESP, EBP
  16053. POP EBP
  16054. JMP [_CryptHashToBeSigned]
  16055. end;
  16056. end;
  16057. var
  16058. _CryptHashCertificate: Pointer;
  16059. function CryptHashCertificate;
  16060. begin
  16061. GetProcedureAddress(_CryptHashCertificate, crypt32, 'CryptHashCertificate');
  16062. asm
  16063. MOV ESP, EBP
  16064. POP EBP
  16065. JMP [_CryptHashCertificate]
  16066. end;
  16067. end;
  16068. var
  16069. _CryptSignCertificate: Pointer;
  16070. function CryptSignCertificate;
  16071. begin
  16072. GetProcedureAddress(_CryptSignCertificate, crypt32, 'CryptSignCertificate');
  16073. asm
  16074. MOV ESP, EBP
  16075. POP EBP
  16076. JMP [_CryptSignCertificate]
  16077. end;
  16078. end;
  16079. var
  16080. _CryptSignAndEncodeCertificate: Pointer;
  16081. function CryptSignAndEncodeCertificate;
  16082. begin
  16083. GetProcedureAddress(_CryptSignAndEncodeCertificate, crypt32, 'CryptSignAndEncodeCertificate');
  16084. asm
  16085. MOV ESP, EBP
  16086. POP EBP
  16087. JMP [_CryptSignAndEncodeCertificate]
  16088. end;
  16089. end;
  16090. var
  16091. _CertVerifyTimeValidity: Pointer;
  16092. function CertVerifyTimeValidity;
  16093. begin
  16094. GetProcedureAddress(_CertVerifyTimeValidity, crypt32, 'CertVerifyTimeValidity');
  16095. asm
  16096. MOV ESP, EBP
  16097. POP EBP
  16098. JMP [_CertVerifyTimeValidity]
  16099. end;
  16100. end;
  16101. var
  16102. _CertVerifyCRLTimeValidity: Pointer;
  16103. function CertVerifyCRLTimeValidity;
  16104. begin
  16105. GetProcedureAddress(_CertVerifyCRLTimeValidity, crypt32, 'CertVerifyCRLTimeValidity');
  16106. asm
  16107. MOV ESP, EBP
  16108. POP EBP
  16109. JMP [_CertVerifyCRLTimeValidity]
  16110. end;
  16111. end;
  16112. var
  16113. _CertVerifyValidityNesting: Pointer;
  16114. function CertVerifyValidityNesting;
  16115. begin
  16116. GetProcedureAddress(_CertVerifyValidityNesting, crypt32, 'CertVerifyValidityNesting');
  16117. asm
  16118. MOV ESP, EBP
  16119. POP EBP
  16120. JMP [_CertVerifyValidityNesting]
  16121. end;
  16122. end;
  16123. var
  16124. _CertVerifyCRLRevocation: Pointer;
  16125. function CertVerifyCRLRevocation;
  16126. begin
  16127. GetProcedureAddress(_CertVerifyCRLRevocation, crypt32, 'CertVerifyCRLRevocation');
  16128. asm
  16129. MOV ESP, EBP
  16130. POP EBP
  16131. JMP [_CertVerifyCRLRevocation]
  16132. end;
  16133. end;
  16134. var
  16135. _CertAlgIdToOID: Pointer;
  16136. function CertAlgIdToOID;
  16137. begin
  16138. GetProcedureAddress(_CertAlgIdToOID, crypt32, 'CertAlgIdToOID');
  16139. asm
  16140. MOV ESP, EBP
  16141. POP EBP
  16142. JMP [_CertAlgIdToOID]
  16143. end;
  16144. end;
  16145. var
  16146. _CertOIDToAlgId: Pointer;
  16147. function CertOIDToAlgId;
  16148. begin
  16149. GetProcedureAddress(_CertOIDToAlgId, crypt32, 'CertOIDToAlgId');
  16150. asm
  16151. MOV ESP, EBP
  16152. POP EBP
  16153. JMP [_CertOIDToAlgId]
  16154. end;
  16155. end;
  16156. var
  16157. _CertFindExtension: Pointer;
  16158. function CertFindExtension;
  16159. begin
  16160. GetProcedureAddress(_CertFindExtension, crypt32, 'CertFindExtension');
  16161. asm
  16162. MOV ESP, EBP
  16163. POP EBP
  16164. JMP [_CertFindExtension]
  16165. end;
  16166. end;
  16167. var
  16168. _CertFindAttribute: Pointer;
  16169. function CertFindAttribute;
  16170. begin
  16171. GetProcedureAddress(_CertFindAttribute, crypt32, 'CertFindAttribute');
  16172. asm
  16173. MOV ESP, EBP
  16174. POP EBP
  16175. JMP [_CertFindAttribute]
  16176. end;
  16177. end;
  16178. var
  16179. _CertFindRDNAttr: Pointer;
  16180. function CertFindRDNAttr;
  16181. begin
  16182. GetProcedureAddress(_CertFindRDNAttr, crypt32, 'CertFindRDNAttr');
  16183. asm
  16184. MOV ESP, EBP
  16185. POP EBP
  16186. JMP [_CertFindRDNAttr]
  16187. end;
  16188. end;
  16189. var
  16190. _CertGetIntendedKeyUsage: Pointer;
  16191. function CertGetIntendedKeyUsage;
  16192. begin
  16193. GetProcedureAddress(_CertGetIntendedKeyUsage, crypt32, 'CertGetIntendedKeyUsage');
  16194. asm
  16195. MOV ESP, EBP
  16196. POP EBP
  16197. JMP [_CertGetIntendedKeyUsage]
  16198. end;
  16199. end;
  16200. var
  16201. _CryptInstallDefaultContext: Pointer;
  16202. function CryptInstallDefaultContext;
  16203. begin
  16204. GetProcedureAddress(_CryptInstallDefaultContext, crypt32, 'CryptInstallDefaultContext');
  16205. asm
  16206. MOV ESP, EBP
  16207. POP EBP
  16208. JMP [_CryptInstallDefaultContext]
  16209. end;
  16210. end;
  16211. var
  16212. _CryptUninstallDefaultContext: Pointer;
  16213. function CryptUninstallDefaultContext;
  16214. begin
  16215. GetProcedureAddress(_CryptUninstallDefaultContext, crypt32, 'CryptUninstallDefaultContext');
  16216. asm
  16217. MOV ESP, EBP
  16218. POP EBP
  16219. JMP [_CryptUninstallDefaultContext]
  16220. end;
  16221. end;
  16222. var
  16223. _CryptExportPublicKeyInfo: Pointer;
  16224. function CryptExportPublicKeyInfo;
  16225. begin
  16226. GetProcedureAddress(_CryptExportPublicKeyInfo, crypt32, 'CryptExportPublicKeyInfo');
  16227. asm
  16228. MOV ESP, EBP
  16229. POP EBP
  16230. JMP [_CryptExportPublicKeyInfo]
  16231. end;
  16232. end;
  16233. var
  16234. _CryptExportPublicKeyInfoEx: Pointer;
  16235. function CryptExportPublicKeyInfoEx;
  16236. begin
  16237. GetProcedureAddress(_CryptExportPublicKeyInfoEx, crypt32, 'CryptExportPublicKeyInfoEx');
  16238. asm
  16239. MOV ESP, EBP
  16240. POP EBP
  16241. JMP [_CryptExportPublicKeyInfoEx]
  16242. end;
  16243. end;
  16244. var
  16245. _CryptImportPublicKeyInfo: Pointer;
  16246. function CryptImportPublicKeyInfo;
  16247. begin
  16248. GetProcedureAddress(_CryptImportPublicKeyInfo, crypt32, 'CryptImportPublicKeyInfo');
  16249. asm
  16250. MOV ESP, EBP
  16251. POP EBP
  16252. JMP [_CryptImportPublicKeyInfo]
  16253. end;
  16254. end;
  16255. var
  16256. _CryptImportPublicKeyInfoEx: Pointer;
  16257. function CryptImportPublicKeyInfoEx;
  16258. begin
  16259. GetProcedureAddress(_CryptImportPublicKeyInfoEx, crypt32, 'CryptImportPublicKeyInfoEx');
  16260. asm
  16261. MOV ESP, EBP
  16262. POP EBP
  16263. JMP [_CryptImportPublicKeyInfoEx]
  16264. end;
  16265. end;
  16266. var
  16267. _CryptAcquireCertPrivateKey: Pointer;
  16268. function CryptAcquireCertificatePrivateKey;
  16269. begin
  16270. GetProcedureAddress(_CryptAcquireCertPrivateKey, crypt32, 'CryptAcquireCertificatePrivateKey');
  16271. asm
  16272. MOV ESP, EBP
  16273. POP EBP
  16274. JMP [_CryptAcquireCertPrivateKey]
  16275. end;
  16276. end;
  16277. var
  16278. _CryptFindCertificateKeyProvInfo: Pointer;
  16279. function CryptFindCertificateKeyProvInfo;
  16280. begin
  16281. GetProcedureAddress(_CryptFindCertificateKeyProvInfo, crypt32, 'CryptFindCertificateKeyProvInfo');
  16282. asm
  16283. MOV ESP, EBP
  16284. POP EBP
  16285. JMP [_CryptFindCertificateKeyProvInfo]
  16286. end;
  16287. end;
  16288. var
  16289. _CryptImportPKCS8: Pointer;
  16290. function CryptImportPKCS8;
  16291. begin
  16292. GetProcedureAddress(_CryptImportPKCS8, crypt32, 'CryptImportPKCS8');
  16293. asm
  16294. MOV ESP, EBP
  16295. POP EBP
  16296. JMP [_CryptImportPKCS8]
  16297. end;
  16298. end;
  16299. var
  16300. _CryptExportPKCS8: Pointer;
  16301. function CryptExportPKCS8;
  16302. begin
  16303. GetProcedureAddress(_CryptExportPKCS8, crypt32, 'CryptExportPKCS8');
  16304. asm
  16305. MOV ESP, EBP
  16306. POP EBP
  16307. JMP [_CryptExportPKCS8]
  16308. end;
  16309. end;
  16310. var
  16311. _CryptExportPKCS8Ex: Pointer;
  16312. function CryptExportPKCS8Ex;
  16313. begin
  16314. GetProcedureAddress(_CryptExportPKCS8Ex, crypt32, 'CryptExportPKCS8Ex');
  16315. asm
  16316. MOV ESP, EBP
  16317. POP EBP
  16318. JMP [_CryptExportPKCS8Ex]
  16319. end;
  16320. end;
  16321. var
  16322. _CryptHashPublicKeyInfo: Pointer;
  16323. function CryptHashPublicKeyInfo;
  16324. begin
  16325. GetProcedureAddress(_CryptHashPublicKeyInfo, crypt32, 'CryptHashPublicKeyInfo');
  16326. asm
  16327. MOV ESP, EBP
  16328. POP EBP
  16329. JMP [_CryptHashPublicKeyInfo]
  16330. end;
  16331. end;
  16332. var
  16333. _CertRDNValueToStrA: Pointer;
  16334. function CertRDNValueToStrA;
  16335. begin
  16336. GetProcedureAddress(_CertRDNValueToStrA, crypt32, 'CertRDNValueToStrA');
  16337. asm
  16338. MOV ESP, EBP
  16339. POP EBP
  16340. JMP [_CertRDNValueToStrA]
  16341. end;
  16342. end;
  16343. var
  16344. _CertRDNValueToStrW: Pointer;
  16345. function CertRDNValueToStrW;
  16346. begin
  16347. GetProcedureAddress(_CertRDNValueToStrW, crypt32, 'CertRDNValueToStrW');
  16348. asm
  16349. MOV ESP, EBP
  16350. POP EBP
  16351. JMP [_CertRDNValueToStrW]
  16352. end;
  16353. end;
  16354. var
  16355. _CertRDNValueToStr: Pointer;
  16356. function CertRDNValueToStr;
  16357. begin
  16358. GetProcedureAddress(_CertRDNValueToStr, crypt32, 'CertRDNValueToStr' + AWSuffix);
  16359. asm
  16360. MOV ESP, EBP
  16361. POP EBP
  16362. JMP [_CertRDNValueToStr]
  16363. end;
  16364. end;
  16365. var
  16366. _CertNameToStrA: Pointer;
  16367. function CertNameToStrA;
  16368. begin
  16369. GetProcedureAddress(_CertNameToStrA, crypt32, 'CertNameToStrA');
  16370. asm
  16371. MOV ESP, EBP
  16372. POP EBP
  16373. JMP [_CertNameToStrA]
  16374. end;
  16375. end;
  16376. var
  16377. _CertNameToStrW: Pointer;
  16378. function CertNameToStrW;
  16379. begin
  16380. GetProcedureAddress(_CertNameToStrW, crypt32, 'CertNameToStrW');
  16381. asm
  16382. MOV ESP, EBP
  16383. POP EBP
  16384. JMP [_CertNameToStrW]
  16385. end;
  16386. end;
  16387. var
  16388. _CertNameToStr: Pointer;
  16389. function CertNameToStr;
  16390. begin
  16391. GetProcedureAddress(_CertNameToStr, crypt32, 'CertNameToStr' + AWSuffix);
  16392. asm
  16393. MOV ESP, EBP
  16394. POP EBP
  16395. JMP [_CertNameToStr]
  16396. end;
  16397. end;
  16398. var
  16399. _CertStrToNameA: Pointer;
  16400. function CertStrToNameA;
  16401. begin
  16402. GetProcedureAddress(_CertStrToNameA, crypt32, 'CertStrToNameA');
  16403. asm
  16404. MOV ESP, EBP
  16405. POP EBP
  16406. JMP [_CertStrToNameA]
  16407. end;
  16408. end;
  16409. var
  16410. _CertStrToNameW: Pointer;
  16411. function CertStrToNameW;
  16412. begin
  16413. GetProcedureAddress(_CertStrToNameW, crypt32, 'CertStrToNameW');
  16414. asm
  16415. MOV ESP, EBP
  16416. POP EBP
  16417. JMP [_CertStrToNameW]
  16418. end;
  16419. end;
  16420. var
  16421. _CertStrToName: Pointer;
  16422. function CertStrToName;
  16423. begin
  16424. GetProcedureAddress(_CertStrToName, crypt32, 'CertStrToName' + AWSuffix);
  16425. asm
  16426. MOV ESP, EBP
  16427. POP EBP
  16428. JMP [_CertStrToName]
  16429. end;
  16430. end;
  16431. var
  16432. _CertGetNameStringA: Pointer;
  16433. function CertGetNameStringA;
  16434. begin
  16435. GetProcedureAddress(_CertGetNameStringA, crypt32, 'CertGetNameStringA');
  16436. asm
  16437. MOV ESP, EBP
  16438. POP EBP
  16439. JMP [_CertGetNameStringA]
  16440. end;
  16441. end;
  16442. var
  16443. _CertGetNameStringW: Pointer;
  16444. function CertGetNameStringW;
  16445. begin
  16446. GetProcedureAddress(_CertGetNameStringW, crypt32, 'CertGetNameStringW');
  16447. asm
  16448. MOV ESP, EBP
  16449. POP EBP
  16450. JMP [_CertGetNameStringW]
  16451. end;
  16452. end;
  16453. var
  16454. _CertGetNameString: Pointer;
  16455. function CertGetNameString;
  16456. begin
  16457. GetProcedureAddress(_CertGetNameString, crypt32, 'CertGetNameString' + AWSuffix);
  16458. asm
  16459. MOV ESP, EBP
  16460. POP EBP
  16461. JMP [_CertGetNameString]
  16462. end;
  16463. end;
  16464. var
  16465. _CryptSignMessage: Pointer;
  16466. function CryptSignMessage;
  16467. begin
  16468. GetProcedureAddress(_CryptSignMessage, crypt32, 'CryptSignMessage');
  16469. asm
  16470. MOV ESP, EBP
  16471. POP EBP
  16472. JMP [_CryptSignMessage]
  16473. end;
  16474. end;
  16475. var
  16476. _CryptVerifyMessageSignature: Pointer;
  16477. function CryptVerifyMessageSignature;
  16478. begin
  16479. GetProcedureAddress(_CryptVerifyMessageSignature, crypt32, 'CryptVerifyMessageSignature');
  16480. asm
  16481. MOV ESP, EBP
  16482. POP EBP
  16483. JMP [_CryptVerifyMessageSignature]
  16484. end;
  16485. end;
  16486. var
  16487. _CryptGetMessageSignerCount: Pointer;
  16488. function CryptGetMessageSignerCount;
  16489. begin
  16490. GetProcedureAddress(_CryptGetMessageSignerCount, crypt32, 'CryptGetMessageSignerCount');
  16491. asm
  16492. MOV ESP, EBP
  16493. POP EBP
  16494. JMP [_CryptGetMessageSignerCount]
  16495. end;
  16496. end;
  16497. var
  16498. _CryptGetMessageCertificates: Pointer;
  16499. function CryptGetMessageCertificates;
  16500. begin
  16501. GetProcedureAddress(_CryptGetMessageCertificates, crypt32, 'CryptGetMessageCertificates');
  16502. asm
  16503. MOV ESP, EBP
  16504. POP EBP
  16505. JMP [_CryptGetMessageCertificates]
  16506. end;
  16507. end;
  16508. var
  16509. _CryptVerDetachedMsgSignature: Pointer;
  16510. function CryptVerifyDetachedMessageSignature;
  16511. begin
  16512. GetProcedureAddress(_CryptVerDetachedMsgSignature, crypt32, 'CryptVerifyDetachedMessageSignature');
  16513. asm
  16514. MOV ESP, EBP
  16515. POP EBP
  16516. JMP [_CryptVerDetachedMsgSignature]
  16517. end;
  16518. end;
  16519. var
  16520. _CryptEncryptMessage: Pointer;
  16521. function CryptEncryptMessage;
  16522. begin
  16523. GetProcedureAddress(_CryptEncryptMessage, crypt32, 'CryptEncryptMessage');
  16524. asm
  16525. MOV ESP, EBP
  16526. POP EBP
  16527. JMP [_CryptEncryptMessage]
  16528. end;
  16529. end;
  16530. var
  16531. _CryptDecryptMessage: Pointer;
  16532. function CryptDecryptMessage;
  16533. begin
  16534. GetProcedureAddress(_CryptDecryptMessage, crypt32, 'CryptDecryptMessage');
  16535. asm
  16536. MOV ESP, EBP
  16537. POP EBP
  16538. JMP [_CryptDecryptMessage]
  16539. end;
  16540. end;
  16541. var
  16542. _CryptSignAndEncryptMessage: Pointer;
  16543. function CryptSignAndEncryptMessage;
  16544. begin
  16545. GetProcedureAddress(_CryptSignAndEncryptMessage, crypt32, 'CryptSignAndEncryptMessage');
  16546. asm
  16547. MOV ESP, EBP
  16548. POP EBP
  16549. JMP [_CryptSignAndEncryptMessage]
  16550. end;
  16551. end;
  16552. var
  16553. _CryptDecryptAndVerMsgSig: Pointer;
  16554. function CryptDecryptAndVerifyMessageSignature;
  16555. begin
  16556. GetProcedureAddress(_CryptDecryptAndVerMsgSig, crypt32, 'CryptDecryptAndVerifyMessageSignature');
  16557. asm
  16558. MOV ESP, EBP
  16559. POP EBP
  16560. JMP [_CryptDecryptAndVerMsgSig]
  16561. end;
  16562. end;
  16563. var
  16564. _CryptDecodeMessage: Pointer;
  16565. function CryptDecodeMessage;
  16566. begin
  16567. GetProcedureAddress(_CryptDecodeMessage, crypt32, 'CryptDecodeMessage');
  16568. asm
  16569. MOV ESP, EBP
  16570. POP EBP
  16571. JMP [_CryptDecodeMessage]
  16572. end;
  16573. end;
  16574. var
  16575. _CryptHashMessage: Pointer;
  16576. function CryptHashMessage;
  16577. begin
  16578. GetProcedureAddress(_CryptHashMessage, crypt32, 'CryptHashMessage');
  16579. asm
  16580. MOV ESP, EBP
  16581. POP EBP
  16582. JMP [_CryptHashMessage]
  16583. end;
  16584. end;
  16585. var
  16586. _CryptVerifyMessageHash: Pointer;
  16587. function CryptVerifyMessageHash;
  16588. begin
  16589. GetProcedureAddress(_CryptVerifyMessageHash, crypt32, 'CryptVerifyMessageHash');
  16590. asm
  16591. MOV ESP, EBP
  16592. POP EBP
  16593. JMP [_CryptVerifyMessageHash]
  16594. end;
  16595. end;
  16596. var
  16597. _CryptVerifyDetachedMessageHash: Pointer;
  16598. function CryptVerifyDetachedMessageHash;
  16599. begin
  16600. GetProcedureAddress(_CryptVerifyDetachedMessageHash, crypt32, 'CryptVerifyDetachedMessageHash');
  16601. asm
  16602. MOV ESP, EBP
  16603. POP EBP
  16604. JMP [_CryptVerifyDetachedMessageHash]
  16605. end;
  16606. end;
  16607. var
  16608. _CryptSignMessageWithKey: Pointer;
  16609. function CryptSignMessageWithKey;
  16610. begin
  16611. GetProcedureAddress(_CryptSignMessageWithKey, crypt32, 'CryptSignMessageWithKey');
  16612. asm
  16613. MOV ESP, EBP
  16614. POP EBP
  16615. JMP [_CryptSignMessageWithKey]
  16616. end;
  16617. end;
  16618. var
  16619. _CryptVerifyMsgSigWithKey: Pointer;
  16620. function CryptVerifyMessageSignatureWithKey;
  16621. begin
  16622. GetProcedureAddress(_CryptVerifyMsgSigWithKey, crypt32, 'CryptVerifyMessageSignatureWithKey');
  16623. asm
  16624. MOV ESP, EBP
  16625. POP EBP
  16626. JMP [_CryptVerifyMsgSigWithKey]
  16627. end;
  16628. end;
  16629. var
  16630. _CertOpenSystemStoreA: Pointer;
  16631. function CertOpenSystemStoreA;
  16632. begin
  16633. GetProcedureAddress(_CertOpenSystemStoreA, crypt32, 'CertOpenSystemStoreA');
  16634. asm
  16635. MOV ESP, EBP
  16636. POP EBP
  16637. JMP [_CertOpenSystemStoreA]
  16638. end;
  16639. end;
  16640. var
  16641. _CertOpenSystemStoreW: Pointer;
  16642. function CertOpenSystemStoreW;
  16643. begin
  16644. GetProcedureAddress(_CertOpenSystemStoreW, crypt32, 'CertOpenSystemStoreW');
  16645. asm
  16646. MOV ESP, EBP
  16647. POP EBP
  16648. JMP [_CertOpenSystemStoreW]
  16649. end;
  16650. end;
  16651. var
  16652. _CertOpenSystemStore: Pointer;
  16653. function CertOpenSystemStore;
  16654. begin
  16655. GetProcedureAddress(_CertOpenSystemStore, crypt32, 'CertOpenSystemStore' + AWSuffix);
  16656. asm
  16657. MOV ESP, EBP
  16658. POP EBP
  16659. JMP [_CertOpenSystemStore]
  16660. end;
  16661. end;
  16662. var
  16663. _CertAddEncodedCertToSysStoreA: Pointer;
  16664. function CertAddEncodedCertificateToSystemStoreA;
  16665. begin
  16666. GetProcedureAddress(_CertAddEncodedCertToSysStoreA, crypt32, 'CertAddEncodedCertificateToSystemStoreA');
  16667. asm
  16668. MOV ESP, EBP
  16669. POP EBP
  16670. JMP [_CertAddEncodedCertToSysStoreA]
  16671. end;
  16672. end;
  16673. var
  16674. _CertAddEncodedCertToSysStoreW: Pointer;
  16675. function CertAddEncodedCertificateToSystemStoreW;
  16676. begin
  16677. GetProcedureAddress(_CertAddEncodedCertToSysStoreW, crypt32, 'CertAddEncodedCertificateToSystemStoreW');
  16678. asm
  16679. MOV ESP, EBP
  16680. POP EBP
  16681. JMP [_CertAddEncodedCertToSysStoreW]
  16682. end;
  16683. end;
  16684. var
  16685. _CertAddEncodedCertToSysStore: Pointer;
  16686. function CertAddEncodedCertificateToSystemStore;
  16687. begin
  16688. GetProcedureAddress(_CertAddEncodedCertToSysStore, crypt32, 'CertAddEncodedCertificateToSystemStore' + AWSuffix);
  16689. asm
  16690. MOV ESP, EBP
  16691. POP EBP
  16692. JMP [_CertAddEncodedCertToSysStore]
  16693. end;
  16694. end;
  16695. var
  16696. _FindCertsByIssuer: Pointer;
  16697. function FindCertsByIssuer;
  16698. begin
  16699. GetProcedureAddress(_FindCertsByIssuer, softpub, 'FindCertsByIssuer');
  16700. asm
  16701. MOV ESP, EBP
  16702. POP EBP
  16703. JMP [_FindCertsByIssuer]
  16704. end;
  16705. end;
  16706. var
  16707. _CryptQueryObject: Pointer;
  16708. function CryptQueryObject;
  16709. begin
  16710. GetProcedureAddress(_CryptQueryObject, crypt32, 'CryptQueryObject');
  16711. asm
  16712. MOV ESP, EBP
  16713. POP EBP
  16714. JMP [_CryptQueryObject]
  16715. end;
  16716. end;
  16717. var
  16718. _CryptMemAlloc: Pointer;
  16719. function CryptMemAlloc;
  16720. begin
  16721. GetProcedureAddress(_CryptMemAlloc, crypt32, 'CryptMemAlloc');
  16722. asm
  16723. MOV ESP, EBP
  16724. POP EBP
  16725. JMP [_CryptMemAlloc]
  16726. end;
  16727. end;
  16728. var
  16729. _CryptMemRealloc: Pointer;
  16730. function CryptMemRealloc;
  16731. begin
  16732. GetProcedureAddress(_CryptMemRealloc, crypt32, 'CryptMemRealloc');
  16733. asm
  16734. MOV ESP, EBP
  16735. POP EBP
  16736. JMP [_CryptMemRealloc]
  16737. end;
  16738. end;
  16739. var
  16740. _CryptMemFree: Pointer;
  16741. procedure CryptMemFree;
  16742. begin
  16743. GetProcedureAddress(_CryptMemFree, crypt32, 'CryptMemFree');
  16744. asm
  16745. MOV ESP, EBP
  16746. POP EBP
  16747. JMP [_CryptMemFree]
  16748. end;
  16749. end;
  16750. var
  16751. _CryptCreateAsyncHandle: Pointer;
  16752. function CryptCreateAsyncHandle;
  16753. begin
  16754. GetProcedureAddress(_CryptCreateAsyncHandle, crypt32, 'CryptCreateAsyncHandle');
  16755. asm
  16756. MOV ESP, EBP
  16757. POP EBP
  16758. JMP [_CryptCreateAsyncHandle]
  16759. end;
  16760. end;
  16761. var
  16762. _CryptSetAsyncParam: Pointer;
  16763. function CryptSetAsyncParam;
  16764. begin
  16765. GetProcedureAddress(_CryptSetAsyncParam, crypt32, 'CryptSetAsyncParam');
  16766. asm
  16767. MOV ESP, EBP
  16768. POP EBP
  16769. JMP [_CryptSetAsyncParam]
  16770. end;
  16771. end;
  16772. var
  16773. _CryptGetAsyncParam: Pointer;
  16774. function CryptGetAsyncParam;
  16775. begin
  16776. GetProcedureAddress(_CryptGetAsyncParam, crypt32, 'CryptGetAsyncParam');
  16777. asm
  16778. MOV ESP, EBP
  16779. POP EBP
  16780. JMP [_CryptGetAsyncParam]
  16781. end;
  16782. end;
  16783. var
  16784. _CryptCloseAsyncHandle: Pointer;
  16785. function CryptCloseAsyncHandle;
  16786. begin
  16787. GetProcedureAddress(_CryptCloseAsyncHandle, crypt32, 'CryptCloseAsyncHandle');
  16788. asm
  16789. MOV ESP, EBP
  16790. POP EBP
  16791. JMP [_CryptCloseAsyncHandle]
  16792. end;
  16793. end;
  16794. var
  16795. _CryptRetrieveObjectByUrlA: Pointer;
  16796. function CryptRetrieveObjectByUrlA;
  16797. begin
  16798. GetProcedureAddress(_CryptRetrieveObjectByUrlA, crypt32, 'CryptRetrieveObjectByUrlA');
  16799. asm
  16800. MOV ESP, EBP
  16801. POP EBP
  16802. JMP [_CryptRetrieveObjectByUrlA]
  16803. end;
  16804. end;
  16805. var
  16806. _CryptRetrieveObjectByUrlW: Pointer;
  16807. function CryptRetrieveObjectByUrlW;
  16808. begin
  16809. GetProcedureAddress(_CryptRetrieveObjectByUrlW, crypt32, 'CryptRetrieveObjectByUrlW');
  16810. asm
  16811. MOV ESP, EBP
  16812. POP EBP
  16813. JMP [_CryptRetrieveObjectByUrlW]
  16814. end;
  16815. end;
  16816. var
  16817. _CryptRetrieveObjectByUrl: Pointer;
  16818. function CryptRetrieveObjectByUrl;
  16819. begin
  16820. GetProcedureAddress(_CryptRetrieveObjectByUrl, crypt32, 'CryptRetrieveObjectByUrl' + AWSuffix);
  16821. asm
  16822. MOV ESP, EBP
  16823. POP EBP
  16824. JMP [_CryptRetrieveObjectByUrl]
  16825. end;
  16826. end;
  16827. var
  16828. _CryptInstallCancelRetrieval: Pointer;
  16829. function CryptInstallCancelRetrieval;
  16830. begin
  16831. GetProcedureAddress(_CryptInstallCancelRetrieval, crypt32, 'CryptInstallCancelRetrieval');
  16832. asm
  16833. MOV ESP, EBP
  16834. POP EBP
  16835. JMP [_CryptInstallCancelRetrieval]
  16836. end;
  16837. end;
  16838. var
  16839. _CryptUninstallCancelRetrieval: Pointer;
  16840. function CryptUninstallCancelRetrieval;
  16841. begin
  16842. GetProcedureAddress(_CryptUninstallCancelRetrieval, crypt32, 'CryptUninstallCancelRetrieval');
  16843. asm
  16844. MOV ESP, EBP
  16845. POP EBP
  16846. JMP [_CryptUninstallCancelRetrieval]
  16847. end;
  16848. end;
  16849. var
  16850. _CryptCancelAsyncRetrieval: Pointer;
  16851. function CryptCancelAsyncRetrieval;
  16852. begin
  16853. GetProcedureAddress(_CryptCancelAsyncRetrieval, crypt32, 'CryptCancelAsyncRetrieval');
  16854. asm
  16855. MOV ESP, EBP
  16856. POP EBP
  16857. JMP [_CryptCancelAsyncRetrieval]
  16858. end;
  16859. end;
  16860. var
  16861. _CryptGetObjectUrl: Pointer;
  16862. function CryptGetObjectUrl;
  16863. begin
  16864. GetProcedureAddress(_CryptGetObjectUrl, crypt32, 'CryptGetObjectUrl');
  16865. asm
  16866. MOV ESP, EBP
  16867. POP EBP
  16868. JMP [_CryptGetObjectUrl]
  16869. end;
  16870. end;
  16871. var
  16872. _CryptGetTimeValidObject: Pointer;
  16873. function CryptGetTimeValidObject;
  16874. begin
  16875. GetProcedureAddress(_CryptGetTimeValidObject, crypt32, 'CryptGetTimeValidObject');
  16876. asm
  16877. MOV ESP, EBP
  16878. POP EBP
  16879. JMP [_CryptGetTimeValidObject]
  16880. end;
  16881. end;
  16882. var
  16883. _CryptFlushTimeValidObject: Pointer;
  16884. function CryptFlushTimeValidObject;
  16885. begin
  16886. GetProcedureAddress(_CryptFlushTimeValidObject, crypt32, 'CryptFlushTimeValidObject');
  16887. asm
  16888. MOV ESP, EBP
  16889. POP EBP
  16890. JMP [_CryptFlushTimeValidObject]
  16891. end;
  16892. end;
  16893. var
  16894. _CryptProtectData: Pointer;
  16895. function CryptProtectData;
  16896. begin
  16897. GetProcedureAddress(_CryptProtectData, crypt32, 'CryptProtectData');
  16898. asm
  16899. MOV ESP, EBP
  16900. POP EBP
  16901. JMP [_CryptProtectData]
  16902. end;
  16903. end;
  16904. var
  16905. _CryptUnprotectData: Pointer;
  16906. function CryptUnprotectData;
  16907. begin
  16908. GetProcedureAddress(_CryptUnprotectData, crypt32, 'CryptUnprotectData');
  16909. asm
  16910. MOV ESP, EBP
  16911. POP EBP
  16912. JMP [_CryptUnprotectData]
  16913. end;
  16914. end;
  16915. var
  16916. _CertCreateSelfSignCertificate: Pointer;
  16917. function CertCreateSelfSignCertificate;
  16918. begin
  16919. GetProcedureAddress(_CertCreateSelfSignCertificate, crypt32, 'CertCreateSelfSignCertificate');
  16920. asm
  16921. MOV ESP, EBP
  16922. POP EBP
  16923. JMP [_CertCreateSelfSignCertificate]
  16924. end;
  16925. end;
  16926. var
  16927. _CryptGetKeyIdentifierProperty: Pointer;
  16928. function CryptGetKeyIdentifierProperty;
  16929. begin
  16930. GetProcedureAddress(_CryptGetKeyIdentifierProperty, crypt32, 'CryptGetKeyIdentifierProperty');
  16931. asm
  16932. MOV ESP, EBP
  16933. POP EBP
  16934. JMP [_CryptGetKeyIdentifierProperty]
  16935. end;
  16936. end;
  16937. var
  16938. _CryptSetKeyIdentifierProperty: Pointer;
  16939. function CryptSetKeyIdentifierProperty;
  16940. begin
  16941. GetProcedureAddress(_CryptSetKeyIdentifierProperty, crypt32, 'CryptSetKeyIdentifierProperty');
  16942. asm
  16943. MOV ESP, EBP
  16944. POP EBP
  16945. JMP [_CryptSetKeyIdentifierProperty]
  16946. end;
  16947. end;
  16948. var
  16949. _CryptEnumKeyIdentProperties: Pointer;
  16950. function CryptEnumKeyIdentifierProperties;
  16951. begin
  16952. GetProcedureAddress(_CryptEnumKeyIdentProperties, crypt32, 'CryptEnumKeyIdentifierProperties');
  16953. asm
  16954. MOV ESP, EBP
  16955. POP EBP
  16956. JMP [_CryptEnumKeyIdentProperties]
  16957. end;
  16958. end;
  16959. var
  16960. _CryptCreateKeyIdentifierFromCSP: Pointer;
  16961. function CryptCreateKeyIdentifierFromCSP;
  16962. begin
  16963. GetProcedureAddress(_CryptCreateKeyIdentifierFromCSP, crypt32, 'CryptCreateKeyIdentifierFromCSP');
  16964. asm
  16965. MOV ESP, EBP
  16966. POP EBP
  16967. JMP [_CryptCreateKeyIdentifierFromCSP]
  16968. end;
  16969. end;
  16970. var
  16971. _CertCreateCertChainEngine: Pointer;
  16972. function CertCreateCertificateChainEngine;
  16973. begin
  16974. GetProcedureAddress(_CertCreateCertChainEngine, crypt32, 'CertCreateCertificateChainEngine');
  16975. asm
  16976. MOV ESP, EBP
  16977. POP EBP
  16978. JMP [_CertCreateCertChainEngine]
  16979. end;
  16980. end;
  16981. var
  16982. _CertFreeCertificateChainEngine: Pointer;
  16983. procedure CertFreeCertificateChainEngine;
  16984. begin
  16985. GetProcedureAddress(_CertFreeCertificateChainEngine, crypt32, 'CertFreeCertificateChainEngine');
  16986. asm
  16987. MOV ESP, EBP
  16988. POP EBP
  16989. JMP [_CertFreeCertificateChainEngine]
  16990. end;
  16991. end;
  16992. var
  16993. _CertResyncCertChainEngine: Pointer;
  16994. function CertResyncCertificateChainEngine;
  16995. begin
  16996. GetProcedureAddress(_CertResyncCertChainEngine, crypt32, 'CertResyncCertificateChainEngine');
  16997. asm
  16998. MOV ESP, EBP
  16999. POP EBP
  17000. JMP [_CertResyncCertChainEngine]
  17001. end;
  17002. end;
  17003. var
  17004. _CertGetCertificateChain: Pointer;
  17005. function CertGetCertificateChain;
  17006. begin
  17007. GetProcedureAddress(_CertGetCertificateChain, crypt32, 'CertGetCertificateChain');
  17008. asm
  17009. MOV ESP, EBP
  17010. POP EBP
  17011. JMP [_CertGetCertificateChain]
  17012. end;
  17013. end;
  17014. var
  17015. _CertFreeCertificateChain: Pointer;
  17016. procedure CertFreeCertificateChain;
  17017. begin
  17018. GetProcedureAddress(_CertFreeCertificateChain, crypt32, 'CertFreeCertificateChain');
  17019. asm
  17020. MOV ESP, EBP
  17021. POP EBP
  17022. JMP [_CertFreeCertificateChain]
  17023. end;
  17024. end;
  17025. var
  17026. _CertDuplicateCertificateChain: Pointer;
  17027. function CertDuplicateCertificateChain;
  17028. begin
  17029. GetProcedureAddress(_CertDuplicateCertificateChain, crypt32, 'CertDuplicateCertificateChain');
  17030. asm
  17031. MOV ESP, EBP
  17032. POP EBP
  17033. JMP [_CertDuplicateCertificateChain]
  17034. end;
  17035. end;
  17036. var
  17037. _CertFindChainInStore: Pointer;
  17038. function CertFindChainInStore;
  17039. begin
  17040. GetProcedureAddress(_CertFindChainInStore, crypt32, 'CertFindChainInStore');
  17041. asm
  17042. MOV ESP, EBP
  17043. POP EBP
  17044. JMP [_CertFindChainInStore]
  17045. end;
  17046. end;
  17047. var
  17048. _CertVerifyCertChainPolicy: Pointer;
  17049. function CertVerifyCertificateChainPolicy;
  17050. begin
  17051. GetProcedureAddress(_CertVerifyCertChainPolicy, crypt32, 'CertVerifyCertificateChainPolicy');
  17052. asm
  17053. MOV ESP, EBP
  17054. POP EBP
  17055. JMP [_CertVerifyCertChainPolicy]
  17056. end;
  17057. end;
  17058. {$ELSE}
  17059. function CryptAcquireContextA; external advapi32 name 'CryptAcquireContextA';
  17060. function CryptAcquireContextW; external advapi32 name 'CryptAcquireContextW';
  17061. function CryptAcquireContext; external advapi32 name 'CryptAcquireContext' + AWSuffix;
  17062. function CryptReleaseContext; external advapi32 name 'CryptReleaseContext';
  17063. function CryptGenKey; external advapi32 name 'CryptGenKey';
  17064. function CryptDeriveKey; external advapi32 name 'CryptDeriveKey';
  17065. function CryptDestroyKey; external advapi32 name 'CryptDestroyKey';
  17066. function CryptSetKeyParam; external crypt32 name 'CryptSetKeyParam';
  17067. function CryptGetKeyParam; external advapi32 name 'CryptGetKeyParam';
  17068. function CryptSetHashParam; external advapi32 name 'CryptSetHashParam';
  17069. function CryptGetHashParam; external advapi32 name 'CryptGetHashParam';
  17070. function CryptSetProvParam; external advapi32 name 'CryptSetProvParam';
  17071. function CryptGetProvParam; external advapi32 name 'CryptGetProvParam';
  17072. function CryptGenRandom; external advapi32 name 'CryptGenRandom';
  17073. function CryptGetUserKey; external advapi32 name 'CryptGetUserKey';
  17074. function CryptExportKey; external advapi32 name 'CryptExportKey';
  17075. function CryptImportKey; external advapi32 name 'CryptImportKey';
  17076. function CryptEncrypt; external advapi32 name 'CryptEncrypt';
  17077. function CryptDecrypt; external advapi32 name 'CryptDecrypt';
  17078. function CryptCreateHash; external advapi32 name 'CryptCreateHash';
  17079. function CryptHashData; external advapi32 name 'CryptHashData';
  17080. function CryptHashSessionKey; external advapi32 name 'CryptHashSessionKey';
  17081. function CryptDestroyHash; external advapi32 name 'CryptDestroyHash';
  17082. function CryptSignHashA; external advapi32 name 'CryptSignHashA';
  17083. function CryptSignHashW; external advapi32 name 'CryptSignHashW';
  17084. function CryptSignHash; external advapi32 name 'CryptSignHash' + AWSuffix;
  17085. function CryptVerifySignatureA; external advapi32 name 'CryptVerifySignatureA';
  17086. function CryptVerifySignatureW; external advapi32 name 'CryptVerifySignatureW';
  17087. function CryptVerifySignature; external advapi32 name 'CryptVerifySignature' + AWSuffix;
  17088. function CryptSetProviderA; external advapi32 name 'CryptSetProviderA';
  17089. function CryptSetProviderW; external advapi32 name 'CryptSetProviderW';
  17090. function CryptSetProvider; external advapi32 name 'CryptSetProvider' + AWSuffix;
  17091. function CryptSetProviderExA; external advapi32 name 'CryptSetProviderExA';
  17092. function CryptSetProviderExW; external advapi32 name 'CryptSetProviderExW';
  17093. function CryptSetProviderEx; external advapi32 name 'CryptSetProviderEx' + AWSuffix;
  17094. function CryptGetDefaultProviderA; external advapi32 name 'CryptGetDefaultProviderA';
  17095. function CryptGetDefaultProviderW; external advapi32 name 'CryptGetDefaultProviderW';
  17096. function CryptGetDefaultProvider; external advapi32 name 'CryptGetDefaultProvider' + AWSuffix;
  17097. function CryptEnumProviderTypesA; external advapi32 name 'CryptEnumProviderTypesA';
  17098. function CryptEnumProviderTypesW; external advapi32 name 'CryptEnumProviderTypesW';
  17099. function CryptEnumProviderTypes; external advapi32 name 'CryptEnumProviderTypes' + AWSuffix;
  17100. function CryptEnumProvidersA; external advapi32 name 'CryptEnumProvidersA';
  17101. function CryptEnumProvidersW; external advapi32 name 'CryptEnumProvidersW';
  17102. function CryptEnumProviders; external advapi32 name 'CryptEnumProviders' + AWSuffix;
  17103. function CryptContextAddRef; external advapi32 name 'CryptContextAddRef';
  17104. function CryptDuplicateKey; external advapi32 name 'CryptDuplicateKey';
  17105. function CryptDuplicateHash; external advapi32 name 'CryptDuplicateHash';
  17106. function CryptFormatObject; external crypt32 name 'CryptFormatObject';
  17107. function CryptEncodeObjectEx; external crypt32 name 'CryptEncodeObjectEx';
  17108. function CryptEncodeObject; external crypt32 name 'CryptEncodeObject';
  17109. function CryptDecodeObjectEx; external crypt32 name 'CryptDecodeObjectEx';
  17110. function CryptDecodeObject; external crypt32 name 'CryptDecodeObject';
  17111. function CryptInstallOIDFunctionAddress; external crypt32 name 'CryptInstallOIDFunctionAddress';
  17112. function CryptInitOIDFunctionSet; external crypt32 name 'CryptInitOIDFunctionSet';
  17113. function CryptGetOIDFunctionAddress; external crypt32 name 'CryptGetOIDFunctionAddress';
  17114. function CryptGetDefaultOIDDllList; external crypt32 name 'CryptGetDefaultOIDDllList';
  17115. function CryptGetDefaultOIDFunctionAddress; external crypt32 name 'CryptGetDefaultOIDFunctionAddress';
  17116. function CryptFreeOIDFunctionAddress; external crypt32 name 'CryptFreeOIDFunctionAddress';
  17117. function CryptRegisterOIDFunction; external crypt32 name 'CryptRegisterOIDFunction';
  17118. function CryptUnregisterOIDFunction; external crypt32 name 'CryptUnregisterOIDFunction';
  17119. function CryptRegisterDefaultOIDFunction; external crypt32 name 'CryptRegisterDefaultOIDFunction';
  17120. function CryptUnregisterDefaultOIDFunction; external crypt32 name 'CryptUnregisterDefaultOIDFunction';
  17121. function CryptSetOIDFunctionValue; external crypt32 name 'CryptSetOIDFunctionValue';
  17122. function CryptGetOIDFunctionValue; external crypt32 name 'CryptGetOIDFunctionValue';
  17123. function CryptEnumOIDFunction; external crypt32 name 'CryptEnumOIDFunction';
  17124. function CryptFindOIDInfo; external crypt32 name 'CryptFindOIDInfo';
  17125. function CryptRegisterOIDInfo; external crypt32 name 'CryptRegisterOIDInfo';
  17126. function CryptUnregisterOIDInfo; external crypt32 name 'CryptUnregisterOIDInfo';
  17127. function CryptEnumOIDInfo; external crypt32 name 'CryptEnumOIDInfo';
  17128. function CryptFindLocalizedName; external crypt32 name 'CryptFindLocalizedName';
  17129. function CryptMsgOpenToEncode; external crypt32 name 'CryptMsgOpenToEncode';
  17130. function CryptMsgCalculateEncodedLength; external crypt32 name 'CryptMsgCalculateEncodedLength';
  17131. function CryptMsgOpenToDecode; external crypt32 name 'CryptMsgOpenToDecode';
  17132. function CryptMsgDuplicate; external crypt32 name 'CryptMsgDuplicate';
  17133. function CryptMsgClose; external crypt32 name 'CryptMsgClose';
  17134. function CryptMsgUpdate; external crypt32 name 'CryptMsgUpdate';
  17135. function CryptMsgGetParam; external crypt32 name 'CryptMsgGetParam';
  17136. function CryptMsgControl; external crypt32 name 'CryptMsgControl';
  17137. function CryptMsgVerifyCountersignatureEncoded; external crypt32 name 'CryptMsgVerifyCountersignatureEncoded';
  17138. function CryptMsgVerifyCountersignatureEncodedEx; external crypt32 name 'CryptMsgVerifyCountersignatureEncodedEx';
  17139. function CryptMsgCountersign; external crypt32 name 'CryptMsgCountersign';
  17140. function CryptMsgCountersignEncoded; external crypt32 name 'CryptMsgCountersignEncoded';
  17141. function CertOpenStore; external crypt32 name 'CertOpenStore';
  17142. function CertDuplicateStore; external crypt32 name 'CertDuplicateStore';
  17143. function CertSaveStore; external crypt32 name 'CertSaveStore';
  17144. function CertCloseStore; external crypt32 name 'CertCloseStore';
  17145. function CertGetSubjectCertificateFromStore; external crypt32 name 'CertGetSubjectCertificateFromStore';
  17146. function CertEnumCertificatesInStore; external crypt32 name 'CertEnumCertificatesInStore';
  17147. function CertFindCertificateInStore; external crypt32 name 'CertFindCertificateInStore';
  17148. function CertGetIssuerCertificateFromStore; external crypt32 name 'CertGetIssuerCertificateFromStore';
  17149. function CertVerifySubjectCertificateContext; external crypt32 name 'CertVerifySubjectCertificateContext';
  17150. function CertDuplicateCertificateContext; external crypt32 name 'CertDuplicateCertificateContext';
  17151. function CertCreateCertificateContext; external crypt32 name 'CertCreateCertificateContext';
  17152. function CertFreeCertificateContext; external crypt32 name 'CertFreeCertificateContext';
  17153. function CertSetCertificateContextProperty; external crypt32 name 'CertSetCertificateContextProperty';
  17154. function CertGetCertificateContextProperty; external crypt32 name 'CertGetCertificateContextProperty';
  17155. function CertEnumCertificateContextProperties; external crypt32 name 'CertEnumCertificateContextProperties';
  17156. function CertGetCRLFromStore; external crypt32 name 'CertGetCRLFromStore';
  17157. function CertEnumCRLsInStore; external crypt32 name 'CertEnumCRLsInStore';
  17158. function CertFindCRLInStore; external crypt32 name 'CertFindCRLInStore';
  17159. function CertDuplicateCRLContext; external crypt32 name 'CertDuplicateCRLContext';
  17160. function CertCreateCRLContext; external crypt32 name 'CertCreateCRLContext';
  17161. function CertFreeCRLContext; external crypt32 name 'CertFreeCRLContext';
  17162. function CertSetCRLContextProperty; external crypt32 name 'CertSetCRLContextProperty';
  17163. function CertGetCRLContextProperty; external crypt32 name 'CertGetCRLContextProperty';
  17164. function CertEnumCRLContextProperties; external crypt32 name 'CertEnumCRLContextProperties';
  17165. function CertFindCertificateInCRL; external crypt32 name 'CertFindCertificateInCRL';
  17166. function CertAddEncodedCertificateToStore; external crypt32 name 'CertAddEncodedCertificateToStore';
  17167. function CertAddCertificateContextToStore; external crypt32 name 'CertAddCertificateContextToStore';
  17168. function CertAddSerializedElementToStore; external crypt32 name 'CertAddSerializedElementToStore';
  17169. function CertDeleteCertificateFromStore; external crypt32 name 'CertDeleteCertificateFromStore';
  17170. function CertAddEncodedCRLToStore; external crypt32 name 'CertAddEncodedCRLToStore';
  17171. function CertAddCRLContextToStore; external crypt32 name 'CertAddCRLContextToStore';
  17172. function CertDeleteCRLFromStore; external crypt32 name 'CertDeleteCRLFromStore';
  17173. function CertSerializeCertificateStoreElement; external crypt32 name 'CertSerializeCertificateStoreElement';
  17174. function CertSerializeCRLStoreElement; external crypt32 name 'CertSerializeCRLStoreElement';
  17175. function CertDuplicateCTLContext; external crypt32 name 'CertDuplicateCTLContext';
  17176. function CertCreateCTLContext; external crypt32 name 'CertCreateCTLContext';
  17177. function CertFreeCTLContext; external crypt32 name 'CertFreeCTLContext';
  17178. function CertSetCTLContextProperty; external crypt32 name 'CertSetCTLContextProperty';
  17179. function CertGetCTLContextProperty; external crypt32 name 'CertGetCTLContextProperty';
  17180. function CertEnumCTLContextProperties; external crypt32 name 'CertEnumCTLContextProperties';
  17181. function CertEnumCTLsInStore; external crypt32 name 'CertEnumCTLsInStore';
  17182. function CertFindSubjectInCTL; external crypt32 name 'CertFindSubjectInCTL';
  17183. function CertFindCTLInStore; external crypt32 name 'CertFindCTLInStore';
  17184. function CertAddEncodedCTLToStore; external crypt32 name 'CertAddEncodedCTLToStore';
  17185. function CertAddCTLContextToStore; external crypt32 name 'CertAddCTLContextToStore';
  17186. function CertSerializeCTLStoreElement; external crypt32 name 'CertSerializeCTLStoreElement';
  17187. function CertDeleteCTLFromStore; external crypt32 name 'CertDeleteCTLFromStore';
  17188. function CertAddCertificateLinkToStore; external crypt32 name 'CertAddCertificateLinkToStore';
  17189. function CertAddCRLLinkToStore; external crypt32 name 'CertAddCRLLinkToStore';
  17190. function CertAddCTLLinkToStore; external crypt32 name 'CertAddCTLLinkToStore';
  17191. function CertAddStoreToCollection; external crypt32 name 'CertAddStoreToCollection';
  17192. procedure CertRemoveStoreFromCollection; external crypt32 name 'CertRemoveStoreFromCollection';
  17193. function CertControlStore; external crypt32 name 'CertControlStore';
  17194. function CertSetStoreProperty; external crypt32 name 'CertSetStoreProperty';
  17195. function CertGetStoreProperty; external crypt32 name 'CertGetStoreProperty';
  17196. function CertCreateContext; external crypt32 name 'CertCreateContext';
  17197. function CertRegisterSystemStore; external crypt32 name 'CertRegisterSystemStore';
  17198. function CertRegisterPhysicalStore; external crypt32 name 'CertRegisterPhysicalStore';
  17199. function CertUnregisterSystemStore; external crypt32 name 'CertUnregisterSystemStore';
  17200. function CertUnregisterPhysicalStore; external crypt32 name 'CertUnregisterPhysicalStore';
  17201. function CertEnumSystemStoreLocation; external crypt32 name 'CertEnumSystemStoreLocation';
  17202. function CertEnumSystemStore; external crypt32 name 'CertEnumSystemStore';
  17203. function CertEnumPhysicalStore; external crypt32 name 'CertEnumPhysicalStore';
  17204. function CertGetEnhancedKeyUsage; external crypt32 name 'CertGetEnhancedKeyUsage';
  17205. function CertSetEnhancedKeyUsage; external crypt32 name 'CertSetEnhancedKeyUsage';
  17206. function CertAddEnhancedKeyUsageIdentifier; external crypt32 name 'CertAddEnhancedKeyUsageIdentifier';
  17207. function CertRemoveEnhancedKeyUsageIdentifier; external crypt32 name 'CertRemoveEnhancedKeyUsageIdentifier';
  17208. function CertGetValidUsages; external crypt32 name 'CertGetValidUsages';
  17209. function CryptMsgGetAndVerifySigner; external crypt32 name 'CryptMsgGetAndVerifySigner';
  17210. function CryptMsgSignCTL; external crypt32 name 'CryptMsgSignCTL';
  17211. function CryptMsgEncodeAndSignCTL; external crypt32 name 'CryptMsgEncodeAndSignCTL';
  17212. function CertFindSubjectInSortedCTL; external crypt32 name 'CertFindSubjectInSortedCTL';
  17213. function CertEnumSubjectInSortedCTL; external crypt32 name 'CertEnumSubjectInSortedCTL';
  17214. function CertVerifyCTLUsage; external crypt32 name 'CertVerifyCTLUsage';
  17215. function CertVerifyRevocation; external crypt32 name 'CertVerifyRevocation';
  17216. function CertCompareIntegerBlob; external crypt32 name 'CertCompareIntegerBlob';
  17217. function CertCompareCertificate; external crypt32 name 'CertCompareCertificate';
  17218. function CertCompareCertificateName; external crypt32 name 'CertCompareCertificateName';
  17219. function CertIsRDNAttrsInCertificateName; external crypt32 name 'CertIsRDNAttrsInCertificateName';
  17220. function CertComparePublicKeyInfo; external crypt32 name 'CertComparePublicKeyInfo';
  17221. function CertGetPublicKeyLength; external crypt32 name 'CertGetPublicKeyLength';
  17222. function CryptVerifyCertificateSignature; external crypt32 name 'CryptVerifyCertificateSignature';
  17223. function CryptVerifyCertificateSignatureEx; external crypt32 name 'CryptVerifyCertificateSignatureEx';
  17224. function CryptHashToBeSigned; external crypt32 name 'CryptHashToBeSigned';
  17225. function CryptHashCertificate; external crypt32 name 'CryptHashCertificate';
  17226. function CryptSignCertificate; external crypt32 name 'CryptSignCertificate';
  17227. function CryptSignAndEncodeCertificate; external crypt32 name 'CryptSignAndEncodeCertificate';
  17228. function CertVerifyTimeValidity; external crypt32 name 'CertVerifyTimeValidity';
  17229. function CertVerifyCRLTimeValidity; external crypt32 name 'CertVerifyCRLTimeValidity';
  17230. function CertVerifyValidityNesting; external crypt32 name 'CertVerifyValidityNesting';
  17231. function CertVerifyCRLRevocation; external crypt32 name 'CertVerifyCRLRevocation';
  17232. function CertAlgIdToOID; external crypt32 name 'CertAlgIdToOID';
  17233. function CertOIDToAlgId; external crypt32 name 'CertOIDToAlgId';
  17234. function CertFindExtension; external crypt32 name 'CertFindExtension';
  17235. function CertFindAttribute; external crypt32 name 'CertFindAttribute';
  17236. function CertFindRDNAttr; external crypt32 name 'CertFindRDNAttr';
  17237. function CertGetIntendedKeyUsage; external crypt32 name 'CertGetIntendedKeyUsage';
  17238. function CryptInstallDefaultContext; external crypt32 name 'CryptInstallDefaultContext';
  17239. function CryptUninstallDefaultContext; external crypt32 name 'CryptUninstallDefaultContext';
  17240. function CryptExportPublicKeyInfo; external crypt32 name 'CryptExportPublicKeyInfo';
  17241. function CryptExportPublicKeyInfoEx; external crypt32 name 'CryptExportPublicKeyInfoEx';
  17242. function CryptImportPublicKeyInfo; external crypt32 name 'CryptImportPublicKeyInfo';
  17243. function CryptImportPublicKeyInfoEx; external crypt32 name 'CryptImportPublicKeyInfoEx';
  17244. function CryptAcquireCertificatePrivateKey; external crypt32 name 'CryptAcquireCertificatePrivateKey';
  17245. function CryptFindCertificateKeyProvInfo; external crypt32 name 'CryptFindCertificateKeyProvInfo';
  17246. function CryptImportPKCS8; external crypt32 name 'CryptImportPKCS8';
  17247. function CryptExportPKCS8; external crypt32 name 'CryptExportPKCS8';
  17248. function CryptExportPKCS8Ex; external crypt32 name 'CryptExportPKCS8Ex';
  17249. function CryptHashPublicKeyInfo; external crypt32 name 'CryptHashPublicKeyInfo';
  17250. function CertRDNValueToStrA; external crypt32 name 'CertRDNValueToStrA';
  17251. function CertRDNValueToStrW; external crypt32 name 'CertRDNValueToStrW';
  17252. function CertRDNValueToStr; external crypt32 name 'CertRDNValueToStr' + AWSuffix;
  17253. function CertNameToStrA; external crypt32 name 'CertNameToStrA';
  17254. function CertNameToStrW; external crypt32 name 'CertNameToStrW';
  17255. function CertNameToStr; external crypt32 name 'CertNameToStr' + AWSuffix;
  17256. function CertStrToNameA; external crypt32 name 'CertStrToNameA';
  17257. function CertStrToNameW; external crypt32 name 'CertStrToNameW';
  17258. function CertStrToName; external crypt32 name 'CertStrToName' + AWSuffix;
  17259. function CertGetNameStringA; external crypt32 name 'CertGetNameStringA';
  17260. function CertGetNameStringW; external crypt32 name 'CertGetNameStringW';
  17261. function CertGetNameString; external crypt32 name 'CertGetNameString' + AWSuffix;
  17262. function CryptSignMessage; external crypt32 name 'CryptSignMessage';
  17263. function CryptVerifyMessageSignature; external crypt32 name 'CryptVerifyMessageSignature';
  17264. function CryptGetMessageSignerCount; external crypt32 name 'CryptGetMessageSignerCount';
  17265. function CryptGetMessageCertificates; external crypt32 name 'CryptGetMessageCertificates';
  17266. function CryptVerifyDetachedMessageSignature; external crypt32 name 'CryptVerifyDetachedMessageSignature';
  17267. function CryptEncryptMessage; external crypt32 name 'CryptEncryptMessage';
  17268. function CryptDecryptMessage; external crypt32 name 'CryptDecryptMessage';
  17269. function CryptSignAndEncryptMessage; external crypt32 name 'CryptSignAndEncryptMessage';
  17270. function CryptDecryptAndVerifyMessageSignature; external crypt32 name 'CryptDecryptAndVerifyMessageSignature';
  17271. function CryptDecodeMessage; external crypt32 name 'CryptDecodeMessage';
  17272. function CryptHashMessage; external crypt32 name 'CryptHashMessage';
  17273. function CryptVerifyMessageHash; external crypt32 name 'CryptVerifyMessageHash';
  17274. function CryptVerifyDetachedMessageHash; external crypt32 name 'CryptVerifyDetachedMessageHash';
  17275. function CryptSignMessageWithKey; external crypt32 name 'CryptSignMessageWithKey';
  17276. function CryptVerifyMessageSignatureWithKey; external crypt32 name 'CryptVerifyMessageSignatureWithKey';
  17277. function CertOpenSystemStoreA; external crypt32 name 'CertOpenSystemStoreA';
  17278. function CertOpenSystemStoreW; external crypt32 name 'CertOpenSystemStoreW';
  17279. function CertOpenSystemStore; external crypt32 name 'CertOpenSystemStore' + AWSuffix;
  17280. function CertAddEncodedCertificateToSystemStoreA; external crypt32 name 'CertAddEncodedCertificateToSystemStoreA';
  17281. function CertAddEncodedCertificateToSystemStoreW; external crypt32 name 'CertAddEncodedCertificateToSystemStoreW';
  17282. function CertAddEncodedCertificateToSystemStore; external crypt32 name 'CertAddEncodedCertificateToSystemStore' + AWSuffix;
  17283. function FindCertsByIssuer; external softpub name 'FindCertsByIssuer';
  17284. function CryptQueryObject; external crypt32 name 'CryptQueryObject';
  17285. function CryptMemAlloc; external crypt32 name 'CryptMemAlloc';
  17286. function CryptMemRealloc; external crypt32 name 'CryptMemRealloc';
  17287. procedure CryptMemFree; external crypt32 name 'CryptMemFree';
  17288. function CryptCreateAsyncHandle; external crypt32 name 'CryptCreateAsyncHandle';
  17289. function CryptSetAsyncParam; external crypt32 name 'CryptSetAsyncParam';
  17290. function CryptGetAsyncParam; external crypt32 name 'CryptGetAsyncParam';
  17291. function CryptCloseAsyncHandle; external crypt32 name 'CryptCloseAsyncHandle';
  17292. function CryptRetrieveObjectByUrlA; external crypt32 name 'CryptRetrieveObjectByUrlA';
  17293. function CryptRetrieveObjectByUrlW; external crypt32 name 'CryptRetrieveObjectByUrlW';
  17294. function CryptRetrieveObjectByUrl; external crypt32 name 'CryptRetrieveObjectByUrl' + AWSuffix;
  17295. function CryptInstallCancelRetrieval; external crypt32 name 'CryptInstallCancelRetrieval';
  17296. function CryptUninstallCancelRetrieval; external crypt32 name 'CryptUninstallCancelRetrieval';
  17297. function CryptCancelAsyncRetrieval; external crypt32 name 'CryptCancelAsyncRetrieval';
  17298. function CryptGetObjectUrl; external crypt32 name 'CryptGetObjectUrl';
  17299. function CryptGetTimeValidObject; external crypt32 name 'CryptGetTimeValidObject';
  17300. function CryptFlushTimeValidObject; external crypt32 name 'CryptFlushTimeValidObject';
  17301. function CryptProtectData; external crypt32 name 'CryptProtectData';
  17302. function CryptUnprotectData; external crypt32 name 'CryptUnprotectData';
  17303. function CertCreateSelfSignCertificate; external crypt32 name 'CertCreateSelfSignCertificate';
  17304. function CryptGetKeyIdentifierProperty; external crypt32 name 'CryptGetKeyIdentifierProperty';
  17305. function CryptSetKeyIdentifierProperty; external crypt32 name 'CryptSetKeyIdentifierProperty';
  17306. function CryptEnumKeyIdentifierProperties; external crypt32 name 'CryptEnumKeyIdentifierProperties';
  17307. function CryptCreateKeyIdentifierFromCSP; external crypt32 name 'CryptCreateKeyIdentifierFromCSP';
  17308. function CertCreateCertificateChainEngine; external crypt32 name 'CertCreateCertificateChainEngine';
  17309. procedure CertFreeCertificateChainEngine; external crypt32 name 'CertFreeCertificateChainEngine';
  17310. function CertResyncCertificateChainEngine; external crypt32 name 'CertResyncCertificateChainEngine';
  17311. function CertGetCertificateChain; external crypt32 name 'CertGetCertificateChain';
  17312. procedure CertFreeCertificateChain; external crypt32 name 'CertFreeCertificateChain';
  17313. function CertDuplicateCertificateChain; external crypt32 name 'CertDuplicateCertificateChain';
  17314. function CertFindChainInStore; external crypt32 name 'CertFindChainInStore';
  17315. function CertVerifyCertificateChainPolicy; external crypt32 name 'CertVerifyCertificateChainPolicy';
  17316. {$ENDIF DYNAMIC_LINK}
  17317. {$ENDIF JWA_IMPLEMENTATIONSECTION}
  17318. {$IFNDEF JWA_INCLUDEMODE}
  17319. end.
  17320. {$ENDIF !JWA_INCLUDEMODE}