jwawincrypt.pas 737 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649
  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. unit JwaWinCrypt;
  43. {$I jediapilib.inc}
  44. {$WEAKPACKAGEUNIT}
  45. interface
  46. uses
  47. JwaWinBase, JwaWinType;
  48. {$HPPEMIT ''}
  49. {$HPPEMIT '#include <WinCrypt.h>'}
  50. {$HPPEMIT ''}
  51. {$HPPEMIT 'typedef HCRYPTPROV *PHCRYPTPROV'}
  52. {$HPPEMIT 'typedef HCRYPTKEY *PHCRYPTKEY'}
  53. {$HPPEMIT 'typedef HCRYPTHASH *PHCRYPTHASH'}
  54. {$HPPEMIT 'typedef PROV_ENUMALGS *PPROV_ENUMALGS'}
  55. {$HPPEMIT 'typedef PROV_ENUMALGS_EX *PPROV_ENUMALGS_EX'}
  56. {$HPPEMIT 'typedef PUBLICKEYSTRUC *PPUBLICKEYSTRUC'}
  57. {$HPPEMIT 'typedef RSAPUBKEY *PRSAPUBKEY'}
  58. {$HPPEMIT 'typedef DSSSEED *PDSSSEED'}
  59. {$HPPEMIT 'typedef PUBKEYVER3 *PPUBKEYVER3'}
  60. {$HPPEMIT 'typedef DHPRIVKEY_VER3 *PPRIVKEYVER3'}
  61. {$HPPEMIT 'typedef CERT_FORTEZZA_DATA_PROP *PCERT_FORTEZZA_DATA_PROP'}
  62. {$HPPEMIT 'typedef HCRYPTMSG *PHCRYPTMSG'}
  63. {$HPPEMIT 'typedef CMSG_RECIPIENT_ENCODE_INFO *PCMSG_RECIPIENT_ENCODE_INFO'}
  64. {$HPPEMIT 'typedef _CMSG_RECIPIENT_ENCODE_INFO CMSG_RECIPIENT_ENCODE_INFO'}
  65. {$HPPEMIT 'typedef PCMSG_KEY_AGREE_KEY_ENCRYPT_INFO *PPCMSG_KEY_AGREE_KEY_ENCRYPT_INFO'}
  66. {$HPPEMIT 'typedef HCERTSTORE *PHCERTSTORE'}
  67. {$HPPEMIT 'typedef PCCERT_CONTEXT *PPCCERT_CONTEXT'}
  68. {$HPPEMIT 'typedef PCCRL_CONTEXT *PPCCRL_CONTEXT'}
  69. {$HPPEMIT 'typedef PCERT_CHAIN_CONTEXT *PPCCERT_CHAIN_CONTEXT'}
  70. {$HPPEMIT ''}
  71. //
  72. // Algorithm IDs and Flags
  73. //
  74. // ALG_ID crackers
  75. function GET_ALG_CLASS(x: DWORD): DWORD;
  76. {$EXTERNALSYM GET_ALG_CLASS}
  77. function GET_ALG_TYPE(x: DWORD): DWORD;
  78. {$EXTERNALSYM GET_ALG_TYPE}
  79. function GET_ALG_SID(x: DWORD): DWORD;
  80. {$EXTERNALSYM GET_ALG_SID}
  81. // Algorithm classes
  82. const
  83. ALG_CLASS_ANY = 0;
  84. {$EXTERNALSYM ALG_CLASS_ANY}
  85. ALG_CLASS_SIGNATURE = 1 shl 13;
  86. {$EXTERNALSYM ALG_CLASS_SIGNATURE}
  87. ALG_CLASS_MSG_ENCRYPT = 2 shl 13;
  88. {$EXTERNALSYM ALG_CLASS_MSG_ENCRYPT}
  89. ALG_CLASS_DATA_ENCRYPT = 3 shl 13;
  90. {$EXTERNALSYM ALG_CLASS_DATA_ENCRYPT}
  91. ALG_CLASS_HASH = 4 shl 13;
  92. {$EXTERNALSYM ALG_CLASS_HASH}
  93. ALG_CLASS_KEY_EXCHANGE = 5 shl 13;
  94. {$EXTERNALSYM ALG_CLASS_KEY_EXCHANGE}
  95. ALG_CLASS_ALL = 7 shl 13;
  96. {$EXTERNALSYM ALG_CLASS_ALL}
  97. // Algorithm types
  98. ALG_TYPE_ANY = 0;
  99. {$EXTERNALSYM ALG_TYPE_ANY}
  100. ALG_TYPE_DSS = 1 shl 9;
  101. {$EXTERNALSYM ALG_TYPE_DSS}
  102. ALG_TYPE_RSA = 2 shl 9;
  103. {$EXTERNALSYM ALG_TYPE_RSA}
  104. ALG_TYPE_BLOCK = 3 shl 9;
  105. {$EXTERNALSYM ALG_TYPE_BLOCK}
  106. ALG_TYPE_STREAM = 4 shl 9;
  107. {$EXTERNALSYM ALG_TYPE_STREAM}
  108. ALG_TYPE_DH = 5 shl 9;
  109. {$EXTERNALSYM ALG_TYPE_DH}
  110. ALG_TYPE_SECURECHANNEL = 6 shl 9;
  111. {$EXTERNALSYM ALG_TYPE_SECURECHANNEL}
  112. // Generic sub-ids
  113. ALG_SID_ANY = 0;
  114. {$EXTERNALSYM ALG_SID_ANY}
  115. // Some RSA sub-ids
  116. ALG_SID_RSA_ANY = 0;
  117. {$EXTERNALSYM ALG_SID_RSA_ANY}
  118. ALG_SID_RSA_PKCS = 1;
  119. {$EXTERNALSYM ALG_SID_RSA_PKCS}
  120. ALG_SID_RSA_MSATWORK = 2;
  121. {$EXTERNALSYM ALG_SID_RSA_MSATWORK}
  122. ALG_SID_RSA_ENTRUST = 3;
  123. {$EXTERNALSYM ALG_SID_RSA_ENTRUST}
  124. ALG_SID_RSA_PGP = 4;
  125. {$EXTERNALSYM ALG_SID_RSA_PGP}
  126. // Some DSS sub-ids
  127. //
  128. ALG_SID_DSS_ANY = 0;
  129. {$EXTERNALSYM ALG_SID_DSS_ANY}
  130. ALG_SID_DSS_PKCS = 1;
  131. {$EXTERNALSYM ALG_SID_DSS_PKCS}
  132. ALG_SID_DSS_DMS = 2;
  133. {$EXTERNALSYM ALG_SID_DSS_DMS}
  134. // Block cipher sub ids
  135. // DES sub_ids
  136. ALG_SID_DES = 1;
  137. {$EXTERNALSYM ALG_SID_DES}
  138. ALG_SID_3DES = 3;
  139. {$EXTERNALSYM ALG_SID_3DES}
  140. ALG_SID_DESX = 4;
  141. {$EXTERNALSYM ALG_SID_DESX}
  142. ALG_SID_IDEA = 5;
  143. {$EXTERNALSYM ALG_SID_IDEA}
  144. ALG_SID_CAST = 6;
  145. {$EXTERNALSYM ALG_SID_CAST}
  146. ALG_SID_SAFERSK64 = 7;
  147. {$EXTERNALSYM ALG_SID_SAFERSK64}
  148. ALG_SID_SAFERSK128 = 8;
  149. {$EXTERNALSYM ALG_SID_SAFERSK128}
  150. ALG_SID_3DES_112 = 9;
  151. {$EXTERNALSYM ALG_SID_3DES_112}
  152. ALG_SID_CYLINK_MEK = 12;
  153. {$EXTERNALSYM ALG_SID_CYLINK_MEK}
  154. ALG_SID_RC5 = 13;
  155. {$EXTERNALSYM ALG_SID_RC5}
  156. // Fortezza sub-ids
  157. ALG_SID_SKIPJACK = 10;
  158. {$EXTERNALSYM ALG_SID_SKIPJACK}
  159. ALG_SID_TEK = 11;
  160. {$EXTERNALSYM ALG_SID_TEK}
  161. // KP_MODE
  162. CRYPT_MODE_CBCI = 6; // ANSI CBC Interleaved
  163. {$EXTERNALSYM CRYPT_MODE_CBCI}
  164. CRYPT_MODE_CFBP = 7; // ANSI CFB Pipelined
  165. {$EXTERNALSYM CRYPT_MODE_CFBP}
  166. CRYPT_MODE_OFBP = 8; // ANSI OFB Pipelined
  167. {$EXTERNALSYM CRYPT_MODE_OFBP}
  168. CRYPT_MODE_CBCOFM = 9; // ANSI CBC + OF Masking
  169. {$EXTERNALSYM CRYPT_MODE_CBCOFM}
  170. CRYPT_MODE_CBCOFMI = 10; // ANSI CBC + OFM Interleaved
  171. {$EXTERNALSYM CRYPT_MODE_CBCOFMI}
  172. // RC2 sub-ids
  173. ALG_SID_RC2 = 2;
  174. {$EXTERNALSYM ALG_SID_RC2}
  175. // Stream cipher sub-ids
  176. ALG_SID_RC4 = 1;
  177. {$EXTERNALSYM ALG_SID_RC4}
  178. ALG_SID_SEAL = 2;
  179. {$EXTERNALSYM ALG_SID_SEAL}
  180. // Diffie-Hellman sub-ids
  181. ALG_SID_DH_SANDF = 1;
  182. {$EXTERNALSYM ALG_SID_DH_SANDF}
  183. ALG_SID_DH_EPHEM = 2;
  184. {$EXTERNALSYM ALG_SID_DH_EPHEM}
  185. ALG_SID_AGREED_KEY_ANY = 3;
  186. {$EXTERNALSYM ALG_SID_AGREED_KEY_ANY}
  187. ALG_SID_KEA = 4;
  188. {$EXTERNALSYM ALG_SID_KEA}
  189. // Hash sub ids
  190. ALG_SID_MD2 = 1;
  191. {$EXTERNALSYM ALG_SID_MD2}
  192. ALG_SID_MD4 = 2;
  193. {$EXTERNALSYM ALG_SID_MD4}
  194. ALG_SID_MD5 = 3;
  195. {$EXTERNALSYM ALG_SID_MD5}
  196. ALG_SID_SHA = 4;
  197. {$EXTERNALSYM ALG_SID_SHA}
  198. ALG_SID_SHA1 = 4;
  199. {$EXTERNALSYM ALG_SID_SHA1}
  200. ALG_SID_MAC = 5;
  201. {$EXTERNALSYM ALG_SID_MAC}
  202. ALG_SID_RIPEMD = 6;
  203. {$EXTERNALSYM ALG_SID_RIPEMD}
  204. ALG_SID_RIPEMD160 = 7;
  205. {$EXTERNALSYM ALG_SID_RIPEMD160}
  206. ALG_SID_SSL3SHAMD5 = 8;
  207. {$EXTERNALSYM ALG_SID_SSL3SHAMD5}
  208. ALG_SID_HMAC = 9;
  209. {$EXTERNALSYM ALG_SID_HMAC}
  210. ALG_SID_TLS1PRF = 10;
  211. {$EXTERNALSYM ALG_SID_TLS1PRF}
  212. // secure channel sub ids
  213. ALG_SID_SSL3_MASTER = 1;
  214. {$EXTERNALSYM ALG_SID_SSL3_MASTER}
  215. ALG_SID_SCHANNEL_MASTER_HASH = 2;
  216. {$EXTERNALSYM ALG_SID_SCHANNEL_MASTER_HASH}
  217. ALG_SID_SCHANNEL_MAC_KEY = 3;
  218. {$EXTERNALSYM ALG_SID_SCHANNEL_MAC_KEY}
  219. ALG_SID_PCT1_MASTER = 4;
  220. {$EXTERNALSYM ALG_SID_PCT1_MASTER}
  221. ALG_SID_SSL2_MASTER = 5;
  222. {$EXTERNALSYM ALG_SID_SSL2_MASTER}
  223. ALG_SID_TLS1_MASTER = 6;
  224. {$EXTERNALSYM ALG_SID_TLS1_MASTER}
  225. ALG_SID_SCHANNEL_ENC_KEY = 7;
  226. {$EXTERNALSYM ALG_SID_SCHANNEL_ENC_KEY}
  227. // Our silly example sub-id
  228. ALG_SID_EXAMPLE = 80;
  229. {$EXTERNALSYM ALG_SID_EXAMPLE}
  230. type
  231. ALG_ID = Cardinal;
  232. {$EXTERNALSYM ALG_ID}
  233. // algorithm identifier definitions
  234. const
  235. CALG_MD2 = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_MD2;
  236. {$EXTERNALSYM CALG_MD2}
  237. CALG_MD4 = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_MD4;
  238. {$EXTERNALSYM CALG_MD4}
  239. CALG_MD5 = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_MD5;
  240. {$EXTERNALSYM CALG_MD5}
  241. CALG_SHA = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_SHA;
  242. {$EXTERNALSYM CALG_SHA}
  243. CALG_SHA1 = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_SHA1;
  244. {$EXTERNALSYM CALG_SHA1}
  245. CALG_MAC = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_MAC;
  246. {$EXTERNALSYM CALG_MAC}
  247. CALG_RSA_SIGN = ALG_CLASS_SIGNATURE or ALG_TYPE_RSA or ALG_SID_RSA_ANY;
  248. {$EXTERNALSYM CALG_RSA_SIGN}
  249. CALG_DSS_SIGN = ALG_CLASS_SIGNATURE or ALG_TYPE_DSS or ALG_SID_DSS_ANY;
  250. {$EXTERNALSYM CALG_DSS_SIGN}
  251. CALG_RSA_KEYX = ALG_CLASS_KEY_EXCHANGE or ALG_TYPE_RSA or ALG_SID_RSA_ANY;
  252. {$EXTERNALSYM CALG_RSA_KEYX}
  253. CALG_DES = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_DES;
  254. {$EXTERNALSYM CALG_DES}
  255. CALG_3DES_112 = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_3DES_112;
  256. {$EXTERNALSYM CALG_3DES_112}
  257. CALG_3DES = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_3DES;
  258. {$EXTERNALSYM CALG_3DES}
  259. CALG_DESX = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_DESX;
  260. {$EXTERNALSYM CALG_DESX}
  261. CALG_RC2 = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_RC2;
  262. {$EXTERNALSYM CALG_RC2}
  263. CALG_RC4 = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_STREAM or ALG_SID_RC4;
  264. {$EXTERNALSYM CALG_RC4}
  265. CALG_SEAL = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_STREAM or ALG_SID_SEAL;
  266. {$EXTERNALSYM CALG_SEAL}
  267. CALG_DH_SF = ALG_CLASS_KEY_EXCHANGE or ALG_TYPE_DH or ALG_SID_DH_SANDF;
  268. {$EXTERNALSYM CALG_DH_SF}
  269. CALG_DH_EPHEM = ALG_CLASS_KEY_EXCHANGE or ALG_TYPE_DH or ALG_SID_DH_EPHEM;
  270. {$EXTERNALSYM CALG_DH_EPHEM}
  271. CALG_AGREEDKEY_ANY = ALG_CLASS_KEY_EXCHANGE or ALG_TYPE_DH or ALG_SID_AGREED_KEY_ANY;
  272. {$EXTERNALSYM CALG_AGREEDKEY_ANY}
  273. CALG_KEA_KEYX = ALG_CLASS_KEY_EXCHANGE or ALG_TYPE_DH or ALG_SID_KEA;
  274. {$EXTERNALSYM CALG_KEA_KEYX}
  275. CALG_HUGHES_MD5 = ALG_CLASS_KEY_EXCHANGE or ALG_TYPE_ANY or ALG_SID_MD5;
  276. {$EXTERNALSYM CALG_HUGHES_MD5}
  277. CALG_SKIPJACK = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_SKIPJACK;
  278. {$EXTERNALSYM CALG_SKIPJACK}
  279. CALG_TEK = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_TEK;
  280. {$EXTERNALSYM CALG_TEK}
  281. CALG_CYLINK_MEK = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_CYLINK_MEK;
  282. {$EXTERNALSYM CALG_CYLINK_MEK}
  283. CALG_SSL3_SHAMD5 = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_SSL3SHAMD5;
  284. {$EXTERNALSYM CALG_SSL3_SHAMD5}
  285. CALG_SSL3_MASTER = ALG_CLASS_MSG_ENCRYPT or ALG_TYPE_SECURECHANNEL or ALG_SID_SSL3_MASTER;
  286. {$EXTERNALSYM CALG_SSL3_MASTER}
  287. CALG_SCHANNEL_MASTER_HASH = ALG_CLASS_MSG_ENCRYPT or ALG_TYPE_SECURECHANNEL or ALG_SID_SCHANNEL_MASTER_HASH;
  288. {$EXTERNALSYM CALG_SCHANNEL_MASTER_HASH}
  289. CALG_SCHANNEL_MAC_KEY = ALG_CLASS_MSG_ENCRYPT or ALG_TYPE_SECURECHANNEL or ALG_SID_SCHANNEL_MAC_KEY;
  290. {$EXTERNALSYM CALG_SCHANNEL_MAC_KEY}
  291. CALG_SCHANNEL_ENC_KEY = ALG_CLASS_MSG_ENCRYPT or ALG_TYPE_SECURECHANNEL or ALG_SID_SCHANNEL_ENC_KEY;
  292. {$EXTERNALSYM CALG_SCHANNEL_ENC_KEY}
  293. CALG_PCT1_MASTER = ALG_CLASS_MSG_ENCRYPT or ALG_TYPE_SECURECHANNEL or ALG_SID_PCT1_MASTER;
  294. {$EXTERNALSYM CALG_PCT1_MASTER}
  295. CALG_SSL2_MASTER = ALG_CLASS_MSG_ENCRYPT or ALG_TYPE_SECURECHANNEL or ALG_SID_SSL2_MASTER;
  296. {$EXTERNALSYM CALG_SSL2_MASTER}
  297. CALG_TLS1_MASTER = ALG_CLASS_MSG_ENCRYPT or ALG_TYPE_SECURECHANNEL or ALG_SID_TLS1_MASTER;
  298. {$EXTERNALSYM CALG_TLS1_MASTER}
  299. CALG_RC5 = ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_RC5;
  300. {$EXTERNALSYM CALG_RC5}
  301. CALG_HMAC = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_HMAC;
  302. {$EXTERNALSYM CALG_HMAC}
  303. CALG_TLS1PRF = ALG_CLASS_HASH or ALG_TYPE_ANY or ALG_SID_TLS1PRF;
  304. {$EXTERNALSYM CALG_TLS1PRF}
  305. // resource number for signatures in the CSP
  306. SIGNATURE_RESOURCE_NUMBER = $29A;
  307. {$EXTERNALSYM SIGNATURE_RESOURCE_NUMBER}
  308. type
  309. PVTableProvStruc = ^VTableProvStruc;
  310. _VTableProvStruc = record
  311. Version: DWORD;
  312. FuncVerifyImage: FARPROC;
  313. FuncReturnhWnd: FARPROC;
  314. dwProvType: DWORD;
  315. pbContextInfo: LPBYTE;
  316. cbContextInfo: DWORD;
  317. pszProvName: LPSTR;
  318. end;
  319. {$EXTERNALSYM _VTableProvStruc}
  320. VTableProvStruc = _VTableProvStruc;
  321. {$EXTERNALSYM VTableProvStruc}
  322. TVTableProvStruc = VTableProvStruc;
  323. HCRYPTPROV = ULONG_PTR;
  324. {$EXTERNALSYM HCRYPTPROV}
  325. HCRYPTKEY = ULONG_PTR;
  326. {$EXTERNALSYM HCRYPTKEY}
  327. HCRYPTHASH = ULONG_PTR;
  328. {$EXTERNALSYM HCRYPTHASH}
  329. PHCRYPTPROV = ^HCRYPTPROV;
  330. {$NODEFINE PHCRYPTPROV}
  331. PHCRYPTKEY = ^HCRYPTKEY;
  332. {$NODEFINE PHCRYPTKEY}
  333. PHCRYPTHASH = ^HCRYPTHASH;
  334. {$NODEFINE PHCRYPTHASH}
  335. // dwFlags definitions for CryptAcquireContext
  336. const
  337. CRYPT_VERIFYCONTEXT = DWORD($F0000000);
  338. {$EXTERNALSYM CRYPT_VERIFYCONTEXT}
  339. CRYPT_NEWKEYSET = $00000008;
  340. {$EXTERNALSYM CRYPT_NEWKEYSET}
  341. CRYPT_DELETEKEYSET = $00000010;
  342. {$EXTERNALSYM CRYPT_DELETEKEYSET}
  343. CRYPT_MACHINE_KEYSET = $00000020;
  344. {$EXTERNALSYM CRYPT_MACHINE_KEYSET}
  345. CRYPT_SILENT = $00000040;
  346. {$EXTERNALSYM CRYPT_SILENT}
  347. // dwFlag definitions for CryptGenKey
  348. CRYPT_EXPORTABLE = $00000001;
  349. {$EXTERNALSYM CRYPT_EXPORTABLE}
  350. CRYPT_USER_PROTECTED = $00000002;
  351. {$EXTERNALSYM CRYPT_USER_PROTECTED}
  352. CRYPT_CREATE_SALT = $00000004;
  353. {$EXTERNALSYM CRYPT_CREATE_SALT}
  354. CRYPT_UPDATE_KEY = $00000008;
  355. {$EXTERNALSYM CRYPT_UPDATE_KEY}
  356. CRYPT_NO_SALT = $00000010;
  357. {$EXTERNALSYM CRYPT_NO_SALT}
  358. CRYPT_PREGEN = $00000040;
  359. {$EXTERNALSYM CRYPT_PREGEN}
  360. CRYPT_RECIPIENT = $00000010;
  361. {$EXTERNALSYM CRYPT_RECIPIENT}
  362. CRYPT_INITIATOR = $00000040;
  363. {$EXTERNALSYM CRYPT_INITIATOR}
  364. CRYPT_ONLINE = $00000080;
  365. {$EXTERNALSYM CRYPT_ONLINE}
  366. CRYPT_SF = $00000100;
  367. {$EXTERNALSYM CRYPT_SF}
  368. CRYPT_CREATE_IV = $00000200;
  369. {$EXTERNALSYM CRYPT_CREATE_IV}
  370. CRYPT_KEK = $00000400;
  371. {$EXTERNALSYM CRYPT_KEK}
  372. CRYPT_DATA_KEY = $00000800;
  373. {$EXTERNALSYM CRYPT_DATA_KEY}
  374. CRYPT_VOLATILE = $00001000;
  375. {$EXTERNALSYM CRYPT_VOLATILE}
  376. CRYPT_SGCKEY = $00002000;
  377. {$EXTERNALSYM CRYPT_SGCKEY}
  378. RSA1024BIT_KEY = $04000000;
  379. {$EXTERNALSYM RSA1024BIT_KEY}
  380. // dwFlags definitions for CryptDeriveKey
  381. CRYPT_SERVER = $00000400;
  382. {$EXTERNALSYM CRYPT_SERVER}
  383. KEY_LENGTH_MASK = DWORD($FFFF0000);
  384. {$EXTERNALSYM KEY_LENGTH_MASK}
  385. // dwFlag definitions for CryptExportKey
  386. CRYPT_Y_ONLY = $00000001;
  387. {$EXTERNALSYM CRYPT_Y_ONLY}
  388. CRYPT_SSL2_FALLBACK = $00000002;
  389. {$EXTERNALSYM CRYPT_SSL2_FALLBACK}
  390. CRYPT_DESTROYKEY = $00000004;
  391. {$EXTERNALSYM CRYPT_DESTROYKEY}
  392. CRYPT_OAEP = $00000040; // used with RSA encryptions/decryptions
  393. // CryptExportKey, CryptImportKey,
  394. // CryptEncrypt and CryptDecrypt
  395. {$EXTERNALSYM CRYPT_OAEP}
  396. CRYPT_BLOB_VER3 = $00000080; // export version 3 of a blob type
  397. {$EXTERNALSYM CRYPT_BLOB_VER3}
  398. // dwFlags definitions for CryptCreateHash
  399. CRYPT_SECRETDIGEST = $00000001;
  400. {$EXTERNALSYM CRYPT_SECRETDIGEST}
  401. // dwFlags definitions for CryptHashSessionKey
  402. CRYPT_LITTLE_ENDIAN = $00000001;
  403. {$EXTERNALSYM CRYPT_LITTLE_ENDIAN}
  404. // dwFlags definitions for CryptSignHash and CryptVerifySignature
  405. CRYPT_NOHASHOID = $00000001;
  406. {$EXTERNALSYM CRYPT_NOHASHOID}
  407. CRYPT_TYPE2_FORMAT = $00000002;
  408. {$EXTERNALSYM CRYPT_TYPE2_FORMAT}
  409. CRYPT_X931_FORMAT = $00000004;
  410. {$EXTERNALSYM CRYPT_X931_FORMAT}
  411. // dwFlag definitions for CryptSetProviderEx and CryptGetDefaultProvider
  412. CRYPT_MACHINE_DEFAULT = $00000001;
  413. {$EXTERNALSYM CRYPT_MACHINE_DEFAULT}
  414. CRYPT_USER_DEFAULT = $00000002;
  415. {$EXTERNALSYM CRYPT_USER_DEFAULT}
  416. CRYPT_DELETE_DEFAULT = $00000004;
  417. {$EXTERNALSYM CRYPT_DELETE_DEFAULT}
  418. // exported key blob definitions
  419. SIMPLEBLOB = $1;
  420. {$EXTERNALSYM SIMPLEBLOB}
  421. PUBLICKEYBLOB = $6;
  422. {$EXTERNALSYM PUBLICKEYBLOB}
  423. PRIVATEKEYBLOB = $7;
  424. {$EXTERNALSYM PRIVATEKEYBLOB}
  425. PLAINTEXTKEYBLOB = $8;
  426. {$EXTERNALSYM PLAINTEXTKEYBLOB}
  427. OPAQUEKEYBLOB = $9;
  428. {$EXTERNALSYM OPAQUEKEYBLOB}
  429. PUBLICKEYBLOBEX = $A;
  430. {$EXTERNALSYM PUBLICKEYBLOBEX}
  431. SYMMETRICWRAPKEYBLOB = $B;
  432. {$EXTERNALSYM SYMMETRICWRAPKEYBLOB}
  433. AT_KEYEXCHANGE = 1;
  434. {$EXTERNALSYM AT_KEYEXCHANGE}
  435. AT_SIGNATURE = 2;
  436. {$EXTERNALSYM AT_SIGNATURE}
  437. CRYPT_USERDATA = 1;
  438. {$EXTERNALSYM CRYPT_USERDATA}
  439. // dwParam
  440. KP_IV = 1; // Initialization vector
  441. {$EXTERNALSYM KP_IV}
  442. KP_SALT = 2; // Salt value
  443. {$EXTERNALSYM KP_SALT}
  444. KP_PADDING = 3; // Padding values
  445. {$EXTERNALSYM KP_PADDING}
  446. KP_MODE = 4; // Mode of the cipher
  447. {$EXTERNALSYM KP_MODE}
  448. KP_MODE_BITS = 5; // Number of bits to feedback
  449. {$EXTERNALSYM KP_MODE_BITS}
  450. KP_PERMISSIONS = 6; // Key permissions DWORD
  451. {$EXTERNALSYM KP_PERMISSIONS}
  452. KP_ALGID = 7; // Key algorithm
  453. {$EXTERNALSYM KP_ALGID}
  454. KP_BLOCKLEN = 8; // Block size of the cipher
  455. {$EXTERNALSYM KP_BLOCKLEN}
  456. KP_KEYLEN = 9; // Length of key in bits
  457. {$EXTERNALSYM KP_KEYLEN}
  458. KP_SALT_EX = 10; // Length of salt in bytes
  459. {$EXTERNALSYM KP_SALT_EX}
  460. KP_P = 11; // DSS/Diffie-Hellman P value
  461. {$EXTERNALSYM KP_P}
  462. KP_G = 12; // DSS/Diffie-Hellman G value
  463. {$EXTERNALSYM KP_G}
  464. KP_Q = 13; // DSS Q value
  465. {$EXTERNALSYM KP_Q}
  466. KP_X = 14; // Diffie-Hellman X value
  467. {$EXTERNALSYM KP_X}
  468. KP_Y = 15; // Y value
  469. {$EXTERNALSYM KP_Y}
  470. KP_RA = 16; // Fortezza RA value
  471. {$EXTERNALSYM KP_RA}
  472. KP_RB = 17; // Fortezza RB value
  473. {$EXTERNALSYM KP_RB}
  474. KP_INFO = 18; // for putting information into an RSA envelope
  475. {$EXTERNALSYM KP_INFO}
  476. KP_EFFECTIVE_KEYLEN = 19; // setting and getting RC2 effective key length
  477. {$EXTERNALSYM KP_EFFECTIVE_KEYLEN}
  478. KP_SCHANNEL_ALG = 20; // for setting the Secure Channel algorithms
  479. {$EXTERNALSYM KP_SCHANNEL_ALG}
  480. KP_CLIENT_RANDOM = 21; // for setting the Secure Channel client random data
  481. {$EXTERNALSYM KP_CLIENT_RANDOM}
  482. KP_SERVER_RANDOM = 22; // for setting the Secure Channel server random data
  483. {$EXTERNALSYM KP_SERVER_RANDOM}
  484. KP_RP = 23;
  485. {$EXTERNALSYM KP_RP}
  486. KP_PRECOMP_MD5 = 24;
  487. {$EXTERNALSYM KP_PRECOMP_MD5}
  488. KP_PRECOMP_SHA = 25;
  489. {$EXTERNALSYM KP_PRECOMP_SHA}
  490. KP_CERTIFICATE = 26; // for setting Secure Channel certificate data (PCT1)
  491. {$EXTERNALSYM KP_CERTIFICATE}
  492. KP_CLEAR_KEY = 27; // for setting Secure Channel clear key data (PCT1)
  493. {$EXTERNALSYM KP_CLEAR_KEY}
  494. KP_PUB_EX_LEN = 28;
  495. {$EXTERNALSYM KP_PUB_EX_LEN}
  496. KP_PUB_EX_VAL = 29;
  497. {$EXTERNALSYM KP_PUB_EX_VAL}
  498. KP_KEYVAL = 30;
  499. {$EXTERNALSYM KP_KEYVAL}
  500. KP_ADMIN_PIN = 31;
  501. {$EXTERNALSYM KP_ADMIN_PIN}
  502. KP_KEYEXCHANGE_PIN = 32;
  503. {$EXTERNALSYM KP_KEYEXCHANGE_PIN}
  504. KP_SIGNATURE_PIN = 33;
  505. {$EXTERNALSYM KP_SIGNATURE_PIN}
  506. KP_PREHASH = 34;
  507. {$EXTERNALSYM KP_PREHASH}
  508. KP_OAEP_PARAMS = 36; // for setting OAEP params on RSA keys
  509. {$EXTERNALSYM KP_OAEP_PARAMS}
  510. KP_CMS_KEY_INFO = 37;
  511. {$EXTERNALSYM KP_CMS_KEY_INFO}
  512. KP_CMS_DH_KEY_INFO = 38;
  513. {$EXTERNALSYM KP_CMS_DH_KEY_INFO}
  514. KP_PUB_PARAMS = 39; // for setting public parameters
  515. {$EXTERNALSYM KP_PUB_PARAMS}
  516. KP_VERIFY_PARAMS = 40; // for verifying DSA and DH parameters
  517. {$EXTERNALSYM KP_VERIFY_PARAMS}
  518. KP_HIGHEST_VERSION = 41; // for TLS protocol version setting
  519. {$EXTERNALSYM KP_HIGHEST_VERSION}
  520. // KP_PADDING
  521. PKCS5_PADDING = 1; // PKCS 5 (sec 6.2) padding method
  522. {$EXTERNALSYM PKCS5_PADDING}
  523. RANDOM_PADDING = 2;
  524. {$EXTERNALSYM RANDOM_PADDING}
  525. ZERO_PADDING = 3;
  526. {$EXTERNALSYM ZERO_PADDING}
  527. // KP_MODE
  528. CRYPT_MODE_CBC = 1; // Cipher block chaining
  529. {$EXTERNALSYM CRYPT_MODE_CBC}
  530. CRYPT_MODE_ECB = 2; // Electronic code book
  531. {$EXTERNALSYM CRYPT_MODE_ECB}
  532. CRYPT_MODE_OFB = 3; // Output feedback mode
  533. {$EXTERNALSYM CRYPT_MODE_OFB}
  534. CRYPT_MODE_CFB = 4; // Cipher feedback mode
  535. {$EXTERNALSYM CRYPT_MODE_CFB}
  536. CRYPT_MODE_CTS = 5; // Ciphertext stealing mode
  537. {$EXTERNALSYM CRYPT_MODE_CTS}
  538. // KP_PERMISSIONS
  539. CRYPT_ENCRYPT = $0001; // Allow encryption
  540. {$EXTERNALSYM CRYPT_ENCRYPT}
  541. CRYPT_DECRYPT = $0002; // Allow decryption
  542. {$EXTERNALSYM CRYPT_DECRYPT}
  543. CRYPT_EXPORT = $0004; // Allow key to be exported
  544. {$EXTERNALSYM CRYPT_EXPORT}
  545. CRYPT_READ = $0008; // Allow parameters to be read
  546. {$EXTERNALSYM CRYPT_READ}
  547. CRYPT_WRITE = $0010; // Allow parameters to be set
  548. {$EXTERNALSYM CRYPT_WRITE}
  549. CRYPT_MAC = $0020; // Allow MACs to be used with key
  550. {$EXTERNALSYM CRYPT_MAC}
  551. CRYPT_EXPORT_KEY = $0040; // Allow key to be used for exporting keys
  552. {$EXTERNALSYM CRYPT_EXPORT_KEY}
  553. CRYPT_IMPORT_KEY = $0080; // Allow key to be used for importing keys
  554. {$EXTERNALSYM CRYPT_IMPORT_KEY}
  555. HP_ALGID = $0001; // Hash algorithm
  556. {$EXTERNALSYM HP_ALGID}
  557. HP_HASHVAL = $0002; // Hash value
  558. {$EXTERNALSYM HP_HASHVAL}
  559. HP_HASHSIZE = $0004; // Hash value size
  560. {$EXTERNALSYM HP_HASHSIZE}
  561. HP_HMAC_INFO = $0005; // information for creating an HMAC
  562. {$EXTERNALSYM HP_HMAC_INFO}
  563. HP_TLS1PRF_LABEL = $0006; // label for TLS1 PRF
  564. {$EXTERNALSYM HP_TLS1PRF_LABEL}
  565. HP_TLS1PRF_SEED = $0007; // seed for TLS1 PRF
  566. {$EXTERNALSYM HP_TLS1PRF_SEED}
  567. CRYPT_FAILED = FALSE;
  568. {$EXTERNALSYM CRYPT_FAILED}
  569. CRYPT_SUCCEED = TRUE;
  570. {$EXTERNALSYM CRYPT_SUCCEED}
  571. function RCRYPT_SUCCEEDED(rt: BOOL): BOOL;
  572. {$EXTERNALSYM RCRYPT_SUCCEEDED}
  573. function RCRYPT_FAILED(rt: BOOL): BOOL;
  574. {$EXTERNALSYM RCRYPT_FAILED}
  575. //
  576. // CryptGetProvParam
  577. //
  578. const
  579. PP_ENUMALGS = 1;
  580. {$EXTERNALSYM PP_ENUMALGS}
  581. PP_ENUMCONTAINERS = 2;
  582. {$EXTERNALSYM PP_ENUMCONTAINERS}
  583. PP_IMPTYPE = 3;
  584. {$EXTERNALSYM PP_IMPTYPE}
  585. PP_NAME = 4;
  586. {$EXTERNALSYM PP_NAME}
  587. PP_VERSION = 5;
  588. {$EXTERNALSYM PP_VERSION}
  589. PP_CONTAINER = 6;
  590. {$EXTERNALSYM PP_CONTAINER}
  591. PP_CHANGE_PASSWORD = 7;
  592. {$EXTERNALSYM PP_CHANGE_PASSWORD}
  593. PP_KEYSET_SEC_DESCR = 8; // get/set security descriptor of keyset
  594. {$EXTERNALSYM PP_KEYSET_SEC_DESCR}
  595. PP_CERTCHAIN = 9; // for retrieving certificates from tokens
  596. {$EXTERNALSYM PP_CERTCHAIN}
  597. PP_KEY_TYPE_SUBTYPE = 10;
  598. {$EXTERNALSYM PP_KEY_TYPE_SUBTYPE}
  599. PP_PROVTYPE = 16;
  600. {$EXTERNALSYM PP_PROVTYPE}
  601. PP_KEYSTORAGE = 17;
  602. {$EXTERNALSYM PP_KEYSTORAGE}
  603. PP_APPLI_CERT = 18;
  604. {$EXTERNALSYM PP_APPLI_CERT}
  605. PP_SYM_KEYSIZE = 19;
  606. {$EXTERNALSYM PP_SYM_KEYSIZE}
  607. PP_SESSION_KEYSIZE = 20;
  608. {$EXTERNALSYM PP_SESSION_KEYSIZE}
  609. PP_UI_PROMPT = 21;
  610. {$EXTERNALSYM PP_UI_PROMPT}
  611. PP_ENUMALGS_EX = 22;
  612. {$EXTERNALSYM PP_ENUMALGS_EX}
  613. PP_ENUMMANDROOTS = 25;
  614. {$EXTERNALSYM PP_ENUMMANDROOTS}
  615. PP_ENUMELECTROOTS = 26;
  616. {$EXTERNALSYM PP_ENUMELECTROOTS}
  617. PP_KEYSET_TYPE = 27;
  618. {$EXTERNALSYM PP_KEYSET_TYPE}
  619. PP_ADMIN_PIN = 31;
  620. {$EXTERNALSYM PP_ADMIN_PIN}
  621. PP_KEYEXCHANGE_PIN = 32;
  622. {$EXTERNALSYM PP_KEYEXCHANGE_PIN}
  623. PP_SIGNATURE_PIN = 33;
  624. {$EXTERNALSYM PP_SIGNATURE_PIN}
  625. PP_SIG_KEYSIZE_INC = 34;
  626. {$EXTERNALSYM PP_SIG_KEYSIZE_INC}
  627. PP_KEYX_KEYSIZE_INC = 35;
  628. {$EXTERNALSYM PP_KEYX_KEYSIZE_INC}
  629. PP_UNIQUE_CONTAINER = 36;
  630. {$EXTERNALSYM PP_UNIQUE_CONTAINER}
  631. PP_SGC_INFO = 37;
  632. {$EXTERNALSYM PP_SGC_INFO}
  633. PP_USE_HARDWARE_RNG = 38;
  634. {$EXTERNALSYM PP_USE_HARDWARE_RNG}
  635. PP_KEYSPEC = 39;
  636. {$EXTERNALSYM PP_KEYSPEC}
  637. PP_ENUMEX_SIGNING_PROT = 40;
  638. {$EXTERNALSYM PP_ENUMEX_SIGNING_PROT}
  639. CRYPT_FIRST = 1;
  640. {$EXTERNALSYM CRYPT_FIRST}
  641. CRYPT_NEXT = 2;
  642. {$EXTERNALSYM CRYPT_NEXT}
  643. CRYPT_SGC_ENUM = 4;
  644. {$EXTERNALSYM CRYPT_SGC_ENUM}
  645. CRYPT_IMPL_HARDWARE = 1;
  646. {$EXTERNALSYM CRYPT_IMPL_HARDWARE}
  647. CRYPT_IMPL_SOFTWARE = 2;
  648. {$EXTERNALSYM CRYPT_IMPL_SOFTWARE}
  649. CRYPT_IMPL_MIXED = 3;
  650. {$EXTERNALSYM CRYPT_IMPL_MIXED}
  651. CRYPT_IMPL_UNKNOWN = 4;
  652. {$EXTERNALSYM CRYPT_IMPL_UNKNOWN}
  653. CRYPT_IMPL_REMOVABLE = 8;
  654. {$EXTERNALSYM CRYPT_IMPL_REMOVABLE}
  655. // key storage flags
  656. CRYPT_SEC_DESCR = $00000001;
  657. {$EXTERNALSYM CRYPT_SEC_DESCR}
  658. CRYPT_PSTORE = $00000002;
  659. {$EXTERNALSYM CRYPT_PSTORE}
  660. CRYPT_UI_PROMPT = $00000004;
  661. {$EXTERNALSYM CRYPT_UI_PROMPT}
  662. // protocol flags
  663. CRYPT_FLAG_PCT1 = $0001;
  664. {$EXTERNALSYM CRYPT_FLAG_PCT1}
  665. CRYPT_FLAG_SSL2 = $0002;
  666. {$EXTERNALSYM CRYPT_FLAG_SSL2}
  667. CRYPT_FLAG_SSL3 = $0004;
  668. {$EXTERNALSYM CRYPT_FLAG_SSL3}
  669. CRYPT_FLAG_TLS1 = $0008;
  670. {$EXTERNALSYM CRYPT_FLAG_TLS1}
  671. CRYPT_FLAG_IPSEC = $0010;
  672. {$EXTERNALSYM CRYPT_FLAG_IPSEC}
  673. CRYPT_FLAG_SIGNING = $0020;
  674. {$EXTERNALSYM CRYPT_FLAG_SIGNING}
  675. // SGC flags
  676. CRYPT_SGC = $0001;
  677. {$EXTERNALSYM CRYPT_SGC}
  678. CRYPT_FASTSGC = $0002;
  679. {$EXTERNALSYM CRYPT_FASTSGC}
  680. //
  681. // CryptSetProvParam
  682. //
  683. PP_CLIENT_HWND = 1;
  684. {$EXTERNALSYM PP_CLIENT_HWND}
  685. PP_CONTEXT_INFO = 11;
  686. {$EXTERNALSYM PP_CONTEXT_INFO}
  687. PP_KEYEXCHANGE_KEYSIZE = 12;
  688. {$EXTERNALSYM PP_KEYEXCHANGE_KEYSIZE}
  689. PP_SIGNATURE_KEYSIZE = 13;
  690. {$EXTERNALSYM PP_SIGNATURE_KEYSIZE}
  691. PP_KEYEXCHANGE_ALG = 14;
  692. {$EXTERNALSYM PP_KEYEXCHANGE_ALG}
  693. PP_SIGNATURE_ALG = 15;
  694. {$EXTERNALSYM PP_SIGNATURE_ALG}
  695. PP_DELETEKEY = 24;
  696. {$EXTERNALSYM PP_DELETEKEY}
  697. PROV_RSA_FULL = 1;
  698. {$EXTERNALSYM PROV_RSA_FULL}
  699. PROV_RSA_SIG = 2;
  700. {$EXTERNALSYM PROV_RSA_SIG}
  701. PROV_DSS = 3;
  702. {$EXTERNALSYM PROV_DSS}
  703. PROV_FORTEZZA = 4;
  704. {$EXTERNALSYM PROV_FORTEZZA}
  705. PROV_MS_EXCHANGE = 5;
  706. {$EXTERNALSYM PROV_MS_EXCHANGE}
  707. PROV_SSL = 6;
  708. {$EXTERNALSYM PROV_SSL}
  709. PROV_RSA_SCHANNEL = 12;
  710. {$EXTERNALSYM PROV_RSA_SCHANNEL}
  711. PROV_DSS_DH = 13;
  712. {$EXTERNALSYM PROV_DSS_DH}
  713. PROV_EC_ECDSA_SIG = 14;
  714. {$EXTERNALSYM PROV_EC_ECDSA_SIG}
  715. PROV_EC_ECNRA_SIG = 15;
  716. {$EXTERNALSYM PROV_EC_ECNRA_SIG}
  717. PROV_EC_ECDSA_FULL = 16;
  718. {$EXTERNALSYM PROV_EC_ECDSA_FULL}
  719. PROV_EC_ECNRA_FULL = 17;
  720. {$EXTERNALSYM PROV_EC_ECNRA_FULL}
  721. PROV_DH_SCHANNEL = 18;
  722. {$EXTERNALSYM PROV_DH_SCHANNEL}
  723. PROV_SPYRUS_LYNKS = 20;
  724. {$EXTERNALSYM PROV_SPYRUS_LYNKS}
  725. PROV_RNG = 21;
  726. {$EXTERNALSYM PROV_RNG}
  727. PROV_INTEL_SEC = 22;
  728. {$EXTERNALSYM PROV_INTEL_SEC}
  729. //
  730. // STT defined Providers
  731. //
  732. PROV_STT_MER = 7;
  733. {$EXTERNALSYM PROV_STT_MER}
  734. PROV_STT_ACQ = 8;
  735. {$EXTERNALSYM PROV_STT_ACQ}
  736. PROV_STT_BRND = 9;
  737. {$EXTERNALSYM PROV_STT_BRND}
  738. PROV_STT_ROOT = 10;
  739. {$EXTERNALSYM PROV_STT_ROOT}
  740. PROV_STT_ISS = 11;
  741. {$EXTERNALSYM PROV_STT_ISS}
  742. //
  743. // Provider friendly names
  744. //
  745. MS_DEF_PROV_A = 'Microsoft Base Cryptographic Provider v1.0';
  746. {$EXTERNALSYM MS_DEF_PROV_A}
  747. MS_DEF_PROV_W = 'Microsoft Base Cryptographic Provider v1.0';
  748. {$EXTERNALSYM MS_DEF_PROV_W}
  749. {$IFDEF UNICODE}
  750. MS_DEF_PROV = MS_DEF_PROV_W;
  751. {$EXTERNALSYM MS_DEF_PROV}
  752. {$ELSE}
  753. MS_DEF_PROV = MS_DEF_PROV_A;
  754. {$EXTERNALSYM MS_DEF_PROV}
  755. {$ENDIF UNICODE}
  756. MS_ENHANCED_PROV_A = 'Microsoft Enhanced Cryptographic Provider v1.0';
  757. {$EXTERNALSYM MS_ENHANCED_PROV_A}
  758. MS_ENHANCED_PROV_W = 'Microsoft Enhanced Cryptographic Provider v1.0';
  759. {$EXTERNALSYM MS_ENHANCED_PROV_W}
  760. {$IFDEF UNICODE}
  761. MS_ENHANCED_PROV = MS_ENHANCED_PROV_W;
  762. {$EXTERNALSYM MS_ENHANCED_PROV}
  763. {$ELSE}
  764. MS_ENHANCED_PROV = MS_ENHANCED_PROV_A;
  765. {$EXTERNALSYM MS_ENHANCED_PROV}
  766. {$ENDIF UNICODE}
  767. MS_STRONG_PROV_A = 'Microsoft Strong Cryptographic Provider';
  768. {$EXTERNALSYM MS_STRONG_PROV_A}
  769. MS_STRONG_PROV_W = 'Microsoft Strong Cryptographic Provider';
  770. {$EXTERNALSYM MS_STRONG_PROV_W}
  771. {$IFDEF UNICODE}
  772. MS_STRONG_PROV = MS_STRONG_PROV_W;
  773. {$EXTERNALSYM MS_STRONG_PROV}
  774. {$ELSE}
  775. MS_STRONG_PROV = MS_STRONG_PROV_A;
  776. {$EXTERNALSYM MS_STRONG_PROV}
  777. {$ENDIF UNICODE}
  778. MS_DEF_RSA_SIG_PROV_A = 'Microsoft RSA Signature Cryptographic Provider';
  779. {$EXTERNALSYM MS_DEF_RSA_SIG_PROV_A}
  780. MS_DEF_RSA_SIG_PROV_W = 'Microsoft RSA Signature Cryptographic Provider';
  781. {$EXTERNALSYM MS_DEF_RSA_SIG_PROV_W}
  782. {$IFDEF UNICODE}
  783. MS_DEF_RSA_SIG_PROV = MS_DEF_RSA_SIG_PROV_W;
  784. {$EXTERNALSYM MS_DEF_RSA_SIG_PROV}
  785. {$ELSE}
  786. MS_DEF_RSA_SIG_PROV = MS_DEF_RSA_SIG_PROV_A;
  787. {$EXTERNALSYM MS_DEF_RSA_SIG_PROV}
  788. {$ENDIF UNICODE}
  789. MS_DEF_RSA_SCHANNEL_PROV_A = 'Microsoft RSA SChannel Cryptographic Provider';
  790. {$EXTERNALSYM MS_DEF_RSA_SCHANNEL_PROV_A}
  791. MS_DEF_RSA_SCHANNEL_PROV_W = 'Microsoft RSA SChannel Cryptographic Provider';
  792. {$EXTERNALSYM MS_DEF_RSA_SCHANNEL_PROV_W}
  793. {$IFDEF UNICODE}
  794. MS_DEF_RSA_SCHANNEL_PROV = MS_DEF_RSA_SCHANNEL_PROV_W;
  795. {$EXTERNALSYM MS_DEF_RSA_SCHANNEL_PROV}
  796. {$ELSE}
  797. MS_DEF_RSA_SCHANNEL_PROV = MS_DEF_RSA_SCHANNEL_PROV_A;
  798. {$EXTERNALSYM MS_DEF_RSA_SCHANNEL_PROV}
  799. {$ENDIF UNICODE}
  800. MS_DEF_DSS_PROV_A = 'Microsoft Base DSS Cryptographic Provider';
  801. {$EXTERNALSYM MS_DEF_DSS_PROV_A}
  802. MS_DEF_DSS_PROV_W = 'Microsoft Base DSS Cryptographic Provider';
  803. {$EXTERNALSYM MS_DEF_DSS_PROV_W}
  804. {$IFDEF UNICODE}
  805. MS_DEF_DSS_PROV = MS_DEF_DSS_PROV_W;
  806. {$EXTERNALSYM MS_DEF_DSS_PROV}
  807. {$ELSE}
  808. MS_DEF_DSS_PROV = MS_DEF_DSS_PROV_A;
  809. {$EXTERNALSYM MS_DEF_DSS_PROV}
  810. {$ENDIF UNICODE}
  811. MS_DEF_DSS_DH_PROV_A = 'Microsoft Base DSS and Diffie-Hellman Cryptographic Provider';
  812. {$EXTERNALSYM MS_DEF_DSS_DH_PROV_A}
  813. MS_DEF_DSS_DH_PROV_W = 'Microsoft Base DSS and Diffie-Hellman Cryptographic Provider';
  814. {$EXTERNALSYM MS_DEF_DSS_DH_PROV_W}
  815. {$IFDEF UNICODE}
  816. MS_DEF_DSS_DH_PROV = MS_DEF_DSS_DH_PROV_W;
  817. {$EXTERNALSYM MS_DEF_DSS_DH_PROV}
  818. {$ELSE}
  819. MS_DEF_DSS_DH_PROV = MS_DEF_DSS_DH_PROV_A;
  820. {$EXTERNALSYM MS_DEF_DSS_DH_PROV}
  821. {$ENDIF UNICODE}
  822. MS_ENH_DSS_DH_PROV_A = 'Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider';
  823. {$EXTERNALSYM MS_ENH_DSS_DH_PROV_A}
  824. MS_ENH_DSS_DH_PROV_W = 'Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider';
  825. {$EXTERNALSYM MS_ENH_DSS_DH_PROV_W}
  826. {$IFDEF UNICODE}
  827. MS_ENH_DSS_DH_PROV = MS_ENH_DSS_DH_PROV_W;
  828. {$EXTERNALSYM MS_ENH_DSS_DH_PROV}
  829. {$ELSE}
  830. MS_ENH_DSS_DH_PROV = MS_ENH_DSS_DH_PROV_A;
  831. {$EXTERNALSYM MS_ENH_DSS_DH_PROV}
  832. {$ENDIF UNICODE}
  833. MS_DEF_DH_SCHANNEL_PROV_A = 'Microsoft DH SChannel Cryptographic Provider';
  834. {$EXTERNALSYM MS_DEF_DH_SCHANNEL_PROV_A}
  835. MS_DEF_DH_SCHANNEL_PROV_W = 'Microsoft DH SChannel Cryptographic Provider';
  836. {$EXTERNALSYM MS_DEF_DH_SCHANNEL_PROV_W}
  837. {$IFDEF UNICODE}
  838. MS_DEF_DH_SCHANNEL_PROV = MS_DEF_DH_SCHANNEL_PROV_W;
  839. {$EXTERNALSYM MS_DEF_DH_SCHANNEL_PROV}
  840. {$ELSE}
  841. MS_DEF_DH_SCHANNEL_PROV = MS_DEF_DH_SCHANNEL_PROV_A;
  842. {$EXTERNALSYM MS_DEF_DH_SCHANNEL_PROV}
  843. {$ENDIF UNICODE}
  844. MS_SCARD_PROV_A = 'Microsoft Base Smart Card Crypto Provider';
  845. {$EXTERNALSYM MS_SCARD_PROV_A}
  846. MS_SCARD_PROV_W = 'Microsoft Base Smart Card Crypto Provider';
  847. {$EXTERNALSYM MS_SCARD_PROV_W}
  848. {$IFDEF UNICODE}
  849. MS_SCARD_PROV = MS_SCARD_PROV_W;
  850. {$EXTERNALSYM MS_SCARD_PROV}
  851. {$ELSE}
  852. MS_SCARD_PROV = MS_SCARD_PROV_A;
  853. {$EXTERNALSYM MS_SCARD_PROV}
  854. {$ENDIF UNICODE}
  855. MAXUIDLEN = 64;
  856. {$EXTERNALSYM MAXUIDLEN}
  857. // Exponentiation Offload Reg Location
  858. EXPO_OFFLOAD_REG_VALUE = 'ExpoOffload';
  859. {$EXTERNALSYM EXPO_OFFLOAD_REG_VALUE}
  860. EXPO_OFFLOAD_FUNC_NAME = 'OffloadModExpo';
  861. {$EXTERNALSYM EXPO_OFFLOAD_FUNC_NAME}
  862. CUR_BLOB_VERSION = 2;
  863. {$EXTERNALSYM CUR_BLOB_VERSION}
  864. // structure for use with CryptSetKeyParam for CMS keys
  865. // DO NOT USE THIS STRUCTURE!!!!!
  866. type
  867. PCMS_KEY_INFO = ^CMS_KEY_INFO;
  868. {$EXTERNALSYM PCMS_KEY_INFO}
  869. _CMS_KEY_INFO = record
  870. dwVersion: DWORD; // sizeof(CMS_KEY_INFO)
  871. Algid: ALG_ID; // algorithmm id for the key to be converted
  872. pbOID: LPBYTE; // pointer to OID to hash in with Z
  873. cbOID: DWORD; // length of OID to hash in with Z
  874. end;
  875. {$EXTERNALSYM _CMS_KEY_INFO}
  876. CMS_KEY_INFO = _CMS_KEY_INFO;
  877. {$EXTERNALSYM CMS_KEY_INFO}
  878. TCmsKeyInfo = CMS_KEY_INFO;
  879. PCmsKeyInfo = PCMS_KEY_INFO;
  880. // structure for use with CryptSetHashParam with CALG_HMAC
  881. PHMAC_Info = ^HMAC_Info;
  882. {$EXTERNALSYM PHMAC_Info}
  883. _HMAC_Info = record
  884. HashAlgid: ALG_ID;
  885. pbInnerString: LPBYTE;
  886. cbInnerString: DWORD;
  887. pbOuterString: LPBYTE;
  888. cbOuterString: DWORD;
  889. end;
  890. {$EXTERNALSYM _HMAC_Info}
  891. HMAC_Info = _HMAC_Info;
  892. {$EXTERNALSYM HMAC_Info}
  893. THMacInfo = HMAC_Info;
  894. PHMacInfo = PHMAC_Info;
  895. // structure for use with CryptSetKeyParam with KP_SCHANNEL_ALG
  896. PSCHANNEL_ALG = ^SCHANNEL_ALG;
  897. {$EXTERNALSYM PSCHANNEL_ALG}
  898. _SCHANNEL_ALG = record
  899. dwUse: DWORD;
  900. Algid: ALG_ID;
  901. cBits: DWORD;
  902. dwFlags: DWORD;
  903. dwReserved: DWORD;
  904. end;
  905. {$EXTERNALSYM _SCHANNEL_ALG}
  906. SCHANNEL_ALG = _SCHANNEL_ALG;
  907. {$EXTERNALSYM SCHANNEL_ALG}
  908. TSChannelAlg = SCHANNEL_ALG;
  909. PSChannelAlg = PSCHANNEL_ALG;
  910. // uses of algortihms for SCHANNEL_ALG structure
  911. const
  912. SCHANNEL_MAC_KEY = $00000000;
  913. {$EXTERNALSYM SCHANNEL_MAC_KEY}
  914. SCHANNEL_ENC_KEY = $00000001;
  915. {$EXTERNALSYM SCHANNEL_ENC_KEY}
  916. // uses of dwFlags SCHANNEL_ALG structure
  917. INTERNATIONAL_USAGE = $00000001;
  918. {$EXTERNALSYM INTERNATIONAL_USAGE}
  919. type
  920. PPROV_ENUMALGS = ^PROV_ENUMALGS;
  921. {$NODEFINE PPROV_ENUMALGS}
  922. _PROV_ENUMALGS = record
  923. aiAlgid: ALG_ID;
  924. dwBitLen: DWORD;
  925. dwNameLen: DWORD;
  926. szName: array [0..19] of CHAR;
  927. end;
  928. {$EXTERNALSYM _PROV_ENUMALGS}
  929. PROV_ENUMALGS = _PROV_ENUMALGS;
  930. {$EXTERNALSYM PROV_ENUMALGS}
  931. TProvEnumAlgs = PROV_ENUMALGS;
  932. PProvEnumAlgs = PPROV_ENUMALGS;
  933. PPROV_ENUMALGS_EX = ^PROV_ENUMALGS_EX;
  934. {$NODEFINE PPROV_ENUMALGS_EX}
  935. _PROV_ENUMALGS_EX = record
  936. aiAlgid: ALG_ID;
  937. dwDefaultLen: DWORD;
  938. dwMinLen: DWORD;
  939. dwMaxLen: DWORD;
  940. dwProtocols: DWORD;
  941. dwNameLen: DWORD;
  942. szName: array [0..19] of CHAR;
  943. dwLongNameLen: DWORD;
  944. szLongName: array [0..39] of CHAR;
  945. end;
  946. {$EXTERNALSYM _PROV_ENUMALGS_EX}
  947. PROV_ENUMALGS_EX = _PROV_ENUMALGS_EX;
  948. {$EXTERNALSYM PROV_ENUMALGS_EX}
  949. TProvEnumAlgsEx = PROV_ENUMALGS_EX;
  950. PProvEnumAlgsEx = PPROV_ENUMALGS_EX;
  951. PPUBLICKEYSTRUC = ^PUBLICKEYSTRUC;
  952. {$NODEFINE PPUBLICKEYSTRUC}
  953. _PUBLICKEYSTRUC = record
  954. bType: BYTE;
  955. bVersion: BYTE;
  956. reserved: WORD;
  957. aiKeyAlg: ALG_ID;
  958. end;
  959. {$EXTERNALSYM _PUBLICKEYSTRUC}
  960. PUBLICKEYSTRUC = _PUBLICKEYSTRUC;
  961. {$EXTERNALSYM PUBLICKEYSTRUC}
  962. BLOBHEADER = _PUBLICKEYSTRUC;
  963. {$EXTERNALSYM BLOBHEADER}
  964. TPublicKeyStruc = PUBLICKEYSTRUC;
  965. PRSAPUBKEY = ^RSAPUBKEY;
  966. {$NODEFINE PRSAPUBKEY}
  967. _RSAPUBKEY = record
  968. magic: DWORD; // Has to be RSA1
  969. bitlen: DWORD; // # of bits in modulus
  970. pubexp: DWORD; // public exponent
  971. // Modulus data follows
  972. end;
  973. {$EXTERNALSYM _RSAPUBKEY}
  974. RSAPUBKEY = _RSAPUBKEY;
  975. {$EXTERNALSYM RSAPUBKEY}
  976. TRsaPubKey = RSAPUBKEY;
  977. _PUBKEY = record
  978. magic: DWORD;
  979. bitlen: DWORD; // # of bits in modulus
  980. end;
  981. {$EXTERNALSYM _PUBKEY}
  982. DHPUBKEY = _PUBKEY;
  983. {$EXTERNALSYM DHPUBKEY}
  984. DSSPUBKEY = _PUBKEY;
  985. {$EXTERNALSYM DSSPUBKEY}
  986. KEAPUBKEY = _PUBKEY;
  987. {$EXTERNALSYM KEAPUBKEY}
  988. TEKPUBKEY = _PUBKEY;
  989. {$EXTERNALSYM TEKPUBKEY}
  990. PDSSSEED = ^DSSSEED;
  991. {$NODEFINE PDSSSEED}
  992. _DSSSEED = record
  993. counter: DWORD;
  994. seed: array [0..19] of BYTE;
  995. end;
  996. {$EXTERNALSYM _DSSSEED}
  997. DSSSEED = _DSSSEED;
  998. {$EXTERNALSYM DSSSEED}
  999. TDssSeed = DSSSEED;
  1000. PPUBKEYVER3 = ^PUBKEYVER3;
  1001. {$NODEFINE PPUBKEYVER3}
  1002. _PUBKEYVER3 = record
  1003. magic: DWORD;
  1004. bitlenP: DWORD; // # of bits in prime modulus
  1005. bitlenQ: DWORD; // # of bits in prime q, 0 if not available
  1006. bitlenJ: DWORD; // # of bits in (p-1)/q, 0 if not available
  1007. DSSSeed: DSSSEED;
  1008. end;
  1009. {$EXTERNALSYM _PUBKEYVER3}
  1010. PUBKEYVER3 = _PUBKEYVER3;
  1011. {$EXTERNALSYM PUBKEYVER3}
  1012. DHPUBKEY_VER3 = PUBKEYVER3;
  1013. {$EXTERNALSYM DHPUBKEY_VER3}
  1014. TPubKeyVer3 = PUBKEYVER3;
  1015. PPRIVKEYVER3 = ^DHPRIVKEY_VER3;
  1016. {$NODEFINE PPRIVKEYVER3}
  1017. _PRIVKEYVER3 = record
  1018. magic: DWORD;
  1019. bitlenP: DWORD; // # of bits in prime modulus
  1020. bitlenQ: DWORD; // # of bits in prime q, 0 if not available
  1021. bitlenJ: DWORD; // # of bits in (p-1)/q, 0 if not available
  1022. bitlenX: DWORD; // # of bits in X
  1023. DSSSeed: DSSSEED;
  1024. end;
  1025. {$EXTERNALSYM _PRIVKEYVER3}
  1026. DHPRIVKEY_VER3 = _PRIVKEYVER3;
  1027. {$EXTERNALSYM DHPRIVKEY_VER3}
  1028. DSSPRIVKEY_VER3 = _PRIVKEYVER3;
  1029. {$EXTERNALSYM DSSPRIVKEY_VER3}
  1030. TDssPrivKey3 = DHPRIVKEY_VER3;
  1031. PKEY_TYPE_SUBTYPE = ^KEY_TYPE_SUBTYPE;
  1032. {$EXTERNALSYM PKEY_TYPE_SUBTYPE}
  1033. _KEY_TYPE_SUBTYPE = record
  1034. dwKeySpec: DWORD;
  1035. Type_: GUID;
  1036. Subtype: GUID;
  1037. end;
  1038. {$EXTERNALSYM _KEY_TYPE_SUBTYPE}
  1039. KEY_TYPE_SUBTYPE = _KEY_TYPE_SUBTYPE;
  1040. {$EXTERNALSYM KEY_TYPE_SUBTYPE}
  1041. TKeyTypeSubType = KEY_TYPE_SUBTYPE;
  1042. PKeyTypeSubType = PKEY_TYPE_SUBTYPE;
  1043. PCERT_FORTEZZA_DATA_PROP = ^CERT_FORTEZZA_DATA_PROP;
  1044. {$NODEFINE PCERT_FORTEZZA_DATA_PROP}
  1045. _CERT_FORTEZZA_DATA_PROP = record
  1046. SerialNumber: array [0..7] of Byte;
  1047. CertIndex: Integer;
  1048. CertLabel: array [0..35] of Byte;
  1049. end;
  1050. {$EXTERNALSYM _CERT_FORTEZZA_DATA_PROP}
  1051. CERT_FORTEZZA_DATA_PROP = _CERT_FORTEZZA_DATA_PROP;
  1052. {$EXTERNALSYM CERT_FORTEZZA_DATA_PROP}
  1053. TCertFortezzaDataProp = CERT_FORTEZZA_DATA_PROP;
  1054. PCertFortezzaDataProp = PCERT_FORTEZZA_DATA_PROP;
  1055. //+-------------------------------------------------------------------------
  1056. // CRYPTOAPI BLOB definitions
  1057. //--------------------------------------------------------------------------
  1058. type
  1059. _CRYPTOAPI_BLOB = record
  1060. cbData: DWORD;
  1061. pbData: LPBYTE;
  1062. end;
  1063. {$EXTERNALSYM _CRYPTOAPI_BLOB}
  1064. CRYPT_INTEGER_BLOB = _CRYPTOAPI_BLOB;
  1065. TCryptIntegerBlob = CRYPT_INTEGER_BLOB;
  1066. {$EXTERNALSYM CRYPT_INTEGER_BLOB}
  1067. PCRYPT_INTEGER_BLOB = ^_CRYPTOAPI_BLOB;
  1068. {$EXTERNALSYM PCRYPT_INTEGER_BLOB}
  1069. PCryptIntegerBlob = PCRYPT_INTEGER_BLOB;
  1070. CRYPT_UINT_BLOB = _CRYPTOAPI_BLOB;
  1071. {$EXTERNALSYM CRYPT_UINT_BLOB}
  1072. TCryptUintBlob = CRYPT_UINT_BLOB;
  1073. PCRYPT_UINT_BLOB = ^_CRYPTOAPI_BLOB;
  1074. {$EXTERNALSYM PCRYPT_UINT_BLOB}
  1075. PCryptUintBlob = PCRYPT_UINT_BLOB;
  1076. CRYPT_OBJID_BLOB = _CRYPTOAPI_BLOB;
  1077. {$EXTERNALSYM CRYPT_OBJID_BLOB}
  1078. TCryptObjIdBlob = CRYPT_OBJID_BLOB;
  1079. PCRYPT_OBJID_BLOB = ^_CRYPTOAPI_BLOB;
  1080. {$EXTERNALSYM PCRYPT_OBJID_BLOB}
  1081. PCryptObjIdBlob = PCRYPT_OBJID_BLOB;
  1082. CERT_NAME_BLOB = _CRYPTOAPI_BLOB;
  1083. {$EXTERNALSYM CERT_NAME_BLOB}
  1084. TCertNameBlob = CERT_NAME_BLOB;
  1085. PCERT_NAME_BLOB = ^_CRYPTOAPI_BLOB;
  1086. {$EXTERNALSYM PCERT_NAME_BLOB}
  1087. PCertNameBlob = PCERT_NAME_BLOB;
  1088. CERT_RDN_VALUE_BLOB = _CRYPTOAPI_BLOB;
  1089. {$EXTERNALSYM CERT_RDN_VALUE_BLOB}
  1090. TCertRdnValueBlob = CERT_RDN_VALUE_BLOB;
  1091. PCERT_RDN_VALUE_BLOB = ^_CRYPTOAPI_BLOB;
  1092. {$EXTERNALSYM PCERT_RDN_VALUE_BLOB}
  1093. PCertRdnValueBlob = PCERT_RDN_VALUE_BLOB;
  1094. CERT_BLOB = _CRYPTOAPI_BLOB;
  1095. {$EXTERNALSYM CERT_BLOB}
  1096. TCertBlob = CERT_BLOB;
  1097. PCERT_BLOB = ^_CRYPTOAPI_BLOB;
  1098. {$EXTERNALSYM PCERT_BLOB}
  1099. PCertBlob = PCERT_BLOB;
  1100. CRL_BLOB = _CRYPTOAPI_BLOB;
  1101. {$EXTERNALSYM CRL_BLOB}
  1102. TCrlBlob = CRL_BLOB;
  1103. PCRL_BLOB = ^_CRYPTOAPI_BLOB;
  1104. {$EXTERNALSYM PCRL_BLOB}
  1105. PCrlBlob = PCRL_BLOB;
  1106. DATA_BLOB = _CRYPTOAPI_BLOB;
  1107. {$EXTERNALSYM DATA_BLOB}
  1108. TDataBlob = DATA_BLOB;
  1109. PDATA_BLOB = ^_CRYPTOAPI_BLOB;
  1110. {$EXTERNALSYM PDATA_BLOB}
  1111. PDataBlob = PDATA_BLOB;
  1112. CRYPT_DATA_BLOB = _CRYPTOAPI_BLOB;
  1113. {$EXTERNALSYM CRYPT_DATA_BLOB}
  1114. TCryptDataBlob = CRYPT_DATA_BLOB;
  1115. PCRYPT_DATA_BLOB = ^_CRYPTOAPI_BLOB;
  1116. {$EXTERNALSYM PCRYPT_DATA_BLOB}
  1117. PCryptDataBlob = PCRYPT_DATA_BLOB;
  1118. CRYPT_HASH_BLOB = _CRYPTOAPI_BLOB;
  1119. {$EXTERNALSYM CRYPT_HASH_BLOB}
  1120. TCryptHashBlob = CRYPT_HASH_BLOB;
  1121. PCRYPT_HASH_BLOB = ^_CRYPTOAPI_BLOB;
  1122. {$EXTERNALSYM PCRYPT_HASH_BLOB}
  1123. PCryptHashBlob = PCRYPT_HASH_BLOB;
  1124. CRYPT_DIGEST_BLOB = _CRYPTOAPI_BLOB;
  1125. {$EXTERNALSYM CRYPT_DIGEST_BLOB}
  1126. TCryptDigestBlob = CRYPT_DIGEST_BLOB;
  1127. PCRYPT_DIGEST_BLOB = ^_CRYPTOAPI_BLOB;
  1128. {$EXTERNALSYM PCRYPT_DIGEST_BLOB}
  1129. PCryptDigestBlob = PCRYPT_DIGEST_BLOB;
  1130. CRYPT_DER_BLOB = _CRYPTOAPI_BLOB;
  1131. {$EXTERNALSYM CRYPT_DER_BLOB}
  1132. TCyptDerBlob = CRYPT_DER_BLOB;
  1133. PCRYPT_DER_BLOB = ^_CRYPTOAPI_BLOB;
  1134. {$EXTERNALSYM PCRYPT_DER_BLOB}
  1135. PCyptDerBlob = PCRYPT_DER_BLOB;
  1136. CRYPT_ATTR_BLOB = _CRYPTOAPI_BLOB;
  1137. {$EXTERNALSYM CRYPT_ATTR_BLOB}
  1138. TCryptAttrBlob = CRYPT_ATTR_BLOB;
  1139. PCRYPT_ATTR_BLOB = ^_CRYPTOAPI_BLOB;
  1140. {$EXTERNALSYM PCRYPT_ATTR_BLOB}
  1141. PCryptAttrBlob = PCRYPT_ATTR_BLOB;
  1142. // structure for use with CryptSetKeyParam for CMS keys
  1143. PCMS_DH_KEY_INFO = ^CMS_DH_KEY_INFO;
  1144. {$EXTERNALSYM PCMS_DH_KEY_INFO}
  1145. _CMS_DH_KEY_INFO = record
  1146. dwVersion: DWORD; // sizeof(CMS_DH_KEY_INFO)
  1147. Algid: ALG_ID; // algorithmm id for the key to be converted
  1148. pszContentEncObjId: LPSTR; // pointer to OID to hash in with Z
  1149. PubInfo: CRYPT_DATA_BLOB; // OPTIONAL - public information
  1150. pReserved: Pointer; // reserved - should be NULL
  1151. end;
  1152. {$EXTERNALSYM _CMS_DH_KEY_INFO}
  1153. CMS_DH_KEY_INFO = _CMS_DH_KEY_INFO;
  1154. {$EXTERNALSYM CMS_DH_KEY_INFO}
  1155. TCmsDhKeyInfo = CMS_DH_KEY_INFO;
  1156. PCmsDhKeyInfo = PCMS_DH_KEY_INFO;
  1157. function CryptAcquireContextA(var phProv: HCRYPTPROV; pszContainer: LPCSTR;
  1158. pszProvider: LPCSTR; dwProvType: DWORD; dwFlags: DWORD): BOOL; stdcall;
  1159. {$EXTERNALSYM CryptAcquireContextA}
  1160. function CryptAcquireContextW(var phProv: HCRYPTPROV; pszContainer: LPCWSTR;
  1161. pszProvider: LPCWSTR; dwProvType: DWORD; dwFlags: DWORD): BOOL; stdcall;
  1162. {$EXTERNALSYM CryptAcquireContextW}
  1163. function CryptAcquireContext(var phProv: HCRYPTPROV; pszContainer: LPCTSTR;
  1164. pszProvider: LPCTSTR; dwProvType: DWORD; dwFlags: DWORD): BOOL; stdcall;
  1165. {$EXTERNALSYM CryptAcquireContext}
  1166. function CryptReleaseContext(hProv: HCRYPTPROV; dwFlags: ULONG_PTR): BOOL; stdcall;
  1167. {$EXTERNALSYM CryptReleaseContext}
  1168. function CryptGenKey(hProv: HCRYPTPROV; Algid: ALG_ID; dwFlags: DWORD;
  1169. var phKey: HCRYPTKEY): BOOL; stdcall;
  1170. {$EXTERNALSYM CryptGenKey}
  1171. function CryptDeriveKey(hProv: HCRYPTPROV; Algid: ALG_ID; hBaseData: HCRYPTHASH;
  1172. dwFlags: DWORD; var phKey: HCRYPTKEY): BOOL; stdcall;
  1173. {$EXTERNALSYM CryptDeriveKey}
  1174. function CryptDestroyKey(hKey: HCRYPTKEY): BOOL; stdcall;
  1175. {$EXTERNALSYM CryptDestroyKey}
  1176. function CryptSetKeyParam(hKey: HCRYPTKEY; dwParam: DWORD; pbData: LPBYTE;
  1177. dwFlags: DWORD): BOOL; stdcall;
  1178. {$EXTERNALSYM CryptSetKeyParam}
  1179. function CryptGetKeyParam(hKey: HCRYPTKEY; dwParam: DWORD; pbData: LPBYTE;
  1180. var pdwDataLen: DWORD; dwFlags: DWORD): BOOL; stdcall;
  1181. {$EXTERNALSYM CryptGetKeyParam}
  1182. function CryptSetHashParam(hHash: HCRYPTHASH; dwParam: DWORD; pbData: LPBYTE;
  1183. dwFlags: DWORD): BOOL; stdcall;
  1184. {$EXTERNALSYM CryptSetHashParam}
  1185. function CryptGetHashParam(hHash: HCRYPTHASH; dwParam: DWORD; pbData: LPBYTE;
  1186. var pdwDataLen: DWORD; dwFlags: DWORD): BOOL; stdcall;
  1187. {$EXTERNALSYM CryptGetHashParam}
  1188. function CryptSetProvParam(hProv: HCRYPTPROV; dwParam: DWORD; pbData: LPBYTE;
  1189. dwFlags: DWORD): BOOL; stdcall;
  1190. {$EXTERNALSYM CryptSetProvParam}
  1191. function CryptGetProvParam(hProv: HCRYPTPROV; dwParam: DWORD; pbData: LPBYTE;
  1192. var pdwDataLen: DWORD; dwFlags: DWORD): BOOL; stdcall;
  1193. {$EXTERNALSYM CryptGetProvParam}
  1194. function CryptGenRandom(hProv: HCRYPTPROV; dwLen: DWORD; pbBuffer: LPBYTE): BOOL; stdcall;
  1195. {$EXTERNALSYM CryptGenRandom}
  1196. function CryptGetUserKey(hProv: HCRYPTPROV; dwKeySpec: DWORD; var phUserKey: HCRYPTKEY): BOOL; stdcall;
  1197. {$EXTERNALSYM CryptGetUserKey}
  1198. function CryptExportKey(hKey, hExpKey: HCRYPTKEY; dwBlobType, dwFlags: DWORD;
  1199. pbData: LPBYTE; var pdwDataLen: DWORD): BOOL; stdcall;
  1200. {$EXTERNALSYM CryptExportKey}
  1201. function CryptImportKey(hProv: HCRYPTPROV; pbData: LPBYTE; dwDataLen: DWORD;
  1202. hPubKey: HCRYPTKEY; dwFlags: DWORD; var phKey: HCRYPTKEY): BOOL; stdcall;
  1203. {$EXTERNALSYM CryptImportKey}
  1204. function CryptEncrypt(hKey: HCRYPTKEY; hHash: HCRYPTHASH; Final: BOOL;
  1205. dwFlags: DWORD; pbData: LPBYTE; var pdwDataLen: DWORD; dwBufLen: DWORD): BOOL; stdcall;
  1206. {$EXTERNALSYM CryptEncrypt}
  1207. function CryptDecrypt(hKey: HCRYPTKEY; hHash: HCRYPTHASH; Final: BOOL;
  1208. dwFlags: DWORD; pbData: LPBYTE; var pdwDataLen: DWORD): BOOL; stdcall;
  1209. {$EXTERNALSYM CryptDecrypt}
  1210. function CryptCreateHash(hProv: HCRYPTPROV; Algid: ALG_ID; hKey: HCRYPTKEY;
  1211. dwFlags: DWORD; var phHash: HCRYPTHASH): BOOL; stdcall;
  1212. {$EXTERNALSYM CryptCreateHash}
  1213. function CryptHashData(hHash: HCRYPTHASH; pbData: LPBYTE; dwDataLen, dwFlags: DWORD): BOOL; stdcall;
  1214. {$EXTERNALSYM CryptHashData}
  1215. function CryptHashSessionKey(hHash: HCRYPTHASH; hKey: HCRYPTKEY; dwFlags: DWORD): BOOL; stdcall;
  1216. {$EXTERNALSYM CryptHashSessionKey}
  1217. function CryptDestroyHash(hHash: HCRYPTHASH): BOOL; stdcall;
  1218. {$EXTERNALSYM CryptDestroyHash}
  1219. function CryptSignHashA(hHash: HCRYPTHASH; dwKeySpec: DWORD; sDescription: LPCSTR;
  1220. dwFlags: DWORD; pbSignature: LPBYTE; var pdwSigLen: DWORD): BOOL; stdcall;
  1221. {$EXTERNALSYM CryptSignHashA}
  1222. function CryptSignHashW(hHash: HCRYPTHASH; dwKeySpec: DWORD; sDescription: LPCWSTR;
  1223. dwFlags: DWORD; pbSignature: LPBYTE; var pdwSigLen: DWORD): BOOL; stdcall;
  1224. {$EXTERNALSYM CryptSignHashW}
  1225. function CryptSignHash(hHash: HCRYPTHASH; dwKeySpec: DWORD; sDescription: LPCTSTR;
  1226. dwFlags: DWORD; pbSignature: LPBYTE; var pdwSigLen: DWORD): BOOL; stdcall;
  1227. {$EXTERNALSYM CryptSignHash}
  1228. function CryptVerifySignatureA(hHash: HCRYPTHASH; pbSignature: LPBYTE;
  1229. dwSigLen: DWORD; hPubKey: HCRYPTKEY; sDescription: LPCSTR; dwFlags: DWORD): BOOL; stdcall;
  1230. {$EXTERNALSYM CryptVerifySignatureA}
  1231. function CryptVerifySignatureW(hHash: HCRYPTHASH; pbSignature: LPBYTE;
  1232. dwSigLen: DWORD; hPubKey: HCRYPTKEY; sDescription: LPCWSTR; dwFlags: DWORD): BOOL; stdcall;
  1233. {$EXTERNALSYM CryptVerifySignatureW}
  1234. function CryptVerifySignature(hHash: HCRYPTHASH; pbSignature: LPBYTE;
  1235. dwSigLen: DWORD; hPubKey: HCRYPTKEY; sDescription: LPCTSTR; dwFlags: DWORD): BOOL; stdcall;
  1236. {$EXTERNALSYM CryptVerifySignature}
  1237. function CryptSetProviderA(pszProvName: LPCSTR; dwProvType: DWORD): BOOL; stdcall;
  1238. {$EXTERNALSYM CryptSetProviderA}
  1239. function CryptSetProviderW(pszProvName: LPCWSTR; dwProvType: DWORD): BOOL; stdcall;
  1240. {$EXTERNALSYM CryptSetProviderW}
  1241. function CryptSetProvider(pszProvName: LPCTSTR; dwProvType: DWORD): BOOL; stdcall;
  1242. {$EXTERNALSYM CryptSetProvider}
  1243. function CryptSetProviderExA(pszProvName: LPCSTR; dwProvType: DWORD;
  1244. pdwReserved: LPDWORD; dwFlags: DWORD): BOOL; stdcall;
  1245. {$EXTERNALSYM CryptSetProviderExA}
  1246. function CryptSetProviderExW(pszProvName: LPCWSTR; dwProvType: DWORD;
  1247. pdwReserved: LPDWORD; dwFlags: DWORD): BOOL; stdcall;
  1248. {$EXTERNALSYM CryptSetProviderExW}
  1249. function CryptSetProviderEx(pszProvName: LPCTSTR; dwProvType: DWORD;
  1250. pdwReserved: LPDWORD; dwFlags: DWORD): BOOL; stdcall;
  1251. {$EXTERNALSYM CryptSetProviderEx}
  1252. function CryptGetDefaultProviderA(dwProvType: DWORD; pdwReserved: LPDWORD;
  1253. dwFlags: DWORD; pszProvName: LPSTR; var pcbProvName: DWORD): BOOL; stdcall;
  1254. {$EXTERNALSYM CryptGetDefaultProviderA}
  1255. function CryptGetDefaultProviderW(dwProvType: DWORD; pdwReserved: LPDWORD;
  1256. dwFlags: DWORD; pszProvName: LPWSTR; var pcbProvName: DWORD): BOOL; stdcall;
  1257. {$EXTERNALSYM CryptGetDefaultProviderW}
  1258. function CryptGetDefaultProvider(dwProvType: DWORD; pdwReserved: LPDWORD;
  1259. dwFlags: DWORD; pszProvName: LPTSTR; var pcbProvName: DWORD): BOOL; stdcall;
  1260. {$EXTERNALSYM CryptGetDefaultProvider}
  1261. function CryptEnumProviderTypesA(dwIndex: DWORD; pdwReserved: LPDWORD;
  1262. dwFlags: DWORD; var pdwProvType: DWORD; pszTypeName: LPSTR;
  1263. var pcbTypeName: DWORD): BOOL; stdcall;
  1264. {$EXTERNALSYM CryptEnumProviderTypesA}
  1265. function CryptEnumProviderTypesW(dwIndex: DWORD; pdwReserved: LPDWORD;
  1266. dwFlags: DWORD; var pdwProvType: DWORD; pszTypeName: LPWSTR;
  1267. var pcbTypeName: DWORD): BOOL; stdcall;
  1268. {$EXTERNALSYM CryptEnumProviderTypesW}
  1269. function CryptEnumProviderTypes(dwIndex: DWORD; pdwReserved: LPDWORD;
  1270. dwFlags: DWORD; var pdwProvType: DWORD; pszTypeName: LPTSTR;
  1271. var pcbTypeName: DWORD): BOOL; stdcall;
  1272. {$EXTERNALSYM CryptEnumProviderTypes}
  1273. function CryptEnumProvidersA(dwIndex: DWORD; pdwReserved: LPDWORD; dwFlags: DWORD;
  1274. var pdwProvType: DWORD; pszProvName: LPSTR; var pcbProvName: DWORD): BOOL; stdcall;
  1275. {$EXTERNALSYM CryptEnumProvidersA}
  1276. function CryptEnumProvidersW(dwIndex: DWORD; pdwReserved: LPDWORD; dwFlags: DWORD;
  1277. var pdwProvType: DWORD; pszProvName: LPWSTR; var pcbProvName: DWORD): BOOL; stdcall;
  1278. {$EXTERNALSYM CryptEnumProvidersW}
  1279. function CryptEnumProviders(dwIndex: DWORD; pdwReserved: LPDWORD; dwFlags: DWORD;
  1280. var pdwProvType: DWORD; pszProvName: LPTSTR; var pcbProvName: DWORD): BOOL; stdcall;
  1281. {$EXTERNALSYM CryptEnumProviders}
  1282. function CryptContextAddRef(hProv: HCRYPTPROV; pdwReserved: LPDWORD; dwFlags: DWORD): BOOL; stdcall;
  1283. {$EXTERNALSYM CryptContextAddRef}
  1284. function CryptDuplicateKey(hKey: HCRYPTKEY; pdwReserved: LPDWORD; dwFlags: DWORD;
  1285. var phKey: HCRYPTKEY): BOOL; stdcall;
  1286. {$EXTERNALSYM CryptDuplicateKey}
  1287. function CryptDuplicateHash(hHash: HCRYPTHASH; pdwReserved: LPDWORD;
  1288. dwFlags: DWORD; var phHash: HCRYPTHASH): BOOL; stdcall;
  1289. {$EXTERNALSYM CryptDuplicateHash}
  1290. //+-------------------------------------------------------------------------
  1291. // In a CRYPT_BIT_BLOB the last byte may contain 0-7 unused bits. Therefore, the
  1292. // overall bit length is cbData * 8 - cUnusedBits.
  1293. //--------------------------------------------------------------------------
  1294. type
  1295. PCRYPT_BIT_BLOB = ^CRYPT_BIT_BLOB;
  1296. {$EXTERNALSYM PCRYPT_BIT_BLOB}
  1297. _CRYPT_BIT_BLOB = record
  1298. cbData: DWORD;
  1299. pbData: LPBYTE;
  1300. cUnusedBits: DWORD;
  1301. end;
  1302. {$EXTERNALSYM _CRYPT_BIT_BLOB}
  1303. CRYPT_BIT_BLOB = _CRYPT_BIT_BLOB;
  1304. {$EXTERNALSYM CRYPT_BIT_BLOB}
  1305. TCryptBitBlob = CRYPT_BIT_BLOB;
  1306. PCryptBitBlob = PCRYPT_BIT_BLOB;
  1307. //+-------------------------------------------------------------------------
  1308. // Type used for any algorithm
  1309. //
  1310. // Where the Parameters CRYPT_OBJID_BLOB is in its encoded representation. For most
  1311. // algorithm types, the Parameters CRYPT_OBJID_BLOB is NULL (Parameters.cbData = 0).
  1312. //--------------------------------------------------------------------------
  1313. type
  1314. PCRYPT_ALGORITHM_IDENTIFIER = ^CRYPT_ALGORITHM_IDENTIFIER;
  1315. {$EXTERNALSYM PCRYPT_ALGORITHM_IDENTIFIER}
  1316. _CRYPT_ALGORITHM_IDENTIFIER = record
  1317. pszObjId: LPSTR;
  1318. Parameters: CRYPT_OBJID_BLOB;
  1319. end;
  1320. {$EXTERNALSYM _CRYPT_ALGORITHM_IDENTIFIER}
  1321. CRYPT_ALGORITHM_IDENTIFIER = _CRYPT_ALGORITHM_IDENTIFIER;
  1322. {$EXTERNALSYM CRYPT_ALGORITHM_IDENTIFIER}
  1323. TCryptAlgorithmIdentifier = CRYPT_ALGORITHM_IDENTIFIER;
  1324. PCryptAlgorithmIdentifier = PCRYPT_ALGORITHM_IDENTIFIER;
  1325. // Following are the definitions of various algorithm object identifiers
  1326. // RSA
  1327. const
  1328. szOID_RSA = '1.2.840.113549';
  1329. {$EXTERNALSYM szOID_RSA}
  1330. szOID_PKCS = '1.2.840.113549.1';
  1331. {$EXTERNALSYM szOID_PKCS}
  1332. szOID_RSA_HASH = '1.2.840.113549.2';
  1333. {$EXTERNALSYM szOID_RSA_HASH}
  1334. szOID_RSA_ENCRYPT = '1.2.840.113549.3';
  1335. {$EXTERNALSYM szOID_RSA_ENCRYPT}
  1336. szOID_PKCS_1 = '1.2.840.113549.1.1';
  1337. {$EXTERNALSYM szOID_PKCS_1}
  1338. szOID_PKCS_2 = '1.2.840.113549.1.2';
  1339. {$EXTERNALSYM szOID_PKCS_2}
  1340. szOID_PKCS_3 = '1.2.840.113549.1.3';
  1341. {$EXTERNALSYM szOID_PKCS_3}
  1342. szOID_PKCS_4 = '1.2.840.113549.1.4';
  1343. {$EXTERNALSYM szOID_PKCS_4}
  1344. szOID_PKCS_5 = '1.2.840.113549.1.5';
  1345. {$EXTERNALSYM szOID_PKCS_5}
  1346. szOID_PKCS_6 = '1.2.840.113549.1.6';
  1347. {$EXTERNALSYM szOID_PKCS_6}
  1348. szOID_PKCS_7 = '1.2.840.113549.1.7';
  1349. {$EXTERNALSYM szOID_PKCS_7}
  1350. szOID_PKCS_8 = '1.2.840.113549.1.8';
  1351. {$EXTERNALSYM szOID_PKCS_8}
  1352. szOID_PKCS_9 = '1.2.840.113549.1.9';
  1353. {$EXTERNALSYM szOID_PKCS_9}
  1354. szOID_PKCS_10 = '1.2.840.113549.1.10';
  1355. {$EXTERNALSYM szOID_PKCS_10}
  1356. szOID_PKCS_12 = '1.2.840.113549.1.12';
  1357. {$EXTERNALSYM szOID_PKCS_12}
  1358. szOID_RSA_RSA = '1.2.840.113549.1.1.1';
  1359. {$EXTERNALSYM szOID_RSA_RSA}
  1360. szOID_RSA_MD2RSA = '1.2.840.113549.1.1.2';
  1361. {$EXTERNALSYM szOID_RSA_MD2RSA}
  1362. szOID_RSA_MD4RSA = '1.2.840.113549.1.1.3';
  1363. {$EXTERNALSYM szOID_RSA_MD4RSA}
  1364. szOID_RSA_MD5RSA = '1.2.840.113549.1.1.4';
  1365. {$EXTERNALSYM szOID_RSA_MD5RSA}
  1366. szOID_RSA_SHA1RSA = '1.2.840.113549.1.1.5';
  1367. {$EXTERNALSYM szOID_RSA_SHA1RSA}
  1368. szOID_RSA_SETOAEP_RSA = '1.2.840.113549.1.1.6';
  1369. {$EXTERNALSYM szOID_RSA_SETOAEP_RSA}
  1370. szOID_RSA_DH = '1.2.840.113549.1.3.1';
  1371. {$EXTERNALSYM szOID_RSA_DH}
  1372. szOID_RSA_data = '1.2.840.113549.1.7.1';
  1373. {$EXTERNALSYM szOID_RSA_data}
  1374. szOID_RSA_signedData = '1.2.840.113549.1.7.2';
  1375. {$EXTERNALSYM szOID_RSA_signedData}
  1376. szOID_RSA_envelopedData = '1.2.840.113549.1.7.3';
  1377. {$EXTERNALSYM szOID_RSA_envelopedData}
  1378. szOID_RSA_signEnvData = '1.2.840.113549.1.7.4';
  1379. {$EXTERNALSYM szOID_RSA_signEnvData}
  1380. szOID_RSA_digestedData = '1.2.840.113549.1.7.5';
  1381. {$EXTERNALSYM szOID_RSA_digestedData}
  1382. szOID_RSA_hashedData = '1.2.840.113549.1.7.5';
  1383. {$EXTERNALSYM szOID_RSA_hashedData}
  1384. szOID_RSA_encryptedData = '1.2.840.113549.1.7.6';
  1385. {$EXTERNALSYM szOID_RSA_encryptedData}
  1386. szOID_RSA_emailAddr = '1.2.840.113549.1.9.1';
  1387. {$EXTERNALSYM szOID_RSA_emailAddr}
  1388. szOID_RSA_unstructName = '1.2.840.113549.1.9.2';
  1389. {$EXTERNALSYM szOID_RSA_unstructName}
  1390. szOID_RSA_contentType = '1.2.840.113549.1.9.3';
  1391. {$EXTERNALSYM szOID_RSA_contentType}
  1392. szOID_RSA_messageDigest = '1.2.840.113549.1.9.4';
  1393. {$EXTERNALSYM szOID_RSA_messageDigest}
  1394. szOID_RSA_signingTime = '1.2.840.113549.1.9.5';
  1395. {$EXTERNALSYM szOID_RSA_signingTime}
  1396. szOID_RSA_counterSign = '1.2.840.113549.1.9.6';
  1397. {$EXTERNALSYM szOID_RSA_counterSign}
  1398. szOID_RSA_challengePwd = '1.2.840.113549.1.9.7';
  1399. {$EXTERNALSYM szOID_RSA_challengePwd}
  1400. szOID_RSA_unstructAddr = '1.2.840.113549.1.9.8';
  1401. {$EXTERNALSYM szOID_RSA_unstructAddr}
  1402. szOID_RSA_extCertAttrs = '1.2.840.113549.1.9.9';
  1403. {$EXTERNALSYM szOID_RSA_extCertAttrs}
  1404. szOID_RSA_certExtensions = '1.2.840.113549.1.9.14';
  1405. {$EXTERNALSYM szOID_RSA_certExtensions}
  1406. szOID_RSA_SMIMECapabilities = '1.2.840.113549.1.9.15';
  1407. {$EXTERNALSYM szOID_RSA_SMIMECapabilities}
  1408. szOID_RSA_preferSignedData = '1.2.840.113549.1.9.15.1';
  1409. {$EXTERNALSYM szOID_RSA_preferSignedData}
  1410. szOID_RSA_SMIMEalg = '1.2.840.113549.1.9.16.3';
  1411. {$EXTERNALSYM szOID_RSA_SMIMEalg}
  1412. szOID_RSA_SMIMEalgESDH = '1.2.840.113549.1.9.16.3.5';
  1413. {$EXTERNALSYM szOID_RSA_SMIMEalgESDH}
  1414. szOID_RSA_SMIMEalgCMS3DESwrap = '1.2.840.113549.1.9.16.3.6';
  1415. {$EXTERNALSYM szOID_RSA_SMIMEalgCMS3DESwrap}
  1416. szOID_RSA_SMIMEalgCMSRC2wrap = '1.2.840.113549.1.9.16.3.7';
  1417. {$EXTERNALSYM szOID_RSA_SMIMEalgCMSRC2wrap}
  1418. szOID_RSA_MD2 = '1.2.840.113549.2.2';
  1419. {$EXTERNALSYM szOID_RSA_MD2}
  1420. szOID_RSA_MD4 = '1.2.840.113549.2.4';
  1421. {$EXTERNALSYM szOID_RSA_MD4}
  1422. szOID_RSA_MD5 = '1.2.840.113549.2.5';
  1423. {$EXTERNALSYM szOID_RSA_MD5}
  1424. szOID_RSA_RC2CBC = '1.2.840.113549.3.2';
  1425. {$EXTERNALSYM szOID_RSA_RC2CBC}
  1426. szOID_RSA_RC4 = '1.2.840.113549.3.4';
  1427. {$EXTERNALSYM szOID_RSA_RC4}
  1428. szOID_RSA_DES_EDE3_CBC = '1.2.840.113549.3.7';
  1429. {$EXTERNALSYM szOID_RSA_DES_EDE3_CBC}
  1430. szOID_RSA_RC5_CBCPad = '1.2.840.113549.3.9';
  1431. {$EXTERNALSYM szOID_RSA_RC5_CBCPad}
  1432. szOID_ANSI_X942 = '1.2.840.10046';
  1433. {$EXTERNALSYM szOID_ANSI_X942}
  1434. szOID_ANSI_X942_DH = '1.2.840.10046.2.1';
  1435. {$EXTERNALSYM szOID_ANSI_X942_DH}
  1436. szOID_X957 = '1.2.840.10040';
  1437. {$EXTERNALSYM szOID_X957}
  1438. szOID_X957_DSA = '1.2.840.10040.4.1';
  1439. {$EXTERNALSYM szOID_X957_DSA}
  1440. szOID_X957_SHA1DSA = '1.2.840.10040.4.3';
  1441. {$EXTERNALSYM szOID_X957_SHA1DSA}
  1442. // ITU-T UsefulDefinitions
  1443. szOID_DS = '2.5';
  1444. {$EXTERNALSYM szOID_DS}
  1445. szOID_DSALG = '2.5.8';
  1446. {$EXTERNALSYM szOID_DSALG}
  1447. szOID_DSALG_CRPT = '2.5.8.1';
  1448. {$EXTERNALSYM szOID_DSALG_CRPT}
  1449. szOID_DSALG_HASH = '2.5.8.2';
  1450. {$EXTERNALSYM szOID_DSALG_HASH}
  1451. szOID_DSALG_SIGN = '2.5.8.3';
  1452. {$EXTERNALSYM szOID_DSALG_SIGN}
  1453. szOID_DSALG_RSA = '2.5.8.1.1';
  1454. {$EXTERNALSYM szOID_DSALG_RSA}
  1455. // NIST OSE Implementors' Workshop (OIW)
  1456. // http://nemo.ncsl.nist.gov/oiw/agreements/stable/OSI/12s_9506.w51
  1457. // http://nemo.ncsl.nist.gov/oiw/agreements/working/OSI/12w_9503.w51
  1458. szOID_OIW = '1.3.14';
  1459. {$EXTERNALSYM szOID_OIW}
  1460. // NIST OSE Implementors' Workshop (OIW) Security SIG algorithm identifiers
  1461. szOID_OIWSEC = '1.3.14.3.2';
  1462. {$EXTERNALSYM szOID_OIWSEC}
  1463. szOID_OIWSEC_md4RSA = '1.3.14.3.2.2';
  1464. {$EXTERNALSYM szOID_OIWSEC_md4RSA}
  1465. szOID_OIWSEC_md5RSA = '1.3.14.3.2.3';
  1466. {$EXTERNALSYM szOID_OIWSEC_md5RSA}
  1467. szOID_OIWSEC_md4RSA2 = '1.3.14.3.2.4';
  1468. {$EXTERNALSYM szOID_OIWSEC_md4RSA2}
  1469. szOID_OIWSEC_desECB = '1.3.14.3.2.6';
  1470. {$EXTERNALSYM szOID_OIWSEC_desECB}
  1471. szOID_OIWSEC_desCBC = '1.3.14.3.2.7';
  1472. {$EXTERNALSYM szOID_OIWSEC_desCBC}
  1473. szOID_OIWSEC_desOFB = '1.3.14.3.2.8';
  1474. {$EXTERNALSYM szOID_OIWSEC_desOFB}
  1475. szOID_OIWSEC_desCFB = '1.3.14.3.2.9';
  1476. {$EXTERNALSYM szOID_OIWSEC_desCFB}
  1477. szOID_OIWSEC_desMAC = '1.3.14.3.2.10';
  1478. {$EXTERNALSYM szOID_OIWSEC_desMAC}
  1479. szOID_OIWSEC_rsaSign = '1.3.14.3.2.11';
  1480. {$EXTERNALSYM szOID_OIWSEC_rsaSign}
  1481. szOID_OIWSEC_dsa = '1.3.14.3.2.12';
  1482. {$EXTERNALSYM szOID_OIWSEC_dsa}
  1483. szOID_OIWSEC_shaDSA = '1.3.14.3.2.13';
  1484. {$EXTERNALSYM szOID_OIWSEC_shaDSA}
  1485. szOID_OIWSEC_mdc2RSA = '1.3.14.3.2.14';
  1486. {$EXTERNALSYM szOID_OIWSEC_mdc2RSA}
  1487. szOID_OIWSEC_shaRSA = '1.3.14.3.2.15';
  1488. {$EXTERNALSYM szOID_OIWSEC_shaRSA}
  1489. szOID_OIWSEC_dhCommMod = '1.3.14.3.2.16';
  1490. {$EXTERNALSYM szOID_OIWSEC_dhCommMod}
  1491. szOID_OIWSEC_desEDE = '1.3.14.3.2.17';
  1492. {$EXTERNALSYM szOID_OIWSEC_desEDE}
  1493. szOID_OIWSEC_sha = '1.3.14.3.2.18';
  1494. {$EXTERNALSYM szOID_OIWSEC_sha}
  1495. szOID_OIWSEC_mdc2 = '1.3.14.3.2.19';
  1496. {$EXTERNALSYM szOID_OIWSEC_mdc2}
  1497. szOID_OIWSEC_dsaComm = '1.3.14.3.2.20';
  1498. {$EXTERNALSYM szOID_OIWSEC_dsaComm}
  1499. szOID_OIWSEC_dsaCommSHA = '1.3.14.3.2.21';
  1500. {$EXTERNALSYM szOID_OIWSEC_dsaCommSHA}
  1501. szOID_OIWSEC_rsaXchg = '1.3.14.3.2.22';
  1502. {$EXTERNALSYM szOID_OIWSEC_rsaXchg}
  1503. szOID_OIWSEC_keyHashSeal = '1.3.14.3.2.23';
  1504. {$EXTERNALSYM szOID_OIWSEC_keyHashSeal}
  1505. szOID_OIWSEC_md2RSASign = '1.3.14.3.2.24';
  1506. {$EXTERNALSYM szOID_OIWSEC_md2RSASign}
  1507. szOID_OIWSEC_md5RSASign = '1.3.14.3.2.25';
  1508. {$EXTERNALSYM szOID_OIWSEC_md5RSASign}
  1509. szOID_OIWSEC_sha1 = '1.3.14.3.2.26';
  1510. {$EXTERNALSYM szOID_OIWSEC_sha1}
  1511. szOID_OIWSEC_dsaSHA1 = '1.3.14.3.2.27';
  1512. {$EXTERNALSYM szOID_OIWSEC_dsaSHA1}
  1513. szOID_OIWSEC_dsaCommSHA1 = '1.3.14.3.2.28';
  1514. {$EXTERNALSYM szOID_OIWSEC_dsaCommSHA1}
  1515. szOID_OIWSEC_sha1RSASign = '1.3.14.3.2.29';
  1516. {$EXTERNALSYM szOID_OIWSEC_sha1RSASign}
  1517. // NIST OSE Implementors' Workshop (OIW) Directory SIG algorithm identifiers
  1518. szOID_OIWDIR = '1.3.14.7.2';
  1519. {$EXTERNALSYM szOID_OIWDIR}
  1520. szOID_OIWDIR_CRPT = '1.3.14.7.2.1';
  1521. {$EXTERNALSYM szOID_OIWDIR_CRPT}
  1522. szOID_OIWDIR_HASH = '1.3.14.7.2.2';
  1523. {$EXTERNALSYM szOID_OIWDIR_HASH}
  1524. szOID_OIWDIR_SIGN = '1.3.14.7.2.3';
  1525. {$EXTERNALSYM szOID_OIWDIR_SIGN}
  1526. szOID_OIWDIR_md2 = '1.3.14.7.2.2.1';
  1527. {$EXTERNALSYM szOID_OIWDIR_md2}
  1528. szOID_OIWDIR_md2RSA = '1.3.14.7.2.3.1';
  1529. {$EXTERNALSYM szOID_OIWDIR_md2RSA}
  1530. // INFOSEC Algorithms
  1531. // joint-iso-ccitt(2) country(16) us(840) organization(1) us-government(101) dod(2) id-infosec(1)
  1532. szOID_INFOSEC = '2.16.840.1.101.2.1';
  1533. {$EXTERNALSYM szOID_INFOSEC}
  1534. szOID_INFOSEC_sdnsSignature = '2.16.840.1.101.2.1.1.1';
  1535. {$EXTERNALSYM szOID_INFOSEC_sdnsSignature}
  1536. szOID_INFOSEC_mosaicSignature = '2.16.840.1.101.2.1.1.2';
  1537. {$EXTERNALSYM szOID_INFOSEC_mosaicSignature}
  1538. szOID_INFOSEC_sdnsConfidentiality = '2.16.840.1.101.2.1.1.3';
  1539. {$EXTERNALSYM szOID_INFOSEC_sdnsConfidentiality}
  1540. szOID_INFOSEC_mosaicConfidentiality = '2.16.840.1.101.2.1.1.4';
  1541. {$EXTERNALSYM szOID_INFOSEC_mosaicConfidentiality}
  1542. szOID_INFOSEC_sdnsIntegrity = '2.16.840.1.101.2.1.1.5';
  1543. {$EXTERNALSYM szOID_INFOSEC_sdnsIntegrity}
  1544. szOID_INFOSEC_mosaicIntegrity = '2.16.840.1.101.2.1.1.6';
  1545. {$EXTERNALSYM szOID_INFOSEC_mosaicIntegrity}
  1546. szOID_INFOSEC_sdnsTokenProtection = '2.16.840.1.101.2.1.1.7';
  1547. {$EXTERNALSYM szOID_INFOSEC_sdnsTokenProtection}
  1548. szOID_INFOSEC_mosaicTokenProtection = '2.16.840.1.101.2.1.1.8';
  1549. {$EXTERNALSYM szOID_INFOSEC_mosaicTokenProtection}
  1550. szOID_INFOSEC_sdnsKeyManagement = '2.16.840.1.101.2.1.1.9';
  1551. {$EXTERNALSYM szOID_INFOSEC_sdnsKeyManagement}
  1552. szOID_INFOSEC_mosaicKeyManagement = '2.16.840.1.101.2.1.1.10';
  1553. {$EXTERNALSYM szOID_INFOSEC_mosaicKeyManagement}
  1554. szOID_INFOSEC_sdnsKMandSig = '2.16.840.1.101.2.1.1.11';
  1555. {$EXTERNALSYM szOID_INFOSEC_sdnsKMandSig}
  1556. szOID_INFOSEC_mosaicKMandSig = '2.16.840.1.101.2.1.1.12';
  1557. {$EXTERNALSYM szOID_INFOSEC_mosaicKMandSig}
  1558. szOID_INFOSEC_SuiteASignature = '2.16.840.1.101.2.1.1.13';
  1559. {$EXTERNALSYM szOID_INFOSEC_SuiteASignature}
  1560. szOID_INFOSEC_SuiteAConfidentiality = '2.16.840.1.101.2.1.1.14';
  1561. {$EXTERNALSYM szOID_INFOSEC_SuiteAConfidentiality}
  1562. szOID_INFOSEC_SuiteAIntegrity = '2.16.840.1.101.2.1.1.15';
  1563. {$EXTERNALSYM szOID_INFOSEC_SuiteAIntegrity}
  1564. szOID_INFOSEC_SuiteATokenProtection = '2.16.840.1.101.2.1.1.16';
  1565. {$EXTERNALSYM szOID_INFOSEC_SuiteATokenProtection}
  1566. szOID_INFOSEC_SuiteAKeyManagement = '2.16.840.1.101.2.1.1.17';
  1567. {$EXTERNALSYM szOID_INFOSEC_SuiteAKeyManagement}
  1568. szOID_INFOSEC_SuiteAKMandSig = '2.16.840.1.101.2.1.1.18';
  1569. {$EXTERNALSYM szOID_INFOSEC_SuiteAKMandSig}
  1570. szOID_INFOSEC_mosaicUpdatedSig = '2.16.840.1.101.2.1.1.19';
  1571. {$EXTERNALSYM szOID_INFOSEC_mosaicUpdatedSig}
  1572. szOID_INFOSEC_mosaicKMandUpdSig = '2.16.840.1.101.2.1.1.20';
  1573. {$EXTERNALSYM szOID_INFOSEC_mosaicKMandUpdSig}
  1574. szOID_INFOSEC_mosaicUpdatedInteg = '2.16.840.1.101.2.1.1.21';
  1575. {$EXTERNALSYM szOID_INFOSEC_mosaicUpdatedInteg}
  1576. type
  1577. PCRYPT_OBJID_TABLE = ^CRYPT_OBJID_TABLE;
  1578. {$EXTERNALSYM PCRYPT_OBJID_TABLE}
  1579. _CRYPT_OBJID_TABLE = record
  1580. dwAlgId: DWORD;
  1581. pszObjId: LPCSTR;
  1582. end;
  1583. {$EXTERNALSYM _CRYPT_OBJID_TABLE}
  1584. CRYPT_OBJID_TABLE = _CRYPT_OBJID_TABLE;
  1585. {$EXTERNALSYM CRYPT_OBJID_TABLE}
  1586. TCryptObjIdTable = CRYPT_OBJID_TABLE;
  1587. PCryptObjIdTable = PCRYPT_OBJID_TABLE;
  1588. //+-------------------------------------------------------------------------
  1589. // PKCS #1 HashInfo (DigestInfo)
  1590. //--------------------------------------------------------------------------
  1591. PCRYPT_HASH_INFO = ^CRYPT_HASH_INFO;
  1592. {$EXTERNALSYM PCRYPT_HASH_INFO}
  1593. _CRYPT_HASH_INFO = record
  1594. HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  1595. Hash: CRYPT_HASH_BLOB;
  1596. end;
  1597. {$EXTERNALSYM _CRYPT_HASH_INFO}
  1598. CRYPT_HASH_INFO = _CRYPT_HASH_INFO;
  1599. {$EXTERNALSYM CRYPT_HASH_INFO}
  1600. TCryptHashInfo = CRYPT_HASH_INFO;
  1601. PCryptHashInfo = PCRYPT_HASH_INFO;
  1602. //+-------------------------------------------------------------------------
  1603. // Type used for an extension to an encoded content
  1604. //
  1605. // Where the Value's CRYPT_OBJID_BLOB is in its encoded representation.
  1606. //--------------------------------------------------------------------------
  1607. PCERT_EXTENSION = ^CERT_EXTENSION;
  1608. {$EXTERNALSYM PCERT_EXTENSION}
  1609. _CERT_EXTENSION = record
  1610. pszObjId: LPSTR;
  1611. fCritical: BOOL;
  1612. Value: CRYPT_OBJID_BLOB;
  1613. end;
  1614. {$EXTERNALSYM _CERT_EXTENSION}
  1615. CERT_EXTENSION = _CERT_EXTENSION;
  1616. {$EXTERNALSYM CERT_EXTENSION}
  1617. TCertExtension = CERT_EXTENSION;
  1618. PCertExtension = PCERT_EXTENSION;
  1619. //+-------------------------------------------------------------------------
  1620. // AttributeTypeValue
  1621. //
  1622. // Where the Value's CRYPT_OBJID_BLOB is in its encoded representation.
  1623. //--------------------------------------------------------------------------
  1624. PCRYPT_ATTRIBUTE_TYPE_VALUE = ^CRYPT_ATTRIBUTE_TYPE_VALUE;
  1625. {$EXTERNALSYM PCRYPT_ATTRIBUTE_TYPE_VALUE}
  1626. _CRYPT_ATTRIBUTE_TYPE_VALUE = record
  1627. pszObjId: LPSTR;
  1628. Value: CRYPT_OBJID_BLOB;
  1629. end;
  1630. {$EXTERNALSYM _CRYPT_ATTRIBUTE_TYPE_VALUE}
  1631. CRYPT_ATTRIBUTE_TYPE_VALUE = _CRYPT_ATTRIBUTE_TYPE_VALUE;
  1632. {$EXTERNALSYM CRYPT_ATTRIBUTE_TYPE_VALUE}
  1633. TCryptAttributeTypeValue = CRYPT_ATTRIBUTE_TYPE_VALUE;
  1634. PCryptAttributeTypeValue = PCRYPT_ATTRIBUTE_TYPE_VALUE;
  1635. //+-------------------------------------------------------------------------
  1636. // Attributes
  1637. //
  1638. // Where the Value's PATTR_BLOBs are in their encoded representation.
  1639. //--------------------------------------------------------------------------
  1640. PCRYPT_ATTRIBUTE = ^CRYPT_ATTRIBUTE;
  1641. {$EXTERNALSYM PCRYPT_ATTRIBUTE}
  1642. _CRYPT_ATTRIBUTE = record
  1643. pszObjId: LPSTR;
  1644. cValue: DWORD;
  1645. rgValue: PCRYPT_ATTR_BLOB;
  1646. end;
  1647. {$EXTERNALSYM _CRYPT_ATTRIBUTE}
  1648. CRYPT_ATTRIBUTE = _CRYPT_ATTRIBUTE;
  1649. {$EXTERNALSYM CRYPT_ATTRIBUTE}
  1650. TCryptAttribute = CRYPT_ATTRIBUTE;
  1651. PCryptAttribute = PCRYPT_ATTRIBUTE;
  1652. PCRYPT_ATTRIBUTES = ^CRYPT_ATTRIBUTES;
  1653. {$EXTERNALSYM PCRYPT_ATTRIBUTES}
  1654. _CRYPT_ATTRIBUTES = record
  1655. cAttr: DWORD;
  1656. rgAttr: PCRYPT_ATTRIBUTE;
  1657. end;
  1658. {$EXTERNALSYM _CRYPT_ATTRIBUTES}
  1659. CRYPT_ATTRIBUTES = _CRYPT_ATTRIBUTES;
  1660. {$EXTERNALSYM CRYPT_ATTRIBUTES}
  1661. TCryptAttributes = CRYPT_ATTRIBUTES;
  1662. PCryptAttributes = PCRYPT_ATTRIBUTES;
  1663. //+-------------------------------------------------------------------------
  1664. // Attributes making up a Relative Distinguished Name (CERT_RDN)
  1665. //
  1666. // The interpretation of the Value depends on the dwValueType.
  1667. // See below for a list of the types.
  1668. //--------------------------------------------------------------------------
  1669. PCERT_RDN_ATTR = ^CERT_RDN_ATTR;
  1670. {$EXTERNALSYM PCERT_RDN_ATTR}
  1671. _CERT_RDN_ATTR = record
  1672. pszObjId: LPSTR;
  1673. dwValueType: DWORD;
  1674. Value: CERT_RDN_VALUE_BLOB;
  1675. end;
  1676. {$EXTERNALSYM _CERT_RDN_ATTR}
  1677. CERT_RDN_ATTR = _CERT_RDN_ATTR;
  1678. {$EXTERNALSYM CERT_RDN_ATTR}
  1679. TCertRdnAttr = CERT_RDN_ATTR;
  1680. PCertRdnAttr = PCERT_RDN_ATTR;
  1681. //+-------------------------------------------------------------------------
  1682. // CERT_RDN attribute Object Identifiers
  1683. //--------------------------------------------------------------------------
  1684. // Labeling attribute types:
  1685. const
  1686. szOID_COMMON_NAME = '2.5.4.3'; // case-ignore string
  1687. {$EXTERNALSYM szOID_COMMON_NAME}
  1688. szOID_SUR_NAME = '2.5.4.4'; // case-ignore string
  1689. {$EXTERNALSYM szOID_SUR_NAME}
  1690. szOID_DEVICE_SERIAL_NUMBER = '2.5.4.5'; // printable string
  1691. {$EXTERNALSYM szOID_DEVICE_SERIAL_NUMBER}
  1692. // Geographic attribute types:
  1693. szOID_COUNTRY_NAME = '2.5.4.6'; // printable 2char string
  1694. {$EXTERNALSYM szOID_COUNTRY_NAME}
  1695. szOID_LOCALITY_NAME = '2.5.4.7'; // case-ignore string
  1696. {$EXTERNALSYM szOID_LOCALITY_NAME}
  1697. szOID_STATE_OR_PROVINCE_NAME = '2.5.4.8'; // case-ignore string
  1698. {$EXTERNALSYM szOID_STATE_OR_PROVINCE_NAME}
  1699. szOID_STREET_ADDRESS = '2.5.4.9'; // case-ignore string
  1700. {$EXTERNALSYM szOID_STREET_ADDRESS}
  1701. // Organizational attribute types:
  1702. szOID_ORGANIZATION_NAME = '2.5.4.10'; // case-ignore string
  1703. {$EXTERNALSYM szOID_ORGANIZATION_NAME}
  1704. szOID_ORGANIZATIONAL_UNIT_NAME = '2.5.4.11'; // case-ignore string
  1705. {$EXTERNALSYM szOID_ORGANIZATIONAL_UNIT_NAME}
  1706. szOID_TITLE = '2.5.4.12'; // case-ignore string
  1707. {$EXTERNALSYM szOID_TITLE}
  1708. // Explanatory attribute types:
  1709. szOID_DESCRIPTION = '2.5.4.13'; // case-ignore string
  1710. {$EXTERNALSYM szOID_DESCRIPTION}
  1711. szOID_SEARCH_GUIDE = '2.5.4.14';
  1712. {$EXTERNALSYM szOID_SEARCH_GUIDE}
  1713. szOID_BUSINESS_CATEGORY = '2.5.4.15'; // case-ignore string
  1714. {$EXTERNALSYM szOID_BUSINESS_CATEGORY}
  1715. // Postal addressing attribute types:
  1716. szOID_POSTAL_ADDRESS = '2.5.4.16';
  1717. {$EXTERNALSYM szOID_POSTAL_ADDRESS}
  1718. szOID_POSTAL_CODE = '2.5.4.17'; // case-ignore string
  1719. {$EXTERNALSYM szOID_POSTAL_CODE}
  1720. szOID_POST_OFFICE_BOX = '2.5.4.18'; // case-ignore string
  1721. {$EXTERNALSYM szOID_POST_OFFICE_BOX}
  1722. szOID_PHYSICAL_DELIVERY_OFFICE_NAME = '2.5.4.19'; // case-ignore string
  1723. {$EXTERNALSYM szOID_PHYSICAL_DELIVERY_OFFICE_NAME}
  1724. // Telecommunications addressing attribute types:
  1725. szOID_TELEPHONE_NUMBER = '2.5.4.20'; // telephone number
  1726. {$EXTERNALSYM szOID_TELEPHONE_NUMBER}
  1727. szOID_TELEX_NUMBER = '2.5.4.21';
  1728. {$EXTERNALSYM szOID_TELEX_NUMBER}
  1729. szOID_TELETEXT_TERMINAL_IDENTIFIER = '2.5.4.22';
  1730. {$EXTERNALSYM szOID_TELETEXT_TERMINAL_IDENTIFIER}
  1731. szOID_FACSIMILE_TELEPHONE_NUMBER = '2.5.4.23';
  1732. {$EXTERNALSYM szOID_FACSIMILE_TELEPHONE_NUMBER}
  1733. szOID_X21_ADDRESS = '2.5.4.24'; // numeric string
  1734. {$EXTERNALSYM szOID_X21_ADDRESS}
  1735. szOID_INTERNATIONAL_ISDN_NUMBER = '2.5.4.25'; // numeric string
  1736. {$EXTERNALSYM szOID_INTERNATIONAL_ISDN_NUMBER}
  1737. szOID_REGISTERED_ADDRESS = '2.5.4.26';
  1738. {$EXTERNALSYM szOID_REGISTERED_ADDRESS}
  1739. szOID_DESTINATION_INDICATOR = '2.5.4.27'; // printable string
  1740. {$EXTERNALSYM szOID_DESTINATION_INDICATOR}
  1741. // Preference attribute types:
  1742. szOID_PREFERRED_DELIVERY_METHOD = '2.5.4.28';
  1743. {$EXTERNALSYM szOID_PREFERRED_DELIVERY_METHOD}
  1744. // OSI application attribute types:
  1745. szOID_PRESENTATION_ADDRESS = '2.5.4.29';
  1746. {$EXTERNALSYM szOID_PRESENTATION_ADDRESS}
  1747. szOID_SUPPORTED_APPLICATION_CONTEXT = '2.5.4.30';
  1748. {$EXTERNALSYM szOID_SUPPORTED_APPLICATION_CONTEXT}
  1749. // Relational application attribute types:
  1750. szOID_MEMBER = '2.5.4.31';
  1751. {$EXTERNALSYM szOID_MEMBER}
  1752. szOID_OWNER = '2.5.4.32';
  1753. {$EXTERNALSYM szOID_OWNER}
  1754. szOID_ROLE_OCCUPANT = '2.5.4.33';
  1755. {$EXTERNALSYM szOID_ROLE_OCCUPANT}
  1756. szOID_SEE_ALSO = '2.5.4.34';
  1757. {$EXTERNALSYM szOID_SEE_ALSO}
  1758. // Security attribute types:
  1759. szOID_USER_PASSWORD = '2.5.4.35';
  1760. {$EXTERNALSYM szOID_USER_PASSWORD}
  1761. szOID_USER_CERTIFICATE = '2.5.4.36';
  1762. {$EXTERNALSYM szOID_USER_CERTIFICATE}
  1763. szOID_CA_CERTIFICATE = '2.5.4.37';
  1764. {$EXTERNALSYM szOID_CA_CERTIFICATE}
  1765. szOID_AUTHORITY_REVOCATION_LIST = '2.5.4.38';
  1766. {$EXTERNALSYM szOID_AUTHORITY_REVOCATION_LIST}
  1767. szOID_CERTIFICATE_REVOCATION_LIST = '2.5.4.39';
  1768. {$EXTERNALSYM szOID_CERTIFICATE_REVOCATION_LIST}
  1769. szOID_CROSS_CERTIFICATE_PAIR = '2.5.4.40';
  1770. {$EXTERNALSYM szOID_CROSS_CERTIFICATE_PAIR}
  1771. // Undocumented attribute types???
  1772. //#define szOID_??? "2.5.4.41"
  1773. szOID_GIVEN_NAME = '2.5.4.42'; // case-ignore string
  1774. {$EXTERNALSYM szOID_GIVEN_NAME}
  1775. szOID_INITIALS = '2.5.4.43'; // case-ignore string
  1776. {$EXTERNALSYM szOID_INITIALS}
  1777. // The DN Qualifier attribute type specifies disambiguating information to add
  1778. // to the relative distinguished name of an entry. It is intended to be used
  1779. // for entries held in multiple DSAs which would otherwise have the same name,
  1780. // and that its value be the same in a given DSA for all entries to which
  1781. // the information has been added.
  1782. szOID_DN_QUALIFIER = '2.5.4.46';
  1783. {$EXTERNALSYM szOID_DN_QUALIFIER}
  1784. // Pilot user attribute types:
  1785. szOID_DOMAIN_COMPONENT = '0.9.2342.19200300.100.1.25'; // IA5, UTF8 string
  1786. {$EXTERNALSYM szOID_DOMAIN_COMPONENT}
  1787. // used for PKCS 12 attributes
  1788. szOID_PKCS_12_FRIENDLY_NAME_ATTR = '1.2.840.113549.1.9.20';
  1789. {$EXTERNALSYM szOID_PKCS_12_FRIENDLY_NAME_ATTR}
  1790. szOID_PKCS_12_LOCAL_KEY_ID = '1.2.840.113549.1.9.21';
  1791. {$EXTERNALSYM szOID_PKCS_12_LOCAL_KEY_ID}
  1792. szOID_PKCS_12_KEY_PROVIDER_NAME_ATTR = '1.3.6.1.4.1.311.17.1';
  1793. {$EXTERNALSYM szOID_PKCS_12_KEY_PROVIDER_NAME_ATTR}
  1794. szOID_LOCAL_MACHINE_KEYSET = '1.3.6.1.4.1.311.17.2';
  1795. {$EXTERNALSYM szOID_LOCAL_MACHINE_KEYSET}
  1796. //+-------------------------------------------------------------------------
  1797. // Microsoft CERT_RDN attribute Object Identifiers
  1798. //--------------------------------------------------------------------------
  1799. // Special RDN containing the KEY_ID. Its value type is CERT_RDN_OCTET_STRING.
  1800. szOID_KEYID_RDN = '1.3.6.1.4.1.311.10.7.1';
  1801. {$EXTERNALSYM szOID_KEYID_RDN}
  1802. //+-------------------------------------------------------------------------
  1803. // CERT_RDN Attribute Value Types
  1804. //
  1805. // For RDN_ENCODED_BLOB, the Value's CERT_RDN_VALUE_BLOB is in its encoded
  1806. // representation. Otherwise, its an array of bytes.
  1807. //
  1808. // For all CERT_RDN types, Value.cbData is always the number of bytes, not
  1809. // necessarily the number of elements in the string. For instance,
  1810. // RDN_UNIVERSAL_STRING is an array of ints (cbData == intCnt * 4) and
  1811. // RDN_BMP_STRING is an array of unsigned shorts (cbData == ushortCnt * 2).
  1812. //
  1813. // A RDN_UTF8_STRING is an array of UNICODE characters (cbData == charCnt *2).
  1814. // These UNICODE characters are encoded as UTF8 8 bit characters.
  1815. //
  1816. // For CertDecodeName, two 0 bytes are always appended to the end of the
  1817. // string (ensures a CHAR or WCHAR string is null terminated).
  1818. // These added 0 bytes are't included in the BLOB.cbData.
  1819. //--------------------------------------------------------------------------
  1820. CERT_RDN_ANY_TYPE = 0;
  1821. {$EXTERNALSYM CERT_RDN_ANY_TYPE}
  1822. CERT_RDN_ENCODED_BLOB = 1;
  1823. {$EXTERNALSYM CERT_RDN_ENCODED_BLOB}
  1824. CERT_RDN_OCTET_STRING = 2;
  1825. {$EXTERNALSYM CERT_RDN_OCTET_STRING}
  1826. CERT_RDN_NUMERIC_STRING = 3;
  1827. {$EXTERNALSYM CERT_RDN_NUMERIC_STRING}
  1828. CERT_RDN_PRINTABLE_STRING = 4;
  1829. {$EXTERNALSYM CERT_RDN_PRINTABLE_STRING}
  1830. CERT_RDN_TELETEX_STRING = 5;
  1831. {$EXTERNALSYM CERT_RDN_TELETEX_STRING}
  1832. CERT_RDN_T61_STRING = 5;
  1833. {$EXTERNALSYM CERT_RDN_T61_STRING}
  1834. CERT_RDN_VIDEOTEX_STRING = 6;
  1835. {$EXTERNALSYM CERT_RDN_VIDEOTEX_STRING}
  1836. CERT_RDN_IA5_STRING = 7;
  1837. {$EXTERNALSYM CERT_RDN_IA5_STRING}
  1838. CERT_RDN_GRAPHIC_STRING = 8;
  1839. {$EXTERNALSYM CERT_RDN_GRAPHIC_STRING}
  1840. CERT_RDN_VISIBLE_STRING = 9;
  1841. {$EXTERNALSYM CERT_RDN_VISIBLE_STRING}
  1842. CERT_RDN_ISO646_STRING = 9;
  1843. {$EXTERNALSYM CERT_RDN_ISO646_STRING}
  1844. CERT_RDN_GENERAL_STRING = 10;
  1845. {$EXTERNALSYM CERT_RDN_GENERAL_STRING}
  1846. CERT_RDN_UNIVERSAL_STRING = 11;
  1847. {$EXTERNALSYM CERT_RDN_UNIVERSAL_STRING}
  1848. CERT_RDN_INT4_STRING = 11;
  1849. {$EXTERNALSYM CERT_RDN_INT4_STRING}
  1850. CERT_RDN_BMP_STRING = 12;
  1851. {$EXTERNALSYM CERT_RDN_BMP_STRING}
  1852. CERT_RDN_UNICODE_STRING = 12;
  1853. {$EXTERNALSYM CERT_RDN_UNICODE_STRING}
  1854. CERT_RDN_UTF8_STRING = 13;
  1855. {$EXTERNALSYM CERT_RDN_UTF8_STRING}
  1856. CERT_RDN_TYPE_MASK = $000000FF;
  1857. {$EXTERNALSYM CERT_RDN_TYPE_MASK}
  1858. CERT_RDN_FLAGS_MASK = DWORD($FF000000);
  1859. {$EXTERNALSYM CERT_RDN_FLAGS_MASK}
  1860. //+-------------------------------------------------------------------------
  1861. // Flags that can be or'ed with the above Value Type when encoding/decoding
  1862. //--------------------------------------------------------------------------
  1863. // For encoding: when set, CERT_RDN_T61_STRING is selected instead of
  1864. // CERT_RDN_UNICODE_STRING if all the unicode characters are <= 0xFF
  1865. CERT_RDN_ENABLE_T61_UNICODE_FLAG = DWORD($80000000);
  1866. {$EXTERNALSYM CERT_RDN_ENABLE_T61_UNICODE_FLAG}
  1867. // For encoding: when set, CERT_RDN_UTF8_STRING is selected instead of
  1868. // CERT_RDN_UNICODE_STRING.
  1869. CERT_RDN_ENABLE_UTF8_UNICODE_FLAG = $20000000;
  1870. {$EXTERNALSYM CERT_RDN_ENABLE_UTF8_UNICODE_FLAG}
  1871. // For encoding: when set, the characters aren't checked to see if they
  1872. // are valid for the Value Type.
  1873. CERT_RDN_DISABLE_CHECK_TYPE_FLAG = $40000000;
  1874. {$EXTERNALSYM CERT_RDN_DISABLE_CHECK_TYPE_FLAG}
  1875. // For decoding: by default, CERT_RDN_T61_STRING values are initially decoded
  1876. // as UTF8. If the UTF8 decoding fails, then, decoded as 8 bit characters.
  1877. // Setting this flag skips the initial attempt to decode as UTF8.
  1878. CERT_RDN_DISABLE_IE4_UTF8_FLAG = $01000000;
  1879. {$EXTERNALSYM CERT_RDN_DISABLE_IE4_UTF8_FLAG}
  1880. // Macro to check that the dwValueType is a character string and not an
  1881. // encoded blob or octet string
  1882. function IS_CERT_RDN_CHAR_STRING(X: DWORD): Boolean;
  1883. {$EXTERNALSYM IS_CERT_RDN_CHAR_STRING}
  1884. //+-------------------------------------------------------------------------
  1885. // A CERT_RDN consists of an array of the above attributes
  1886. //--------------------------------------------------------------------------
  1887. type
  1888. PCERT_RDN = ^CERT_RDN;
  1889. {$EXTERNALSYM PCERT_RDN}
  1890. _CERT_RDN = record
  1891. cRDNAttr: DWORD;
  1892. rgRDNAttr: PCERT_RDN_ATTR;
  1893. end;
  1894. {$EXTERNALSYM _CERT_RDN}
  1895. CERT_RDN = _CERT_RDN;
  1896. {$EXTERNALSYM CERT_RDN}
  1897. TCertRdn = CERT_RDN;
  1898. PCertRdn = PCERT_RDN;
  1899. //+-------------------------------------------------------------------------
  1900. // Information stored in a subject's or issuer's name. The information
  1901. // is represented as an array of the above RDNs.
  1902. //--------------------------------------------------------------------------
  1903. PCERT_NAME_INFO = ^CERT_NAME_INFO;
  1904. {$EXTERNALSYM PCERT_NAME_INFO}
  1905. _CERT_NAME_INFO = record
  1906. cRDN: DWORD;
  1907. rgRDN: PCERT_RDN;
  1908. end;
  1909. {$EXTERNALSYM _CERT_NAME_INFO}
  1910. CERT_NAME_INFO = _CERT_NAME_INFO;
  1911. {$EXTERNALSYM CERT_NAME_INFO}
  1912. TCertNameInfo = CERT_NAME_INFO;
  1913. PCertNameInfo = PCERT_NAME_INFO;
  1914. //+-------------------------------------------------------------------------
  1915. // Name attribute value without the Object Identifier
  1916. //
  1917. // The interpretation of the Value depends on the dwValueType.
  1918. // See above for a list of the types.
  1919. //--------------------------------------------------------------------------
  1920. PCERT_NAME_VALUE = ^CERT_NAME_VALUE;
  1921. {$EXTERNALSYM PCERT_NAME_VALUE}
  1922. _CERT_NAME_VALUE = record
  1923. dwValueType: DWORD;
  1924. Value: CERT_RDN_VALUE_BLOB;
  1925. end;
  1926. {$EXTERNALSYM _CERT_NAME_VALUE}
  1927. CERT_NAME_VALUE = _CERT_NAME_VALUE;
  1928. {$EXTERNALSYM CERT_NAME_VALUE}
  1929. TCertNameValue = CERT_NAME_VALUE;
  1930. PCertNameValue = PCERT_NAME_VALUE;
  1931. //+-------------------------------------------------------------------------
  1932. // Public Key Info
  1933. //
  1934. // The PublicKey is the encoded representation of the information as it is
  1935. // stored in the bit string
  1936. //--------------------------------------------------------------------------
  1937. PCERT_PUBLIC_KEY_INFO = ^CERT_PUBLIC_KEY_INFO;
  1938. {$EXTERNALSYM PCERT_PUBLIC_KEY_INFO}
  1939. _CERT_PUBLIC_KEY_INFO = record
  1940. Algorithm: CRYPT_ALGORITHM_IDENTIFIER;
  1941. PublicKey: CRYPT_BIT_BLOB;
  1942. end;
  1943. {$EXTERNALSYM _CERT_PUBLIC_KEY_INFO}
  1944. CERT_PUBLIC_KEY_INFO = _CERT_PUBLIC_KEY_INFO;
  1945. {$EXTERNALSYM CERT_PUBLIC_KEY_INFO}
  1946. TCertPublicKeyInfo = CERT_PUBLIC_KEY_INFO;
  1947. PCertPublicKeyInfo = PCERT_PUBLIC_KEY_INFO;
  1948. const
  1949. CERT_RSA_PUBLIC_KEY_OBJID = szOID_RSA_RSA;
  1950. {$EXTERNALSYM CERT_RSA_PUBLIC_KEY_OBJID}
  1951. CERT_DEFAULT_OID_PUBLIC_KEY_SIGN = szOID_RSA_RSA;
  1952. {$EXTERNALSYM CERT_DEFAULT_OID_PUBLIC_KEY_SIGN}
  1953. CERT_DEFAULT_OID_PUBLIC_KEY_XCHG = szOID_RSA_RSA;
  1954. {$EXTERNALSYM CERT_DEFAULT_OID_PUBLIC_KEY_XCHG}
  1955. //+-------------------------------------------------------------------------
  1956. // structure that contains all the information in a PKCS#8 PrivateKeyInfo
  1957. //--------------------------------------------------------------------------
  1958. type
  1959. PCRYPT_PRIVATE_KEY_INFO = ^CRYPT_PRIVATE_KEY_INFO;
  1960. {$EXTERNALSYM PCRYPT_PRIVATE_KEY_INFO}
  1961. _CRYPT_PRIVATE_KEY_INFO = record
  1962. Version: DWORD;
  1963. Algorithm: CRYPT_ALGORITHM_IDENTIFIER;
  1964. PrivateKey: CRYPT_DER_BLOB;
  1965. pAttributes: PCRYPT_ATTRIBUTES;
  1966. end;
  1967. {$EXTERNALSYM _CRYPT_PRIVATE_KEY_INFO}
  1968. CRYPT_PRIVATE_KEY_INFO = _CRYPT_PRIVATE_KEY_INFO;
  1969. {$EXTERNALSYM CRYPT_PRIVATE_KEY_INFO}
  1970. TCryptPrivateKeyInfo = CRYPT_PRIVATE_KEY_INFO;
  1971. PCryptPrivateKeyInfo = PCRYPT_PRIVATE_KEY_INFO;
  1972. //+-------------------------------------------------------------------------
  1973. // structure that contains all the information in a PKCS#8
  1974. // EncryptedPrivateKeyInfo
  1975. //--------------------------------------------------------------------------
  1976. PCRYPT_ENCRYPTED_PRIVATE_KEY_INFO = ^CRYPT_ENCRYPTED_PRIVATE_KEY_INFO;
  1977. {$EXTERNALSYM PCRYPT_ENCRYPTED_PRIVATE_KEY_INFO}
  1978. _CRYPT_ENCRYPTED_PRIVATE_KEY_INFO = record
  1979. EncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  1980. EncryptedPrivateKey: CRYPT_DATA_BLOB;
  1981. end;
  1982. {$EXTERNALSYM _CRYPT_ENCRYPTED_PRIVATE_KEY_INFO}
  1983. CRYPT_ENCRYPTED_PRIVATE_KEY_INFO = _CRYPT_ENCRYPTED_PRIVATE_KEY_INFO;
  1984. {$EXTERNALSYM CRYPT_ENCRYPTED_PRIVATE_KEY_INFO}
  1985. TCryptEncryptedPrivateKeyInfo = CRYPT_ENCRYPTED_PRIVATE_KEY_INFO;
  1986. PCryptEncryptedPrivateKeyInfo = PCRYPT_ENCRYPTED_PRIVATE_KEY_INFO;
  1987. //+-------------------------------------------------------------------------
  1988. // this callback is given when an EncryptedProvateKeyInfo structure is
  1989. // encountered during ImportPKCS8. the caller is then expected to decrypt
  1990. // the private key and hand back the decrypted contents.
  1991. //
  1992. // the parameters are:
  1993. // Algorithm - the algorithm used to encrypt the PrivateKeyInfo
  1994. // EncryptedPrivateKey - the encrypted private key blob
  1995. // pClearTextKey - a buffer to receive the clear text
  1996. // cbClearTextKey - the number of bytes of the pClearTextKey buffer
  1997. // note the if this is zero then this should be
  1998. // filled in with the size required to decrypt the
  1999. // key into, and pClearTextKey should be ignored
  2000. // pVoidDecryptFunc - this is the pVoid that was passed into the call
  2001. // and is preserved and passed back as context
  2002. //+-------------------------------------------------------------------------
  2003. type
  2004. PCRYPT_DECRYPT_PRIVATE_KEY_FUNC = function(Algorithm: CRYPT_ALGORITHM_IDENTIFIER;
  2005. EncryptedPrivateKey: CRYPT_DATA_BLOB; pbClearTextKey: LPBYTE;
  2006. pcbClearTextKey: LPDWORD; pVoidDecryptFunc: LPVOID): BOOL; stdcall;
  2007. {$EXTERNALSYM PCRYPT_DECRYPT_PRIVATE_KEY_FUNC}
  2008. PCryptDecryptPrivateKeyFunc = PCRYPT_DECRYPT_PRIVATE_KEY_FUNC;
  2009. //+-------------------------------------------------------------------------
  2010. // this callback is given when creating a PKCS8 EncryptedPrivateKeyInfo.
  2011. // The caller is then expected to encrypt the private key and hand back
  2012. // the encrypted contents.
  2013. //
  2014. // the parameters are:
  2015. // Algorithm - the algorithm used to encrypt the PrivateKeyInfo
  2016. // pClearTextPrivateKey - the cleartext private key to be encrypted
  2017. // pbEncryptedKey - the output encrypted private key blob
  2018. // cbEncryptedKey - the number of bytes of the pbEncryptedKey buffer
  2019. // note the if this is zero then this should be
  2020. // filled in with the size required to encrypt the
  2021. // key into, and pbEncryptedKey should be ignored
  2022. // pVoidEncryptFunc - this is the pVoid that was passed into the call
  2023. // and is preserved and passed back as context
  2024. //+-------------------------------------------------------------------------
  2025. type
  2026. PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC = function(pAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER;
  2027. pClearTextPrivateKey: PCRYPT_DATA_BLOB; pbEncryptedKey: LPBYTE;
  2028. pcbEncryptedKey: LPDWORD; pVoidEncryptFunc: LPVOID): BOOL; stdcall;
  2029. {$EXTERNALSYM PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC}
  2030. PCryptEncryptPrivateKeyFunc = PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC;
  2031. //+-------------------------------------------------------------------------
  2032. // this callback is given from the context of a ImportPKCS8 calls. the caller
  2033. // is then expected to hand back an HCRYPTPROV to receive the key being imported
  2034. //
  2035. // the parameters are:
  2036. // pPrivateKeyInfo - pointer to a CRYPT_PRIVATE_KEY_INFO structure which
  2037. // describes the key being imported
  2038. // EncryptedPrivateKey - the encrypted private key blob
  2039. // phCryptProv - a pointer to a HCRRYPTPROV to be filled in
  2040. // pVoidResolveFunc - this is the pVoidResolveFunc passed in by the caller in the
  2041. // CRYPT_PRIVATE_KEY_BLOB_AND_PARAMS struct
  2042. //+-------------------------------------------------------------------------
  2043. type
  2044. PCRYPT_RESOLVE_HCRYPTPROV_FUNC = function(pPrivateKeyInfo: PCRYPT_PRIVATE_KEY_INFO;
  2045. phCryptProv: PHCRYPTPROV; pVoidResolveFunc: LPVOID): BOOL; stdcall;
  2046. {$EXTERNALSYM PCRYPT_RESOLVE_HCRYPTPROV_FUNC}
  2047. PCryptResolveHCryptProvFunc = PCRYPT_RESOLVE_HCRYPTPROV_FUNC;
  2048. //+-------------------------------------------------------------------------
  2049. // this struct contains a PKCS8 private key and two pointers to callback
  2050. // functions, with a corresponding pVoids. the first callback is used to give
  2051. // the caller the opportunity to specify where the key is imported to. the callback
  2052. // passes the caller the algoroithm OID and key size to use in making the decision.
  2053. // the other callback is used to decrypt the private key if the PKCS8 contains an
  2054. // EncryptedPrivateKeyInfo. both pVoids are preserved and passed back to the caller
  2055. // in the respective callback
  2056. //+-------------------------------------------------------------------------
  2057. PCRYPT_PKCS8_IMPORT_PARAMS = ^CRYPT_PKCS8_IMPORT_PARAMS;
  2058. {$EXTERNALSYM PCRYPT_PKCS8_IMPORT_PARAMS}
  2059. _CRYPT_PKCS8_IMPORT_PARAMS = record
  2060. PrivateKey: CRYPT_DIGEST_BLOB; // PKCS8 blob
  2061. pResolvehCryptProvFunc: PCRYPT_RESOLVE_HCRYPTPROV_FUNC; // optional
  2062. pVoidResolveFunc: LPVOID; // optional
  2063. pDecryptPrivateKeyFunc: PCRYPT_DECRYPT_PRIVATE_KEY_FUNC;
  2064. pVoidDecryptFunc: LPVOID;
  2065. end;
  2066. {$EXTERNALSYM _CRYPT_PKCS8_IMPORT_PARAMS}
  2067. CRYPT_PKCS8_IMPORT_PARAMS = _CRYPT_PKCS8_IMPORT_PARAMS;
  2068. {$EXTERNALSYM CRYPT_PKCS8_IMPORT_PARAMS}
  2069. TCryptPkcs8ImportParams = CRYPT_PKCS8_IMPORT_PARAMS;
  2070. PCryptPkcs8ImportParams = PCRYPT_PKCS8_IMPORT_PARAMS;
  2071. CRYPT_PRIVATE_KEY_BLOB_AND_PARAMS = CRYPT_PKCS8_IMPORT_PARAMS;
  2072. {$EXTERNALSYM CRYPT_PRIVATE_KEY_BLOB_AND_PARAMS}
  2073. PCRYPT_PRIVATE_KEY_BLOB_AND_PARAMS = PCRYPT_PKCS8_IMPORT_PARAMS;
  2074. {$EXTERNALSYM PCRYPT_PRIVATE_KEY_BLOB_AND_PARAMS}
  2075. //+-------------------------------------------------------------------------
  2076. // this struct contains information identifying a private key and a pointer
  2077. // to a callback function, with a corresponding pVoid. The callback is used
  2078. // to encrypt the private key. If the pEncryptPrivateKeyFunc is NULL, the
  2079. // key will not be encrypted and an EncryptedPrivateKeyInfo will not be generated.
  2080. // The pVoid is preserved and passed back to the caller in the respective callback
  2081. //+-------------------------------------------------------------------------
  2082. PCRYPT_PKCS8_EXPORT_PARAMS = ^CRYPT_PKCS8_EXPORT_PARAMS;
  2083. {$EXTERNALSYM PCRYPT_PKCS8_EXPORT_PARAMS}
  2084. _CRYPT_PKCS8_EXPORT_PARAMS = record
  2085. hCryptProv: HCRYPTPROV;
  2086. dwKeySpec: DWORD;
  2087. pszPrivateKeyObjId: LPSTR;
  2088. pEncryptPrivateKeyFunc: PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC;
  2089. pVoidEncryptFunc: LPVOID;
  2090. end;
  2091. {$EXTERNALSYM _CRYPT_PKCS8_EXPORT_PARAMS}
  2092. CRYPT_PKCS8_EXPORT_PARAMS = _CRYPT_PKCS8_EXPORT_PARAMS;
  2093. {$EXTERNALSYM CRYPT_PKCS8_EXPORT_PARAMS}
  2094. TCryptPkcs8ExportParams = CRYPT_PKCS8_EXPORT_PARAMS;
  2095. PCryptPkcs8ExportParams = PCRYPT_PKCS8_EXPORT_PARAMS;
  2096. //+-------------------------------------------------------------------------
  2097. // Information stored in a certificate
  2098. //
  2099. // The Issuer, Subject, Algorithm, PublicKey and Extension BLOBs are the
  2100. // encoded representation of the information.
  2101. //--------------------------------------------------------------------------
  2102. PCERT_INFO = ^CERT_INFO;
  2103. {$EXTERNALSYM PCERT_INFO}
  2104. _CERT_INFO = record
  2105. dwVersion: DWORD;
  2106. SerialNumber: CRYPT_INTEGER_BLOB;
  2107. SignatureAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  2108. Issuer: CERT_NAME_BLOB;
  2109. NotBefore: FILETIME;
  2110. NotAfter: FILETIME;
  2111. Subject: CERT_NAME_BLOB;
  2112. SubjectPublicKeyInfo: CERT_PUBLIC_KEY_INFO;
  2113. IssuerUniqueId: CRYPT_BIT_BLOB;
  2114. SubjectUniqueId: CRYPT_BIT_BLOB;
  2115. cExtension: DWORD;
  2116. rgExtension: PCERT_EXTENSION;
  2117. end;
  2118. {$EXTERNALSYM _CERT_INFO}
  2119. CERT_INFO = _CERT_INFO;
  2120. {$EXTERNALSYM CERT_INFO}
  2121. TCertInfo = CERT_INFO;
  2122. PCertInfo = PCERT_INFO;
  2123. //+-------------------------------------------------------------------------
  2124. // Certificate versions
  2125. //--------------------------------------------------------------------------
  2126. const
  2127. CERT_V1 = 0;
  2128. {$EXTERNALSYM CERT_V1}
  2129. CERT_V2 = 1;
  2130. {$EXTERNALSYM CERT_V2}
  2131. CERT_V3 = 2;
  2132. {$EXTERNALSYM CERT_V3}
  2133. //+-------------------------------------------------------------------------
  2134. // Certificate Information Flags
  2135. //--------------------------------------------------------------------------
  2136. CERT_INFO_VERSION_FLAG = 1;
  2137. {$EXTERNALSYM CERT_INFO_VERSION_FLAG}
  2138. CERT_INFO_SERIAL_NUMBER_FLAG = 2;
  2139. {$EXTERNALSYM CERT_INFO_SERIAL_NUMBER_FLAG}
  2140. CERT_INFO_SIGNATURE_ALGORITHM_FLAG = 3;
  2141. {$EXTERNALSYM CERT_INFO_SIGNATURE_ALGORITHM_FLAG}
  2142. CERT_INFO_ISSUER_FLAG = 4;
  2143. {$EXTERNALSYM CERT_INFO_ISSUER_FLAG}
  2144. CERT_INFO_NOT_BEFORE_FLAG = 5;
  2145. {$EXTERNALSYM CERT_INFO_NOT_BEFORE_FLAG}
  2146. CERT_INFO_NOT_AFTER_FLAG = 6;
  2147. {$EXTERNALSYM CERT_INFO_NOT_AFTER_FLAG}
  2148. CERT_INFO_SUBJECT_FLAG = 7;
  2149. {$EXTERNALSYM CERT_INFO_SUBJECT_FLAG}
  2150. CERT_INFO_SUBJECT_PUBLIC_KEY_INFO_FLAG = 8;
  2151. {$EXTERNALSYM CERT_INFO_SUBJECT_PUBLIC_KEY_INFO_FLAG}
  2152. CERT_INFO_ISSUER_UNIQUE_ID_FLAG = 9;
  2153. {$EXTERNALSYM CERT_INFO_ISSUER_UNIQUE_ID_FLAG}
  2154. CERT_INFO_SUBJECT_UNIQUE_ID_FLAG = 10;
  2155. {$EXTERNALSYM CERT_INFO_SUBJECT_UNIQUE_ID_FLAG}
  2156. CERT_INFO_EXTENSION_FLAG = 11;
  2157. {$EXTERNALSYM CERT_INFO_EXTENSION_FLAG}
  2158. //+-------------------------------------------------------------------------
  2159. // An entry in a CRL
  2160. //
  2161. // The Extension BLOBs are the encoded representation of the information.
  2162. //--------------------------------------------------------------------------
  2163. type
  2164. PCRL_ENTRY = ^CRL_ENTRY;
  2165. {$EXTERNALSYM PCRL_ENTRY}
  2166. _CRL_ENTRY = record
  2167. SerialNumber: CRYPT_INTEGER_BLOB;
  2168. RevocationDate: FILETIME;
  2169. cExtension: DWORD;
  2170. rgExtension: PCERT_EXTENSION;
  2171. end;
  2172. {$EXTERNALSYM _CRL_ENTRY}
  2173. CRL_ENTRY = _CRL_ENTRY;
  2174. {$EXTERNALSYM CRL_ENTRY}
  2175. TCrlEntry = CRL_ENTRY;
  2176. PCrlEntry = PCRL_ENTRY;
  2177. //+-------------------------------------------------------------------------
  2178. // Information stored in a CRL
  2179. //
  2180. // The Issuer, Algorithm and Extension BLOBs are the encoded
  2181. // representation of the information.
  2182. //--------------------------------------------------------------------------
  2183. PCRL_INFO = ^CRL_INFO;
  2184. {$EXTERNALSYM PCRL_INFO}
  2185. _CRL_INFO = record
  2186. dwVersion: DWORD;
  2187. SignatureAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  2188. Issuer: CERT_NAME_BLOB;
  2189. ThisUpdate: FILETIME;
  2190. NextUpdate: FILETIME;
  2191. cCRLEntry: DWORD;
  2192. rgCRLEntry: PCRL_ENTRY;
  2193. cExtension: DWORD;
  2194. rgExtension: PCERT_EXTENSION;
  2195. end;
  2196. {$EXTERNALSYM _CRL_INFO}
  2197. CRL_INFO = _CRL_INFO;
  2198. {$EXTERNALSYM CRL_INFO}
  2199. TCrlInfo = CRL_INFO;
  2200. PCrlInfo = PCRL_INFO;
  2201. //+-------------------------------------------------------------------------
  2202. // CRL versions
  2203. //--------------------------------------------------------------------------
  2204. const
  2205. CRL_V1 = 0;
  2206. {$EXTERNALSYM CRL_V1}
  2207. CRL_V2 = 1;
  2208. {$EXTERNALSYM CRL_V2}
  2209. //+-------------------------------------------------------------------------
  2210. // Information stored in a certificate request
  2211. //
  2212. // The Subject, Algorithm, PublicKey and Attribute BLOBs are the encoded
  2213. // representation of the information.
  2214. //--------------------------------------------------------------------------
  2215. type
  2216. PCERT_REQUEST_INFO = ^CERT_REQUEST_INFO;
  2217. {$EXTERNALSYM PCERT_REQUEST_INFO}
  2218. _CERT_REQUEST_INFO = record
  2219. dwVersion: DWORD;
  2220. Subject: CERT_NAME_BLOB;
  2221. SubjectPublicKeyInfo: CERT_PUBLIC_KEY_INFO;
  2222. cAttribute: DWORD;
  2223. rgAttribute: PCRYPT_ATTRIBUTE;
  2224. end;
  2225. {$EXTERNALSYM _CERT_REQUEST_INFO}
  2226. CERT_REQUEST_INFO = _CERT_REQUEST_INFO;
  2227. {$EXTERNALSYM CERT_REQUEST_INFO}
  2228. TCertRequestInfo = CERT_REQUEST_INFO;
  2229. PCertRequestInfo = PCERT_REQUEST_INFO;
  2230. //+-------------------------------------------------------------------------
  2231. // Certificate Request versions
  2232. //--------------------------------------------------------------------------
  2233. const
  2234. CERT_REQUEST_V1 = 0;
  2235. {$EXTERNALSYM CERT_REQUEST_V1}
  2236. //+-------------------------------------------------------------------------
  2237. // Information stored in Netscape's Keygen request
  2238. //--------------------------------------------------------------------------
  2239. type
  2240. PCERT_KEYGEN_REQUEST_INFO = ^CERT_KEYGEN_REQUEST_INFO;
  2241. {$EXTERNALSYM PCERT_KEYGEN_REQUEST_INFO}
  2242. _CERT_KEYGEN_REQUEST_INFO = record
  2243. dwVersion: DWORD;
  2244. SubjectPublicKeyInfo: CERT_PUBLIC_KEY_INFO;
  2245. pwszChallengeString: LPWSTR; // encoded as IA5
  2246. end;
  2247. {$EXTERNALSYM _CERT_KEYGEN_REQUEST_INFO}
  2248. CERT_KEYGEN_REQUEST_INFO = _CERT_KEYGEN_REQUEST_INFO;
  2249. {$EXTERNALSYM CERT_KEYGEN_REQUEST_INFO}
  2250. TCertKeygenRequestInfo = CERT_KEYGEN_REQUEST_INFO;
  2251. PCertKeygenRequestInfo = PCERT_KEYGEN_REQUEST_INFO;
  2252. const
  2253. CERT_KEYGEN_REQUEST_V1 = 0;
  2254. {$EXTERNALSYM CERT_KEYGEN_REQUEST_V1}
  2255. //+-------------------------------------------------------------------------
  2256. // Certificate, CRL, Certificate Request or Keygen Request Signed Content
  2257. //
  2258. // The "to be signed" encoded content plus its signature. The ToBeSigned
  2259. // is the encoded CERT_INFO, CRL_INFO, CERT_REQUEST_INFO or
  2260. // CERT_KEYGEN_REQUEST_INFO.
  2261. //--------------------------------------------------------------------------
  2262. type
  2263. PCERT_SIGNED_CONTENT_INFO = ^CERT_SIGNED_CONTENT_INFO;
  2264. {$EXTERNALSYM PCERT_SIGNED_CONTENT_INFO}
  2265. _CERT_SIGNED_CONTENT_INFO = record
  2266. ToBeSigned: CRYPT_DER_BLOB;
  2267. SignatureAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  2268. Signature: CRYPT_BIT_BLOB;
  2269. end;
  2270. {$EXTERNALSYM _CERT_SIGNED_CONTENT_INFO}
  2271. CERT_SIGNED_CONTENT_INFO = _CERT_SIGNED_CONTENT_INFO;
  2272. {$EXTERNALSYM CERT_SIGNED_CONTENT_INFO}
  2273. TCertSignedContentInfo = CERT_SIGNED_CONTENT_INFO;
  2274. PCertSignedContentInfo = PCERT_SIGNED_CONTENT_INFO;
  2275. //+-------------------------------------------------------------------------
  2276. // Certificate Trust List (CTL)
  2277. //--------------------------------------------------------------------------
  2278. //+-------------------------------------------------------------------------
  2279. // CTL Usage. Also used for EnhancedKeyUsage extension.
  2280. //--------------------------------------------------------------------------
  2281. PCTL_USAGE = ^CTL_USAGE;
  2282. {$EXTERNALSYM PCTL_USAGE}
  2283. _CTL_USAGE = record
  2284. cUsageIdentifier: DWORD;
  2285. rgpszUsageIdentifier: LPSTR; // array of pszObjId
  2286. end;
  2287. {$EXTERNALSYM _CTL_USAGE}
  2288. CTL_USAGE = _CTL_USAGE;
  2289. {$EXTERNALSYM CTL_USAGE}
  2290. TCtlUsage = CTL_USAGE;
  2291. PCtlUsage = PCTL_USAGE;
  2292. CERT_ENHKEY_USAGE = CTL_USAGE;
  2293. {$EXTERNALSYM CERT_ENHKEY_USAGE}
  2294. PCERT_ENHKEY_USAGE = PCTL_USAGE;
  2295. {$EXTERNALSYM PCERT_ENHKEY_USAGE}
  2296. //+-------------------------------------------------------------------------
  2297. // An entry in a CTL
  2298. //--------------------------------------------------------------------------
  2299. PCTL_ENTRY = ^CTL_ENTRY;
  2300. {$EXTERNALSYM PCTL_ENTRY}
  2301. _CTL_ENTRY = record
  2302. SubjectIdentifier: CRYPT_DATA_BLOB; // For example, its hash
  2303. cAttribute: DWORD;
  2304. rgAttribute: PCRYPT_ATTRIBUTE; // OPTIONAL
  2305. end;
  2306. {$EXTERNALSYM _CTL_ENTRY}
  2307. CTL_ENTRY = _CTL_ENTRY;
  2308. {$EXTERNALSYM CTL_ENTRY}
  2309. TCtlEntry = CTL_ENTRY;
  2310. PCtlEntry = PCTL_ENTRY;
  2311. //+-------------------------------------------------------------------------
  2312. // Information stored in a CTL
  2313. //--------------------------------------------------------------------------
  2314. PCTL_INFO = ^CTL_INFO;
  2315. {$EXTERNALSYM PCTL_INFO}
  2316. _CTL_INFO = record
  2317. dwVersion: DWORD;
  2318. SubjectUsage: CTL_USAGE;
  2319. ListIdentifier: CRYPT_DATA_BLOB; // OPTIONAL
  2320. SequenceNumber: CRYPT_INTEGER_BLOB; // OPTIONAL
  2321. ThisUpdate: FILETIME;
  2322. NextUpdate: FILETIME; // OPTIONAL
  2323. SubjectAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  2324. cCTLEntry: DWORD;
  2325. rgCTLEntry: PCTL_ENTRY; // OPTIONAL
  2326. cExtension: DWORD;
  2327. rgExtension: PCERT_EXTENSION; // OPTIONAL
  2328. end;
  2329. {$EXTERNALSYM _CTL_INFO}
  2330. CTL_INFO = _CTL_INFO;
  2331. {$EXTERNALSYM CTL_INFO}
  2332. TCtlInfo = CTL_INFO;
  2333. PCtlInfo = PCTL_INFO;
  2334. //+-------------------------------------------------------------------------
  2335. // CTL versions
  2336. //--------------------------------------------------------------------------
  2337. const
  2338. CTL_V1 = 0;
  2339. {$EXTERNALSYM CTL_V1}
  2340. //+-------------------------------------------------------------------------
  2341. // TimeStamp Request
  2342. //
  2343. // The pszTimeStamp is the OID for the Time type requested
  2344. // The pszContentType is the Content Type OID for the content, usually DATA
  2345. // The Content is a un-decoded blob
  2346. //--------------------------------------------------------------------------
  2347. type
  2348. PCRYPT_TIME_STAMP_REQUEST_INFO = ^CRYPT_TIME_STAMP_REQUEST_INFO;
  2349. {$EXTERNALSYM PCRYPT_TIME_STAMP_REQUEST_INFO}
  2350. _CRYPT_TIME_STAMP_REQUEST_INFO = record
  2351. pszTimeStampAlgorithm: LPSTR; // pszObjId
  2352. pszContentType: LPSTR; // pszObjId
  2353. Content: CRYPT_OBJID_BLOB;
  2354. cAttribute: DWORD;
  2355. rgAttribute: PCRYPT_ATTRIBUTE;
  2356. end;
  2357. {$EXTERNALSYM _CRYPT_TIME_STAMP_REQUEST_INFO}
  2358. CRYPT_TIME_STAMP_REQUEST_INFO = _CRYPT_TIME_STAMP_REQUEST_INFO;
  2359. {$EXTERNALSYM CRYPT_TIME_STAMP_REQUEST_INFO}
  2360. TCryptTimeStampRequestInfo = CRYPT_TIME_STAMP_REQUEST_INFO;
  2361. PCryptTimeStampRequestInfo = PCRYPT_TIME_STAMP_REQUEST_INFO;
  2362. //+-------------------------------------------------------------------------
  2363. // Name Value Attribute
  2364. //--------------------------------------------------------------------------
  2365. PCRYPT_ENROLLMENT_NAME_VALUE_PAIR = ^CRYPT_ENROLLMENT_NAME_VALUE_PAIR;
  2366. {$EXTERNALSYM PCRYPT_ENROLLMENT_NAME_VALUE_PAIR}
  2367. _CRYPT_ENROLLMENT_NAME_VALUE_PAIR = record
  2368. pwszName: LPWSTR;
  2369. pwszValue: LPWSTR;
  2370. end;
  2371. {$EXTERNALSYM _CRYPT_ENROLLMENT_NAME_VALUE_PAIR}
  2372. CRYPT_ENROLLMENT_NAME_VALUE_PAIR = _CRYPT_ENROLLMENT_NAME_VALUE_PAIR;
  2373. {$EXTERNALSYM CRYPT_ENROLLMENT_NAME_VALUE_PAIR}
  2374. TCryptEnrollmentNameValuePair = CRYPT_ENROLLMENT_NAME_VALUE_PAIR;
  2375. PCryptEnrollmentNameValuePair = PCRYPT_ENROLLMENT_NAME_VALUE_PAIR;
  2376. //+-------------------------------------------------------------------------
  2377. // CSP Provider
  2378. //--------------------------------------------------------------------------
  2379. PCRYPT_CSP_PROVIDER = ^CRYPT_CSP_PROVIDER;
  2380. {$EXTERNALSYM PCRYPT_CSP_PROVIDER}
  2381. _CRYPT_CSP_PROVIDER = record
  2382. dwKeySpec: DWORD;
  2383. pwszProviderName: LPWSTR;
  2384. Signature: CRYPT_BIT_BLOB;
  2385. end;
  2386. {$EXTERNALSYM _CRYPT_CSP_PROVIDER}
  2387. CRYPT_CSP_PROVIDER = _CRYPT_CSP_PROVIDER;
  2388. {$EXTERNALSYM CRYPT_CSP_PROVIDER}
  2389. TCryptCspProvider = CRYPT_CSP_PROVIDER;
  2390. PCryptCspProvider = PCRYPT_CSP_PROVIDER;
  2391. //+-------------------------------------------------------------------------
  2392. // Certificate and Message encoding types
  2393. //
  2394. // The encoding type is a DWORD containing both the certificate and message
  2395. // encoding types. The certificate encoding type is stored in the LOWORD.
  2396. // The message encoding type is stored in the HIWORD. Some functions or
  2397. // structure fields require only one of the encoding types. The following
  2398. // naming convention is used to indicate which encoding type(s) are
  2399. // required:
  2400. // dwEncodingType (both encoding types are required)
  2401. // dwMsgAndCertEncodingType (both encoding types are required)
  2402. // dwMsgEncodingType (only msg encoding type is required)
  2403. // dwCertEncodingType (only cert encoding type is required)
  2404. //
  2405. // Its always acceptable to specify both.
  2406. //--------------------------------------------------------------------------
  2407. const
  2408. CERT_ENCODING_TYPE_MASK = $0000FFFF;
  2409. {$EXTERNALSYM CERT_ENCODING_TYPE_MASK}
  2410. CMSG_ENCODING_TYPE_MASK = DWORD($FFFF0000);
  2411. {$EXTERNALSYM CMSG_ENCODING_TYPE_MASK}
  2412. function GET_CERT_ENCODING_TYPE(X: DWORD): DWORD;
  2413. {$EXTERNALSYM GET_CERT_ENCODING_TYPE}
  2414. function GET_CMSG_ENCODING_TYPE(X: DWORD): DWORD;
  2415. {$EXTERNALSYM GET_CMSG_ENCODING_TYPE}
  2416. const
  2417. CRYPT_ASN_ENCODING = $00000001;
  2418. {$EXTERNALSYM CRYPT_ASN_ENCODING}
  2419. CRYPT_NDR_ENCODING = $00000002;
  2420. {$EXTERNALSYM CRYPT_NDR_ENCODING}
  2421. X509_ASN_ENCODING = $00000001;
  2422. {$EXTERNALSYM X509_ASN_ENCODING}
  2423. X509_NDR_ENCODING = $00000002;
  2424. {$EXTERNALSYM X509_NDR_ENCODING}
  2425. PKCS_7_ASN_ENCODING = $00010000;
  2426. {$EXTERNALSYM PKCS_7_ASN_ENCODING}
  2427. PKCS_7_NDR_ENCODING = $00020000;
  2428. {$EXTERNALSYM PKCS_7_NDR_ENCODING}
  2429. //+-------------------------------------------------------------------------
  2430. // format the specified data structure according to the certificate
  2431. // encoding type.
  2432. //
  2433. // The default behavior of CryptFormatObject is to return single line
  2434. // display of the encoded data, that is, each subfield will be concatenated with
  2435. // a ", " on one line. If user prefers to display the data in multiple line,
  2436. // set the flag CRYPT_FORMAT_STR_MULTI_LINE, that is, each subfield will be displayed
  2437. // on a seperate line.
  2438. //
  2439. // If there is no formatting routine installed or registered
  2440. // for the lpszStructType, the hex dump of the encoded BLOB will be returned.
  2441. // User can set the flag CRYPT_FORMAT_STR_NO_HEX to disable the hex dump.
  2442. //--------------------------------------------------------------------------
  2443. function CryptFormatObject(dwCertEncodingType, dwFormatType, dwFormatStrType: DWORD;
  2444. pFormatStruct: Pointer; lpszStructType: LPCSTR; pbEncoded: LPBYTE;
  2445. cbEncoded: DWORD; pbFormat: Pointer; var pcbFormat: DWORD): BOOL; stdcall;
  2446. {$EXTERNALSYM CryptFormatObject}
  2447. //-------------------------------------------------------------------------
  2448. // constants for dwFormatStrType of function CryptFormatObject
  2449. //-------------------------------------------------------------------------
  2450. const
  2451. CRYPT_FORMAT_STR_MULTI_LINE = $0001;
  2452. {$EXTERNALSYM CRYPT_FORMAT_STR_MULTI_LINE}
  2453. CRYPT_FORMAT_STR_NO_HEX = $0010;
  2454. {$EXTERNALSYM CRYPT_FORMAT_STR_NO_HEX}
  2455. //-------------------------------------------------------------------------
  2456. // constants for dwFormatType of function CryptFormatObject
  2457. // when format X509_NAME or X509_UNICODE_NAME
  2458. //-------------------------------------------------------------------------
  2459. // Just get the simple string
  2460. CRYPT_FORMAT_SIMPLE = $0001;
  2461. {$EXTERNALSYM CRYPT_FORMAT_SIMPLE}
  2462. //Put an attribute name infront of the attribute
  2463. //such as "O=Microsoft,DN=xiaohs"
  2464. CRYPT_FORMAT_X509 = $0002;
  2465. {$EXTERNALSYM CRYPT_FORMAT_X509}
  2466. //Put an OID infront of the simple string, such as
  2467. //"2.5.4.22=Microsoft,2.5.4.3=xiaohs"
  2468. CRYPT_FORMAT_OID = $0004;
  2469. {$EXTERNALSYM CRYPT_FORMAT_OID}
  2470. //Put a ";" between each RDN. The default is ","
  2471. CRYPT_FORMAT_RDN_SEMICOLON = $0100;
  2472. {$EXTERNALSYM CRYPT_FORMAT_RDN_SEMICOLON}
  2473. //Put a "\n" between each RDN.
  2474. CRYPT_FORMAT_RDN_CRLF = $0200;
  2475. {$EXTERNALSYM CRYPT_FORMAT_RDN_CRLF}
  2476. //Unquote the DN value, which is quoated by default va the following
  2477. //rules: if the DN contains leading or trailing
  2478. //white space or one of the following characters: ",", "+", "=",
  2479. //""", "\n", "<", ">", "#" or ";". The quoting character is ".
  2480. //If the DN Value contains a " it is double quoted ("").
  2481. CRYPT_FORMAT_RDN_UNQUOTE = $0400;
  2482. {$EXTERNALSYM CRYPT_FORMAT_RDN_UNQUOTE}
  2483. //reverse the order of the RDNs before converting to the string
  2484. CRYPT_FORMAT_RDN_REVERSE = $0800;
  2485. {$EXTERNALSYM CRYPT_FORMAT_RDN_REVERSE}
  2486. //-------------------------------------------------------------------------
  2487. // contants dwFormatType of function CryptFormatObject when format a DN.:
  2488. //
  2489. // The following three values are defined in the section above:
  2490. // CRYPT_FORMAT_SIMPLE: Just a simple string
  2491. // such as "Microsoft+xiaohs+NT"
  2492. // CRYPT_FORMAT_X509 Put an attribute name infront of the attribute
  2493. // such as "O=Microsoft+xiaohs+NT"
  2494. //
  2495. // CRYPT_FORMAT_OID Put an OID infront of the simple string,
  2496. // such as "2.5.4.22=Microsoft+xiaohs+NT"
  2497. //
  2498. // Additional values are defined as following:
  2499. //----------------------------------------------------------------------------
  2500. //Put a "," between each value. Default is "+"
  2501. CRYPT_FORMAT_COMMA = $1000;
  2502. {$EXTERNALSYM CRYPT_FORMAT_COMMA}
  2503. //Put a ";" between each value
  2504. CRYPT_FORMAT_SEMICOLON = CRYPT_FORMAT_RDN_SEMICOLON;
  2505. {$EXTERNALSYM CRYPT_FORMAT_SEMICOLON}
  2506. //Put a "\n" between each value
  2507. CRYPT_FORMAT_CRLF = CRYPT_FORMAT_RDN_CRLF;
  2508. {$EXTERNALSYM CRYPT_FORMAT_CRLF}
  2509. //+-------------------------------------------------------------------------
  2510. // Encode / decode the specified data structure according to the certificate
  2511. // encoding type.
  2512. //
  2513. // See below for a list of the predefined data structures.
  2514. //--------------------------------------------------------------------------
  2515. type
  2516. PFN_CRYPT_ALLOC = function(cbSize: size_t): LPVOID; stdcall;
  2517. {$EXTERNALSYM PFN_CRYPT_ALLOC}
  2518. PFN_CRYPT_FREE = procedure(pv: LPVOID); stdcall;
  2519. {$EXTERNALSYM PFN_CRYPT_FREE}
  2520. PCRYPT_ENCODE_PARA = ^CRYPT_ENCODE_PARA;
  2521. {$EXTERNALSYM PCRYPT_ENCODE_PARA}
  2522. _CRYPT_ENCODE_PARA = record
  2523. cbSize: DWORD;
  2524. pfnAlloc: PFN_CRYPT_ALLOC; // OPTIONAL
  2525. pfnFree: PFN_CRYPT_FREE; // OPTIONAL
  2526. end;
  2527. {$EXTERNALSYM _CRYPT_ENCODE_PARA}
  2528. CRYPT_ENCODE_PARA = _CRYPT_ENCODE_PARA;
  2529. {$EXTERNALSYM CRYPT_ENCODE_PARA}
  2530. TCryptEncodePara = CRYPT_ENCODE_PARA;
  2531. PCryptEncodePara = PCRYPT_ENCODE_PARA;
  2532. function CryptEncodeObjectEx(dwCertEncodingType: DWORD; lpszStructType: LPCSTR;
  2533. pvStructInfo: Pointer; dwFlags: DWORD; pEncodePara: PCRYPT_ENCODE_PARA;
  2534. pvEncoded: Pointer; var pcbEncoded: DWORD): BOOL; stdcall;
  2535. {$EXTERNALSYM CryptEncodeObjectEx}
  2536. function CryptEncodeObject(dwCertEncodingType: DWORD; lpszStructType: LPCSTR;
  2537. pvStructInfo: Pointer; pbEncoded: LPBYTE; var pcbEncoded: DWORD): BOOL; stdcall;
  2538. {$EXTERNALSYM CryptEncodeObject}
  2539. // By default the signature bytes are reversed. The following flag can
  2540. // be set to inhibit the byte reversal.
  2541. //
  2542. // This flag is applicable to
  2543. // X509_CERT_TO_BE_SIGNED
  2544. const
  2545. CRYPT_ENCODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG = $8;
  2546. {$EXTERNALSYM CRYPT_ENCODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG}
  2547. // When the following flag is set the called encode function allocates
  2548. // memory for the encoded bytes. A pointer to the allocated bytes
  2549. // is returned in pvEncoded. If pEncodePara or pEncodePara->pfnAlloc is
  2550. // NULL, then, LocalAlloc is called for the allocation and LocalFree must
  2551. // be called to do the free. Otherwise, pEncodePara->pfnAlloc is called
  2552. // for the allocation.
  2553. //
  2554. // *pcbEncoded is ignored on input and updated with the length of the
  2555. // allocated, encoded bytes.
  2556. //
  2557. // If pfnAlloc is set, then, pfnFree should also be set.
  2558. CRYPT_ENCODE_ALLOC_FLAG = $8000;
  2559. {$EXTERNALSYM CRYPT_ENCODE_ALLOC_FLAG}
  2560. // The following flag is applicable when encoding X509_UNICODE_NAME.
  2561. // When set, CERT_RDN_T61_STRING is selected instead of
  2562. // CERT_RDN_UNICODE_STRING if all the unicode characters are <= 0xFF
  2563. CRYPT_UNICODE_NAME_ENCODE_ENABLE_T61_UNICODE_FLAG = CERT_RDN_ENABLE_T61_UNICODE_FLAG;
  2564. {$EXTERNALSYM CRYPT_UNICODE_NAME_ENCODE_ENABLE_T61_UNICODE_FLAG}
  2565. // The following flag is applicable when encoding X509_UNICODE_NAME.
  2566. // When set, CERT_RDN_UTF8_STRING is selected instead of
  2567. // CERT_RDN_UNICODE_STRING.
  2568. CRYPT_UNICODE_NAME_ENCODE_ENABLE_UTF8_UNICODE_FLAG = CERT_RDN_ENABLE_UTF8_UNICODE_FLAG;
  2569. {$EXTERNALSYM CRYPT_UNICODE_NAME_ENCODE_ENABLE_UTF8_UNICODE_FLAG}
  2570. // The following flag is applicable when encoding X509_UNICODE_NAME,
  2571. // X509_UNICODE_NAME_VALUE or X509_UNICODE_ANY_STRING.
  2572. // When set, the characters aren't checked to see if they
  2573. // are valid for the specified Value Type.
  2574. CRYPT_UNICODE_NAME_ENCODE_DISABLE_CHECK_TYPE_FLAG = CERT_RDN_DISABLE_CHECK_TYPE_FLAG;
  2575. {$EXTERNALSYM CRYPT_UNICODE_NAME_ENCODE_DISABLE_CHECK_TYPE_FLAG}
  2576. // The following flag is applicable when encoding the PKCS_SORTED_CTL. This
  2577. // flag should be set if the identifier for the TrustedSubjects is a hash,
  2578. // such as, MD5 or SHA1.
  2579. CRYPT_SORTED_CTL_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG = $10000;
  2580. {$EXTERNALSYM CRYPT_SORTED_CTL_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG}
  2581. type
  2582. PCRYPT_DECODE_PARA = ^CRYPT_DECODE_PARA;
  2583. {$EXTERNALSYM PCRYPT_DECODE_PARA}
  2584. _CRYPT_DECODE_PARA = record
  2585. cbSize: DWORD;
  2586. pfnAlloc: PFN_CRYPT_ALLOC; // OPTIONAL
  2587. pfnFree: PFN_CRYPT_FREE; // OPTIONAL
  2588. end;
  2589. {$EXTERNALSYM _CRYPT_DECODE_PARA}
  2590. CRYPT_DECODE_PARA = _CRYPT_DECODE_PARA;
  2591. {$EXTERNALSYM CRYPT_DECODE_PARA}
  2592. TCryptDecodePara = CRYPT_DECODE_PARA;
  2593. PCryptDecodePara = PCRYPT_DECODE_PARA;
  2594. function CryptDecodeObjectEx(dwCertEncodingType: DWORD; lpszStructType: LPCSTR;
  2595. pbEncoded: Pointer; cbEncoded, dwFlags: DWORD; pDecodePara: PCRYPT_DECODE_PARA;
  2596. pvStructInfo: Pointer; var pcbStructInfo: DWORD): BOOL; stdcall;
  2597. {$EXTERNALSYM CryptDecodeObjectEx}
  2598. function CryptDecodeObject(dwCertEncodingType: DWORD; lpszStructType: LPCSTR;
  2599. pbEncoded: LPBYTE; cbEncoded, dwFlags: DWORD; pvStructInfo: Pointer;
  2600. var pcbStructInfo: DWORD): BOOL; stdcall;
  2601. {$EXTERNALSYM CryptDecodeObject}
  2602. // When the following flag is set the nocopy optimization is enabled.
  2603. // This optimization where appropriate, updates the pvStructInfo fields
  2604. // to point to content residing within pbEncoded instead of making a copy
  2605. // of and appending to pvStructInfo.
  2606. //
  2607. // Note, when set, pbEncoded can't be freed until pvStructInfo is freed.
  2608. const
  2609. CRYPT_DECODE_NOCOPY_FLAG = $1;
  2610. {$EXTERNALSYM CRYPT_DECODE_NOCOPY_FLAG}
  2611. // For CryptDecodeObject(), by default the pbEncoded is the "to be signed"
  2612. // plus its signature. Set the following flag, if pbEncoded points to only
  2613. // the "to be signed".
  2614. //
  2615. // This flag is applicable to
  2616. // X509_CERT_TO_BE_SIGNED
  2617. // X509_CERT_CRL_TO_BE_SIGNED
  2618. // X509_CERT_REQUEST_TO_BE_SIGNED
  2619. // X509_KEYGEN_REQUEST_TO_BE_SIGNED
  2620. CRYPT_DECODE_TO_BE_SIGNED_FLAG = $2;
  2621. {$EXTERNALSYM CRYPT_DECODE_TO_BE_SIGNED_FLAG}
  2622. // When the following flag is set, the OID strings are allocated in
  2623. // crypt32.dll and shared instead of being copied into the returned
  2624. // data structure. This flag may be set if crypt32.dll isn't unloaded
  2625. // before the caller is unloaded.
  2626. CRYPT_DECODE_SHARE_OID_STRING_FLAG = $4;
  2627. {$EXTERNALSYM CRYPT_DECODE_SHARE_OID_STRING_FLAG}
  2628. // By default the signature bytes are reversed. The following flag can
  2629. // be set to inhibit the byte reversal.
  2630. //
  2631. // This flag is applicable to
  2632. // X509_CERT_TO_BE_SIGNED
  2633. CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG = $8;
  2634. {$EXTERNALSYM CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG}
  2635. // When the following flag is set the called decode function allocates
  2636. // memory for the decoded structure. A pointer to the allocated structure
  2637. // is returned in pvStructInfo. If pDecodePara or pDecodePara->pfnAlloc is
  2638. // NULL, then, LocalAlloc is called for the allocation and LocalFree must
  2639. // be called to do the free. Otherwise, pDecodePara->pfnAlloc is called
  2640. // for the allocation.
  2641. //
  2642. // *pcbStructInfo is ignored on input and updated with the length of the
  2643. // allocated, decoded structure.
  2644. //
  2645. // This flag may also be set in the CryptDecodeObject API. Since
  2646. // CryptDecodeObject doesn't take a pDecodePara, LocalAlloc is always
  2647. // called for the allocation which must be freed by calling LocalFree.
  2648. CRYPT_DECODE_ALLOC_FLAG = $8000;
  2649. {$EXTERNALSYM CRYPT_DECODE_ALLOC_FLAG}
  2650. // The following flag is applicable when decoding X509_UNICODE_NAME,
  2651. // X509_UNICODE_NAME_VALUE or X509_UNICODE_ANY_STRING.
  2652. // By default, CERT_RDN_T61_STRING values are initially decoded
  2653. // as UTF8. If the UTF8 decoding fails, then, decoded as 8 bit characters.
  2654. // Setting this flag skips the initial attempt to decode as UTF8.
  2655. CRYPT_UNICODE_NAME_DECODE_DISABLE_IE4_UTF8_FLAG = CERT_RDN_DISABLE_IE4_UTF8_FLAG;
  2656. {$EXTERNALSYM CRYPT_UNICODE_NAME_DECODE_DISABLE_IE4_UTF8_FLAG}
  2657. //+-------------------------------------------------------------------------
  2658. // Predefined X509 certificate data structures that can be encoded / decoded.
  2659. //--------------------------------------------------------------------------
  2660. CRYPT_ENCODE_DECODE_NONE = 0;
  2661. {$EXTERNALSYM CRYPT_ENCODE_DECODE_NONE}
  2662. X509_CERT = LPCSTR(1);
  2663. {$EXTERNALSYM X509_CERT}
  2664. X509_CERT_TO_BE_SIGNED = LPCSTR(2);
  2665. {$EXTERNALSYM X509_CERT_TO_BE_SIGNED}
  2666. X509_CERT_CRL_TO_BE_SIGNED = LPCSTR(3);
  2667. {$EXTERNALSYM X509_CERT_CRL_TO_BE_SIGNED}
  2668. X509_CERT_REQUEST_TO_BE_SIGNED = LPCSTR(4);
  2669. {$EXTERNALSYM X509_CERT_REQUEST_TO_BE_SIGNED}
  2670. X509_EXTENSIONS = LPCSTR(5);
  2671. {$EXTERNALSYM X509_EXTENSIONS}
  2672. X509_NAME_VALUE = LPCSTR(6);
  2673. {$EXTERNALSYM X509_NAME_VALUE}
  2674. X509_NAME = LPCSTR(7);
  2675. {$EXTERNALSYM X509_NAME}
  2676. X509_PUBLIC_KEY_INFO = LPCSTR(8);
  2677. {$EXTERNALSYM X509_PUBLIC_KEY_INFO}
  2678. //+-------------------------------------------------------------------------
  2679. // Predefined X509 certificate extension data structures that can be
  2680. // encoded / decoded.
  2681. //--------------------------------------------------------------------------
  2682. X509_AUTHORITY_KEY_ID = LPCSTR(9);
  2683. {$EXTERNALSYM X509_AUTHORITY_KEY_ID}
  2684. X509_KEY_ATTRIBUTES = LPCSTR(10);
  2685. {$EXTERNALSYM X509_KEY_ATTRIBUTES}
  2686. X509_KEY_USAGE_RESTRICTION = LPCSTR(11);
  2687. {$EXTERNALSYM X509_KEY_USAGE_RESTRICTION}
  2688. X509_ALTERNATE_NAME = LPCSTR(12);
  2689. {$EXTERNALSYM X509_ALTERNATE_NAME}
  2690. X509_BASIC_CONSTRAINTS = LPCSTR(13);
  2691. {$EXTERNALSYM X509_BASIC_CONSTRAINTS}
  2692. X509_KEY_USAGE = LPCSTR(14);
  2693. {$EXTERNALSYM X509_KEY_USAGE}
  2694. X509_BASIC_CONSTRAINTS2 = LPCSTR(15);
  2695. {$EXTERNALSYM X509_BASIC_CONSTRAINTS2}
  2696. X509_CERT_POLICIES = LPCSTR(16);
  2697. {$EXTERNALSYM X509_CERT_POLICIES}
  2698. //+-------------------------------------------------------------------------
  2699. // Additional predefined data structures that can be encoded / decoded.
  2700. //--------------------------------------------------------------------------
  2701. PKCS_UTC_TIME = LPCSTR(17);
  2702. {$EXTERNALSYM PKCS_UTC_TIME}
  2703. PKCS_TIME_REQUEST = LPCSTR(18);
  2704. {$EXTERNALSYM PKCS_TIME_REQUEST}
  2705. RSA_CSP_PUBLICKEYBLOB = LPCSTR(19);
  2706. {$EXTERNALSYM RSA_CSP_PUBLICKEYBLOB}
  2707. X509_UNICODE_NAME = LPCSTR(20);
  2708. {$EXTERNALSYM X509_UNICODE_NAME}
  2709. X509_KEYGEN_REQUEST_TO_BE_SIGNED = LPCSTR(21);
  2710. {$EXTERNALSYM X509_KEYGEN_REQUEST_TO_BE_SIGNED}
  2711. PKCS_ATTRIBUTE = LPCSTR(22);
  2712. {$EXTERNALSYM PKCS_ATTRIBUTE}
  2713. PKCS_CONTENT_INFO_SEQUENCE_OF_ANY = LPCSTR(23);
  2714. {$EXTERNALSYM PKCS_CONTENT_INFO_SEQUENCE_OF_ANY}
  2715. //+-------------------------------------------------------------------------
  2716. // Predefined primitive data structures that can be encoded / decoded.
  2717. //--------------------------------------------------------------------------
  2718. X509_UNICODE_NAME_VALUE = LPCSTR(24);
  2719. {$EXTERNALSYM X509_UNICODE_NAME_VALUE}
  2720. X509_ANY_STRING = X509_NAME_VALUE;
  2721. {$EXTERNALSYM X509_ANY_STRING}
  2722. X509_UNICODE_ANY_STRING = X509_UNICODE_NAME_VALUE;
  2723. {$EXTERNALSYM X509_UNICODE_ANY_STRING}
  2724. X509_OCTET_STRING = LPCSTR(25);
  2725. {$EXTERNALSYM X509_OCTET_STRING}
  2726. X509_BITS = LPCSTR(26);
  2727. {$EXTERNALSYM X509_BITS}
  2728. X509_INTEGER = LPCSTR(27);
  2729. {$EXTERNALSYM X509_INTEGER}
  2730. X509_MULTI_BYTE_INTEGER = LPCSTR(28);
  2731. {$EXTERNALSYM X509_MULTI_BYTE_INTEGER}
  2732. X509_ENUMERATED = LPCSTR(29);
  2733. {$EXTERNALSYM X509_ENUMERATED}
  2734. X509_CHOICE_OF_TIME = LPCSTR(30);
  2735. {$EXTERNALSYM X509_CHOICE_OF_TIME}
  2736. //+-------------------------------------------------------------------------
  2737. // More predefined X509 certificate extension data structures that can be
  2738. // encoded / decoded.
  2739. //--------------------------------------------------------------------------
  2740. X509_AUTHORITY_KEY_ID2 = LPCSTR(31);
  2741. {$EXTERNALSYM X509_AUTHORITY_KEY_ID2}
  2742. X509_AUTHORITY_INFO_ACCESS = LPCSTR(32);
  2743. {$EXTERNALSYM X509_AUTHORITY_INFO_ACCESS}
  2744. X509_CRL_REASON_CODE = X509_ENUMERATED;
  2745. {$EXTERNALSYM X509_CRL_REASON_CODE}
  2746. PKCS_CONTENT_INFO = LPCSTR(33);
  2747. {$EXTERNALSYM PKCS_CONTENT_INFO}
  2748. X509_SEQUENCE_OF_ANY = LPCSTR(34);
  2749. {$EXTERNALSYM X509_SEQUENCE_OF_ANY}
  2750. X509_CRL_DIST_POINTS = LPCSTR(35);
  2751. {$EXTERNALSYM X509_CRL_DIST_POINTS}
  2752. X509_ENHANCED_KEY_USAGE = LPCSTR(36);
  2753. {$EXTERNALSYM X509_ENHANCED_KEY_USAGE}
  2754. PKCS_CTL = LPCSTR(37);
  2755. {$EXTERNALSYM PKCS_CTL}
  2756. X509_MULTI_BYTE_UINT = LPCSTR(38);
  2757. {$EXTERNALSYM X509_MULTI_BYTE_UINT}
  2758. X509_DSS_PUBLICKEY = X509_MULTI_BYTE_UINT;
  2759. {$EXTERNALSYM X509_DSS_PUBLICKEY}
  2760. X509_DSS_PARAMETERS = LPCSTR(39);
  2761. {$EXTERNALSYM X509_DSS_PARAMETERS}
  2762. X509_DSS_SIGNATURE = LPCSTR(40);
  2763. {$EXTERNALSYM X509_DSS_SIGNATURE}
  2764. PKCS_RC2_CBC_PARAMETERS = LPCSTR(41);
  2765. {$EXTERNALSYM PKCS_RC2_CBC_PARAMETERS}
  2766. PKCS_SMIME_CAPABILITIES = LPCSTR(42);
  2767. {$EXTERNALSYM PKCS_SMIME_CAPABILITIES}
  2768. //+-------------------------------------------------------------------------
  2769. // data structures for private keys
  2770. //--------------------------------------------------------------------------
  2771. PKCS_RSA_PRIVATE_KEY = LPCSTR(43);
  2772. {$EXTERNALSYM PKCS_RSA_PRIVATE_KEY}
  2773. PKCS_PRIVATE_KEY_INFO = LPCSTR(44);
  2774. {$EXTERNALSYM PKCS_PRIVATE_KEY_INFO}
  2775. PKCS_ENCRYPTED_PRIVATE_KEY_INFO = LPCSTR(45);
  2776. {$EXTERNALSYM PKCS_ENCRYPTED_PRIVATE_KEY_INFO}
  2777. //+-------------------------------------------------------------------------
  2778. // certificate policy qualifier
  2779. //--------------------------------------------------------------------------
  2780. X509_PKIX_POLICY_QUALIFIER_USERNOTICE = LPCSTR(46);
  2781. {$EXTERNALSYM X509_PKIX_POLICY_QUALIFIER_USERNOTICE}
  2782. //+-------------------------------------------------------------------------
  2783. // Diffie-Hellman Key Exchange
  2784. //--------------------------------------------------------------------------
  2785. X509_DH_PUBLICKEY = X509_MULTI_BYTE_UINT;
  2786. {$EXTERNALSYM X509_DH_PUBLICKEY}
  2787. X509_DH_PARAMETERS = LPCSTR(47);
  2788. {$EXTERNALSYM X509_DH_PARAMETERS}
  2789. PKCS_ATTRIBUTES = LPCSTR(48);
  2790. {$EXTERNALSYM PKCS_ATTRIBUTES}
  2791. PKCS_SORTED_CTL = LPCSTR(49);
  2792. {$EXTERNALSYM PKCS_SORTED_CTL}
  2793. //+-------------------------------------------------------------------------
  2794. // X942 Diffie-Hellman
  2795. //--------------------------------------------------------------------------
  2796. X942_DH_PARAMETERS = LPCSTR(50);
  2797. {$EXTERNALSYM X942_DH_PARAMETERS}
  2798. //+-------------------------------------------------------------------------
  2799. // The following is the same as X509_BITS, except before encoding,
  2800. // the bit length is decremented to exclude trailing zero bits.
  2801. //--------------------------------------------------------------------------
  2802. X509_BITS_WITHOUT_TRAILING_ZEROES = LPCSTR(51);
  2803. {$EXTERNALSYM X509_BITS_WITHOUT_TRAILING_ZEROES}
  2804. //+-------------------------------------------------------------------------
  2805. // X942 Diffie-Hellman Other Info
  2806. //--------------------------------------------------------------------------
  2807. X942_OTHER_INFO = LPCSTR(52);
  2808. {$EXTERNALSYM X942_OTHER_INFO}
  2809. //+-------------------------------------------------------------------------
  2810. // Predefined PKCS #7 data structures that can be encoded / decoded.
  2811. //--------------------------------------------------------------------------
  2812. PKCS7_SIGNER_INFO = LPCSTR(500);
  2813. {$EXTERNALSYM PKCS7_SIGNER_INFO}
  2814. //+-------------------------------------------------------------------------
  2815. // Predefined PKCS #7 data structures that can be encoded / decoded.
  2816. //--------------------------------------------------------------------------
  2817. CMS_SIGNER_INFO = LPCSTR(501);
  2818. {$EXTERNALSYM CMS_SIGNER_INFO}
  2819. //+-------------------------------------------------------------------------
  2820. // Predefined Software Publishing Credential (SPC) data structures that
  2821. // can be encoded / decoded.
  2822. //
  2823. // Predefined values: 2000 .. 2999
  2824. //
  2825. // See spc.h for value and data structure definitions.
  2826. //--------------------------------------------------------------------------
  2827. //+-------------------------------------------------------------------------
  2828. // Extension Object Identifiers
  2829. //--------------------------------------------------------------------------
  2830. szOID_AUTHORITY_KEY_IDENTIFIER = '2.5.29.1';
  2831. {$EXTERNALSYM szOID_AUTHORITY_KEY_IDENTIFIER}
  2832. szOID_KEY_ATTRIBUTES = '2.5.29.2';
  2833. {$EXTERNALSYM szOID_KEY_ATTRIBUTES}
  2834. szOID_CERT_POLICIES_95 = '2.5.29.3';
  2835. {$EXTERNALSYM szOID_CERT_POLICIES_95}
  2836. szOID_KEY_USAGE_RESTRICTION = '2.5.29.4';
  2837. {$EXTERNALSYM szOID_KEY_USAGE_RESTRICTION}
  2838. szOID_SUBJECT_ALT_NAME = '2.5.29.7';
  2839. {$EXTERNALSYM szOID_SUBJECT_ALT_NAME}
  2840. szOID_ISSUER_ALT_NAME = '2.5.29.8';
  2841. {$EXTERNALSYM szOID_ISSUER_ALT_NAME}
  2842. szOID_BASIC_CONSTRAINTS = '2.5.29.10';
  2843. {$EXTERNALSYM szOID_BASIC_CONSTRAINTS}
  2844. szOID_KEY_USAGE = '2.5.29.15';
  2845. {$EXTERNALSYM szOID_KEY_USAGE}
  2846. szOID_PRIVATEKEY_USAGE_PERIOD = '2.5.29.16';
  2847. {$EXTERNALSYM szOID_PRIVATEKEY_USAGE_PERIOD}
  2848. szOID_BASIC_CONSTRAINTS2 = '2.5.29.19';
  2849. {$EXTERNALSYM szOID_BASIC_CONSTRAINTS2}
  2850. szOID_CERT_POLICIES = '2.5.29.32';
  2851. {$EXTERNALSYM szOID_CERT_POLICIES}
  2852. szOID_AUTHORITY_KEY_IDENTIFIER2 = '2.5.29.35';
  2853. {$EXTERNALSYM szOID_AUTHORITY_KEY_IDENTIFIER2}
  2854. szOID_SUBJECT_KEY_IDENTIFIER = '2.5.29.14';
  2855. {$EXTERNALSYM szOID_SUBJECT_KEY_IDENTIFIER}
  2856. szOID_SUBJECT_ALT_NAME2 = '2.5.29.17';
  2857. {$EXTERNALSYM szOID_SUBJECT_ALT_NAME2}
  2858. szOID_ISSUER_ALT_NAME2 = '2.5.29.18';
  2859. {$EXTERNALSYM szOID_ISSUER_ALT_NAME2}
  2860. szOID_CRL_REASON_CODE = '2.5.29.21';
  2861. {$EXTERNALSYM szOID_CRL_REASON_CODE}
  2862. szOID_CRL_DIST_POINTS = '2.5.29.31';
  2863. {$EXTERNALSYM szOID_CRL_DIST_POINTS}
  2864. szOID_ENHANCED_KEY_USAGE = '2.5.29.37';
  2865. {$EXTERNALSYM szOID_ENHANCED_KEY_USAGE}
  2866. // Microsoft PKCS10 Attributes
  2867. szOID_RENEWAL_CERTIFICATE = '1.3.6.1.4.1.311.13.1';
  2868. {$EXTERNALSYM szOID_RENEWAL_CERTIFICATE}
  2869. szOID_ENROLLMENT_NAME_VALUE_PAIR = '1.3.6.1.4.1.311.13.2.1';
  2870. {$EXTERNALSYM szOID_ENROLLMENT_NAME_VALUE_PAIR}
  2871. szOID_ENROLLMENT_CSP_PROVIDER = '1.3.6.1.4.1.311.13.2.2';
  2872. {$EXTERNALSYM szOID_ENROLLMENT_CSP_PROVIDER}
  2873. szOID_OS_VERSION = '1.3.6.1.4.1.311.13.2.3';
  2874. {$EXTERNALSYM szOID_OS_VERSION}
  2875. //
  2876. // Extension contain certificate type
  2877. szOID_ENROLLMENT_AGENT = '1.3.6.1.4.1.311.20.2.1';
  2878. {$EXTERNALSYM szOID_ENROLLMENT_AGENT}
  2879. // Internet Public Key Infrastructure (PKIX)
  2880. szOID_PKIX = '1.3.6.1.5.5.7';
  2881. {$EXTERNALSYM szOID_PKIX}
  2882. szOID_PKIX_PE = '1.3.6.1.5.5.7.1';
  2883. {$EXTERNALSYM szOID_PKIX_PE}
  2884. szOID_AUTHORITY_INFO_ACCESS = '1.3.6.1.5.5.7.1.1';
  2885. {$EXTERNALSYM szOID_AUTHORITY_INFO_ACCESS}
  2886. // Microsoft extensions or attributes
  2887. szOID_CERT_EXTENSIONS = '1.3.6.1.4.1.311.2.1.14';
  2888. {$EXTERNALSYM szOID_CERT_EXTENSIONS}
  2889. szOID_NEXT_UPDATE_LOCATION = '1.3.6.1.4.1.311.10.2';
  2890. {$EXTERNALSYM szOID_NEXT_UPDATE_LOCATION}
  2891. // Microsoft PKCS #7 ContentType Object Identifiers
  2892. szOID_CTL = '1.3.6.1.4.1.311.10.1';
  2893. {$EXTERNALSYM szOID_CTL}
  2894. // Microsoft Sorted CTL Extension Object Identifier
  2895. szOID_SORTED_CTL = '1.3.6.1.4.1.311.10.1.1';
  2896. {$EXTERNALSYM szOID_SORTED_CTL}
  2897. // serialized serial numbers for PRS
  2898. szOID_SERIALIZED = '1.3.6.1.4.1.311.10.3.3.1';
  2899. {$EXTERNALSYM szOID_SERIALIZED}
  2900. // UPN principal name in SubjectAltName
  2901. szOID_NT_PRINCIPAL_NAME = '1.3.6.1.4.1.311.20.2.3';
  2902. {$EXTERNALSYM szOID_NT_PRINCIPAL_NAME}
  2903. // Windows product update unauthenticated attribute
  2904. szOID_PRODUCT_UPDATE = '1.3.6.1.4.1.311.31.1';
  2905. {$EXTERNALSYM szOID_PRODUCT_UPDATE}
  2906. //+-------------------------------------------------------------------------
  2907. // Object Identifiers for use with Auto Enrollment
  2908. //--------------------------------------------------------------------------
  2909. szOID_AUTO_ENROLL_CTL_USAGE = '1.3.6.1.4.1.311.20.1';
  2910. {$EXTERNALSYM szOID_AUTO_ENROLL_CTL_USAGE}
  2911. // Extension contain certificate type
  2912. szOID_ENROLL_CERTTYPE_EXTENSION = '1.3.6.1.4.1.311.20.2';
  2913. {$EXTERNALSYM szOID_ENROLL_CERTTYPE_EXTENSION}
  2914. szOID_CERT_MANIFOLD = '1.3.6.1.4.1.311.20.3';
  2915. {$EXTERNALSYM szOID_CERT_MANIFOLD}
  2916. //+-------------------------------------------------------------------------
  2917. // Object Identifiers for use with the MS Certificate Server
  2918. //--------------------------------------------------------------------------
  2919. szOID_CERTSRV_CA_VERSION = '1.3.6.1.4.1.311.21.1';
  2920. {$EXTERNALSYM szOID_CERTSRV_CA_VERSION}
  2921. //+-------------------------------------------------------------------------
  2922. // Object Identifiers for use with the MS Directory Service
  2923. //--------------------------------------------------------------------------
  2924. szOID_NTDS_REPLICATION = '1.3.6.1.4.1.311.25.1';
  2925. {$EXTERNALSYM szOID_NTDS_REPLICATION}
  2926. //+-------------------------------------------------------------------------
  2927. // Extension Object Identifiers (currently not implemented)
  2928. //--------------------------------------------------------------------------
  2929. szOID_POLICY_MAPPINGS = '2.5.29.5';
  2930. {$EXTERNALSYM szOID_POLICY_MAPPINGS}
  2931. szOID_SUBJECT_DIR_ATTRS = '2.5.29.9';
  2932. {$EXTERNALSYM szOID_SUBJECT_DIR_ATTRS}
  2933. //+-------------------------------------------------------------------------
  2934. // Enhanced Key Usage (Purpose) Object Identifiers
  2935. //--------------------------------------------------------------------------
  2936. szOID_PKIX_KP = '1.3.6.1.5.5.7.3';
  2937. {$EXTERNALSYM szOID_PKIX_KP}
  2938. // Consistent key usage bits: DIGITAL_SIGNATURE, KEY_ENCIPHERMENT
  2939. // or KEY_AGREEMENT
  2940. szOID_PKIX_KP_SERVER_AUTH = '1.3.6.1.5.5.7.3.1';
  2941. {$EXTERNALSYM szOID_PKIX_KP_SERVER_AUTH}
  2942. // Consistent key usage bits: DIGITAL_SIGNATURE
  2943. szOID_PKIX_KP_CLIENT_AUTH = '1.3.6.1.5.5.7.3.2';
  2944. {$EXTERNALSYM szOID_PKIX_KP_CLIENT_AUTH}
  2945. // Consistent key usage bits: DIGITAL_SIGNATURE
  2946. szOID_PKIX_KP_CODE_SIGNING = '1.3.6.1.5.5.7.3.3';
  2947. {$EXTERNALSYM szOID_PKIX_KP_CODE_SIGNING}
  2948. // Consistent key usage bits: DIGITAL_SIGNATURE, NON_REPUDIATION and/or
  2949. // (KEY_ENCIPHERMENT or KEY_AGREEMENT)
  2950. szOID_PKIX_KP_EMAIL_PROTECTION = '1.3.6.1.5.5.7.3.4';
  2951. {$EXTERNALSYM szOID_PKIX_KP_EMAIL_PROTECTION}
  2952. // Consistent key usage bits: DIGITAL_SIGNATURE and/or
  2953. // (KEY_ENCIPHERMENT or KEY_AGREEMENT)
  2954. szOID_PKIX_KP_IPSEC_END_SYSTEM = '1.3.6.1.5.5.7.3.5';
  2955. {$EXTERNALSYM szOID_PKIX_KP_IPSEC_END_SYSTEM}
  2956. // Consistent key usage bits: DIGITAL_SIGNATURE and/or
  2957. // (KEY_ENCIPHERMENT or KEY_AGREEMENT)
  2958. szOID_PKIX_KP_IPSEC_TUNNEL = '1.3.6.1.5.5.7.3.6';
  2959. {$EXTERNALSYM szOID_PKIX_KP_IPSEC_TUNNEL}
  2960. // Consistent key usage bits: DIGITAL_SIGNATURE and/or
  2961. // (KEY_ENCIPHERMENT or KEY_AGREEMENT)
  2962. szOID_PKIX_KP_IPSEC_USER = '1.3.6.1.5.5.7.3.7';
  2963. {$EXTERNALSYM szOID_PKIX_KP_IPSEC_USER}
  2964. // Consistent key usage bits: DIGITAL_SIGNATURE or NON_REPUDIATION
  2965. szOID_PKIX_KP_TIMESTAMP_SIGNING = '1.3.6.1.5.5.7.3.8';
  2966. {$EXTERNALSYM szOID_PKIX_KP_TIMESTAMP_SIGNING}
  2967. //+-------------------------------------------------------------------------
  2968. // Microsoft Enhanced Key Usage (Purpose) Object Identifiers
  2969. //+-------------------------------------------------------------------------
  2970. // Signer of CTLs
  2971. szOID_KP_CTL_USAGE_SIGNING = '1.3.6.1.4.1.311.10.3.1';
  2972. {$EXTERNALSYM szOID_KP_CTL_USAGE_SIGNING}
  2973. // Signer of TimeStamps
  2974. szOID_KP_TIME_STAMP_SIGNING = '1.3.6.1.4.1.311.10.3.2';
  2975. {$EXTERNALSYM szOID_KP_TIME_STAMP_SIGNING}
  2976. szOID_SERVER_GATED_CRYPTO = '1.3.6.1.4.1.311.10.3.3';
  2977. {$EXTERNALSYM szOID_SERVER_GATED_CRYPTO}
  2978. szOID_SGC_NETSCAPE = '2.16.840.1.113730.4.1';
  2979. {$EXTERNALSYM szOID_SGC_NETSCAPE}
  2980. szOID_KP_EFS = '1.3.6.1.4.1.311.10.3.4';
  2981. {$EXTERNALSYM szOID_KP_EFS}
  2982. // Can use Windows Hardware Compatible (WHQL)
  2983. szOID_WHQL_CRYPTO = '1.3.6.1.4.1.311.10.3.5';
  2984. {$EXTERNALSYM szOID_WHQL_CRYPTO}
  2985. // Signed by the NT5 build lab
  2986. szOID_NT5_CRYPTO = '1.3.6.1.4.1.311.10.3.6';
  2987. {$EXTERNALSYM szOID_NT5_CRYPTO}
  2988. // Signed by and OEM of WHQL
  2989. szOID_OEM_WHQL_CRYPTO = '1.3.6.1.4.1.311.10.3.7';
  2990. {$EXTERNALSYM szOID_OEM_WHQL_CRYPTO}
  2991. // Signed by the Embedded NT
  2992. szOID_EMBEDDED_NT_CRYPTO = '1.3.6.1.4.1.311.10.3.8';
  2993. {$EXTERNALSYM szOID_EMBEDDED_NT_CRYPTO}
  2994. szOID_DRM = '1.3.6.1.4.1.311.10.5.1';
  2995. {$EXTERNALSYM szOID_DRM}
  2996. szOID_LICENSES = '1.3.6.1.4.1.311.10.6.1';
  2997. {$EXTERNALSYM szOID_LICENSES}
  2998. szOID_LICENSE_SERVER = '1.3.6.1.4.1.311.10.6.2';
  2999. {$EXTERNALSYM szOID_LICENSE_SERVER}
  3000. szOID_KP_SMARTCARD_LOGON = '1.3.6.1.4.1.311.20.2.2';
  3001. {$EXTERNALSYM szOID_KP_SMARTCARD_LOGON}
  3002. //+-------------------------------------------------------------------------
  3003. // Microsoft Attribute Object Identifiers
  3004. //+-------------------------------------------------------------------------
  3005. szOID_YESNO_TRUST_ATTR = '1.3.6.1.4.1.311.10.4.1';
  3006. {$EXTERNALSYM szOID_YESNO_TRUST_ATTR}
  3007. //+-------------------------------------------------------------------------
  3008. // Qualifiers that may be part of the szOID_CERT_POLICIES and
  3009. // szOID_CERT_POLICIES95 extensions
  3010. //+-------------------------------------------------------------------------
  3011. szOID_PKIX_POLICY_QUALIFIER_CPS = '1.3.6.1.5.5.7.2.1';
  3012. {$EXTERNALSYM szOID_PKIX_POLICY_QUALIFIER_CPS}
  3013. szOID_PKIX_POLICY_QUALIFIER_USERNOTICE = '1.3.6.1.5.5.7.2.2';
  3014. {$EXTERNALSYM szOID_PKIX_POLICY_QUALIFIER_USERNOTICE}
  3015. // OID for old qualifer
  3016. szOID_CERT_POLICIES_95_QUALIFIER1 = '2.16.840.1.113733.1.7.1.1';
  3017. {$EXTERNALSYM szOID_CERT_POLICIES_95_QUALIFIER1}
  3018. //+-------------------------------------------------------------------------
  3019. // X509_CERT
  3020. //
  3021. // The "to be signed" encoded content plus its signature. The ToBeSigned
  3022. // content is the CryptEncodeObject() output for one of the following:
  3023. // X509_CERT_TO_BE_SIGNED, X509_CERT_CRL_TO_BE_SIGNED or
  3024. // X509_CERT_REQUEST_TO_BE_SIGNED.
  3025. //
  3026. // pvStructInfo points to CERT_SIGNED_CONTENT_INFO.
  3027. //--------------------------------------------------------------------------
  3028. //+-------------------------------------------------------------------------
  3029. // X509_CERT_TO_BE_SIGNED
  3030. //
  3031. // pvStructInfo points to CERT_INFO.
  3032. //
  3033. // For CryptDecodeObject(), the pbEncoded is the "to be signed" plus its
  3034. // signature (output of a X509_CERT CryptEncodeObject()).
  3035. //
  3036. // For CryptEncodeObject(), the pbEncoded is just the "to be signed".
  3037. //--------------------------------------------------------------------------
  3038. //+-------------------------------------------------------------------------
  3039. // X509_CERT_CRL_TO_BE_SIGNED
  3040. //
  3041. // pvStructInfo points to CRL_INFO.
  3042. //
  3043. // For CryptDecodeObject(), the pbEncoded is the "to be signed" plus its
  3044. // signature (output of a X509_CERT CryptEncodeObject()).
  3045. //
  3046. // For CryptEncodeObject(), the pbEncoded is just the "to be signed".
  3047. //--------------------------------------------------------------------------
  3048. //+-------------------------------------------------------------------------
  3049. // X509_CERT_REQUEST_TO_BE_SIGNED
  3050. //
  3051. // pvStructInfo points to CERT_REQUEST_INFO.
  3052. //
  3053. // For CryptDecodeObject(), the pbEncoded is the "to be signed" plus its
  3054. // signature (output of a X509_CERT CryptEncodeObject()).
  3055. //
  3056. // For CryptEncodeObject(), the pbEncoded is just the "to be signed".
  3057. //--------------------------------------------------------------------------
  3058. //+-------------------------------------------------------------------------
  3059. // X509_EXTENSIONS
  3060. // szOID_CERT_EXTENSIONS
  3061. //
  3062. // pvStructInfo points to following CERT_EXTENSIONS.
  3063. //--------------------------------------------------------------------------
  3064. type
  3065. PCERT_EXTENSIONS = ^CERT_EXTENSIONS;
  3066. {$EXTERNALSYM PCERT_EXTENSIONS}
  3067. _CERT_EXTENSIONS = record
  3068. cExtension: DWORD;
  3069. rgExtension: PCERT_EXTENSION;
  3070. end;
  3071. {$EXTERNALSYM _CERT_EXTENSIONS}
  3072. CERT_EXTENSIONS = _CERT_EXTENSIONS;
  3073. {$EXTERNALSYM CERT_EXTENSIONS}
  3074. TCertExtensions = CERT_EXTENSIONS;
  3075. PCertExtensions = PCERT_EXTENSIONS;
  3076. //+-------------------------------------------------------------------------
  3077. // X509_NAME_VALUE
  3078. // X509_ANY_STRING
  3079. //
  3080. // pvStructInfo points to CERT_NAME_VALUE.
  3081. //--------------------------------------------------------------------------
  3082. //+-------------------------------------------------------------------------
  3083. // X509_UNICODE_NAME_VALUE
  3084. // X509_UNICODE_ANY_STRING
  3085. //
  3086. // pvStructInfo points to CERT_NAME_VALUE.
  3087. //
  3088. // The name values are unicode strings.
  3089. //
  3090. // For CryptEncodeObject:
  3091. // Value.pbData points to the unicode string.
  3092. // If Value.cbData = 0, then, the unicode string is NULL terminated.
  3093. // Otherwise, Value.cbData is the unicode string byte count. The byte count
  3094. // is twice the character count.
  3095. //
  3096. // If the unicode string contains an invalid character for the specified
  3097. // dwValueType, then, *pcbEncoded is updated with the unicode character
  3098. // index of the first invalid character. LastError is set to:
  3099. // CRYPT_E_INVALID_NUMERIC_STRING, CRYPT_E_INVALID_PRINTABLE_STRING or
  3100. // CRYPT_E_INVALID_IA5_STRING.
  3101. //
  3102. // To disable the above check, either set CERT_RDN_DISABLE_CHECK_TYPE_FLAG
  3103. // in dwValueType or set CRYPT_UNICODE_NAME_ENCODE_DISABLE_CHECK_TYPE_FLAG
  3104. // in dwFlags passed to CryptEncodeObjectEx.
  3105. //
  3106. // The unicode string is converted before being encoded according to
  3107. // the specified dwValueType. If dwValueType is set to 0, LastError
  3108. // is set to E_INVALIDARG.
  3109. //
  3110. // If the dwValueType isn't one of the character strings (its a
  3111. // CERT_RDN_ENCODED_BLOB or CERT_RDN_OCTET_STRING), then, CryptEncodeObject
  3112. // will return FALSE with LastError set to CRYPT_E_NOT_CHAR_STRING.
  3113. //
  3114. // For CryptDecodeObject:
  3115. // Value.pbData points to a NULL terminated unicode string. Value.cbData
  3116. // contains the byte count of the unicode string excluding the NULL
  3117. // terminator. dwValueType contains the type used in the encoded object.
  3118. // Its not forced to CERT_RDN_UNICODE_STRING. The encoded value is
  3119. // converted to the unicode string according to the dwValueType.
  3120. //
  3121. // If the encoded object isn't one of the character string types, then,
  3122. // CryptDecodeObject will return FALSE with LastError set to
  3123. // CRYPT_E_NOT_CHAR_STRING. For a non character string, decode using
  3124. // X509_NAME_VALUE or X509_ANY_STRING.
  3125. //
  3126. // By default, CERT_RDN_T61_STRING values are initially decoded
  3127. // as UTF8. If the UTF8 decoding fails, then, decoded as 8 bit characters.
  3128. // Set CRYPT_UNICODE_NAME_DECODE_DISABLE_IE4_UTF8_FLAG in dwFlags
  3129. // passed to either CryptDecodeObject or CryptDecodeObjectEx to
  3130. // skip the initial attempt to decode as UTF8.
  3131. //--------------------------------------------------------------------------
  3132. //+-------------------------------------------------------------------------
  3133. // X509_NAME
  3134. //
  3135. // pvStructInfo points to CERT_NAME_INFO.
  3136. //--------------------------------------------------------------------------
  3137. //+-------------------------------------------------------------------------
  3138. // X509_UNICODE_NAME
  3139. //
  3140. // pvStructInfo points to CERT_NAME_INFO.
  3141. //
  3142. // The RDN attribute values are unicode strings except for the dwValueTypes of
  3143. // CERT_RDN_ENCODED_BLOB or CERT_RDN_OCTET_STRING. These dwValueTypes are
  3144. // the same as for a X509_NAME. Their values aren't converted to/from unicode.
  3145. //
  3146. // For CryptEncodeObject:
  3147. // Value.pbData points to the unicode string.
  3148. // If Value.cbData = 0, then, the unicode string is NULL terminated.
  3149. // Otherwise, Value.cbData is the unicode string byte count. The byte count
  3150. // is twice the character count.
  3151. //
  3152. // If dwValueType = 0 (CERT_RDN_ANY_TYPE), the pszObjId is used to find
  3153. // an acceptable dwValueType. If the unicode string contains an
  3154. // invalid character for the found or specified dwValueType, then,
  3155. // *pcbEncoded is updated with the error location of the invalid character.
  3156. // See below for details. LastError is set to:
  3157. // CRYPT_E_INVALID_NUMERIC_STRING, CRYPT_E_INVALID_PRINTABLE_STRING or
  3158. // CRYPT_E_INVALID_IA5_STRING.
  3159. //
  3160. // To disable the above check, either set CERT_RDN_DISABLE_CHECK_TYPE_FLAG
  3161. // in dwValueType or set CRYPT_UNICODE_NAME_ENCODE_DISABLE_CHECK_TYPE_FLAG
  3162. // in dwFlags passed to CryptEncodeObjectEx.
  3163. //
  3164. // Set CERT_RDN_UNICODE_STRING in dwValueType or set
  3165. // CRYPT_UNICODE_NAME_ENCODE_ENABLE_T61_UNICODE_FLAG in dwFlags passed
  3166. // to CryptEncodeObjectEx to select CERT_RDN_T61_STRING instead of
  3167. // CERT_RDN_UNICODE_STRING if all the unicode characters are <= 0xFF.
  3168. //
  3169. // Set CERT_RDN_ENABLE_UTF8_UNICODE_STRING in dwValueType or set
  3170. // CRYPT_UNICODE_NAME_ENCODE_ENABLE_UTF8_UNICODE_FLAG in dwFlags passed
  3171. // to CryptEncodeObjectEx to select CERT_RDN_UTF8_STRING instead of
  3172. // CERT_RDN_UNICODE_STRING.
  3173. //
  3174. // The unicode string is converted before being encoded according to
  3175. // the specified or ObjId matching dwValueType.
  3176. //
  3177. // For CryptDecodeObject:
  3178. // Value.pbData points to a NULL terminated unicode string. Value.cbData
  3179. // contains the byte count of the unicode string excluding the NULL
  3180. // terminator. dwValueType contains the type used in the encoded object.
  3181. // Its not forced to CERT_RDN_UNICODE_STRING. The encoded value is
  3182. // converted to the unicode string according to the dwValueType.
  3183. //
  3184. // If the dwValueType of the encoded value isn't a character string
  3185. // type, then, it isn't converted to UNICODE. Use the
  3186. // IS_CERT_RDN_CHAR_STRING() macro on the dwValueType to check
  3187. // that Value.pbData points to a converted unicode string.
  3188. //
  3189. // By default, CERT_RDN_T61_STRING values are initially decoded
  3190. // as UTF8. If the UTF8 decoding fails, then, decoded as 8 bit characters.
  3191. // Set CRYPT_UNICODE_NAME_DECODE_DISABLE_IE4_UTF8_FLAG in dwFlags
  3192. // passed to either CryptDecodeObject or CryptDecodeObjectEx to
  3193. // skip the initial attempt to decode as UTF8.
  3194. //--------------------------------------------------------------------------
  3195. //+-------------------------------------------------------------------------
  3196. // Unicode Name Value Error Location Definitions
  3197. //
  3198. // Error location is returned in *pcbEncoded by
  3199. // CryptEncodeObject(X509_UNICODE_NAME)
  3200. //
  3201. // Error location consists of:
  3202. // RDN_INDEX - 10 bits << 22
  3203. // ATTR_INDEX - 6 bits << 16
  3204. // VALUE_INDEX - 16 bits (unicode character index)
  3205. //--------------------------------------------------------------------------
  3206. const
  3207. CERT_UNICODE_RDN_ERR_INDEX_MASK = $3FF;
  3208. {$EXTERNALSYM CERT_UNICODE_RDN_ERR_INDEX_MASK}
  3209. CERT_UNICODE_RDN_ERR_INDEX_SHIFT = 22;
  3210. {$EXTERNALSYM CERT_UNICODE_RDN_ERR_INDEX_SHIFT}
  3211. CERT_UNICODE_ATTR_ERR_INDEX_MASK = $003F;
  3212. {$EXTERNALSYM CERT_UNICODE_ATTR_ERR_INDEX_MASK}
  3213. CERT_UNICODE_ATTR_ERR_INDEX_SHIFT = 16;
  3214. {$EXTERNALSYM CERT_UNICODE_ATTR_ERR_INDEX_SHIFT}
  3215. CERT_UNICODE_VALUE_ERR_INDEX_MASK = $0000FFFF;
  3216. {$EXTERNALSYM CERT_UNICODE_VALUE_ERR_INDEX_MASK}
  3217. CERT_UNICODE_VALUE_ERR_INDEX_SHIFT = 0;
  3218. {$EXTERNALSYM CERT_UNICODE_VALUE_ERR_INDEX_SHIFT}
  3219. function GET_CERT_UNICODE_RDN_ERR_INDEX(X: DWORD): DWORD;
  3220. {$EXTERNALSYM GET_CERT_UNICODE_RDN_ERR_INDEX}
  3221. function GET_CERT_UNICODE_ATTR_ERR_INDEX(X: DWORD): DWORD;
  3222. {$EXTERNALSYM GET_CERT_UNICODE_ATTR_ERR_INDEX}
  3223. function GET_CERT_UNICODE_VALUE_ERR_INDEX(X: DWORD): DWORD;
  3224. {$EXTERNALSYM GET_CERT_UNICODE_VALUE_ERR_INDEX}
  3225. //+-------------------------------------------------------------------------
  3226. // X509_PUBLIC_KEY_INFO
  3227. //
  3228. // pvStructInfo points to CERT_PUBLIC_KEY_INFO.
  3229. //--------------------------------------------------------------------------
  3230. //+-------------------------------------------------------------------------
  3231. // X509_AUTHORITY_KEY_ID
  3232. // szOID_AUTHORITY_KEY_IDENTIFIER
  3233. //
  3234. // pvStructInfo points to following CERT_AUTHORITY_KEY_ID_INFO.
  3235. //--------------------------------------------------------------------------
  3236. type
  3237. PCERT_AUTHORITY_KEY_ID_INFO = ^CERT_AUTHORITY_KEY_ID_INFO;
  3238. {$EXTERNALSYM PCERT_AUTHORITY_KEY_ID_INFO}
  3239. _CERT_AUTHORITY_KEY_ID_INFO = record
  3240. KeyId: CRYPT_DATA_BLOB;
  3241. CertIssuer: CERT_NAME_BLOB;
  3242. CertSerialNumber: CRYPT_INTEGER_BLOB;
  3243. end;
  3244. {$EXTERNALSYM _CERT_AUTHORITY_KEY_ID_INFO}
  3245. CERT_AUTHORITY_KEY_ID_INFO = _CERT_AUTHORITY_KEY_ID_INFO;
  3246. {$EXTERNALSYM CERT_AUTHORITY_KEY_ID_INFO}
  3247. TCertAuthorityKeyIdInfo = CERT_AUTHORITY_KEY_ID_INFO;
  3248. PCertAuthorityKeyIdInfo = PCERT_AUTHORITY_KEY_ID_INFO;
  3249. //+-------------------------------------------------------------------------
  3250. // X509_KEY_ATTRIBUTES
  3251. // szOID_KEY_ATTRIBUTES
  3252. //
  3253. // pvStructInfo points to following CERT_KEY_ATTRIBUTES_INFO.
  3254. //--------------------------------------------------------------------------
  3255. PCERT_PRIVATE_KEY_VALIDITY = ^CERT_PRIVATE_KEY_VALIDITY;
  3256. {$EXTERNALSYM PCERT_PRIVATE_KEY_VALIDITY}
  3257. _CERT_PRIVATE_KEY_VALIDITY = record
  3258. NotBefore: FILETIME;
  3259. NotAfter: FILETIME;
  3260. end;
  3261. {$EXTERNALSYM _CERT_PRIVATE_KEY_VALIDITY}
  3262. CERT_PRIVATE_KEY_VALIDITY = _CERT_PRIVATE_KEY_VALIDITY;
  3263. {$EXTERNALSYM CERT_PRIVATE_KEY_VALIDITY}
  3264. TCertPrivateKeyValidity = CERT_PRIVATE_KEY_VALIDITY;
  3265. PCertPrivateKeyValidity = PCERT_PRIVATE_KEY_VALIDITY;
  3266. PCERT_KEY_ATTRIBUTES_INFO = ^CERT_KEY_ATTRIBUTES_INFO;
  3267. {$EXTERNALSYM PCERT_KEY_ATTRIBUTES_INFO}
  3268. _CERT_KEY_ATTRIBUTES_INFO = record
  3269. KeyId: CRYPT_DATA_BLOB;
  3270. IntendedKeyUsage: CRYPT_BIT_BLOB;
  3271. pPrivateKeyUsagePeriod: PCERT_PRIVATE_KEY_VALIDITY; // OPTIONAL
  3272. end;
  3273. {$EXTERNALSYM _CERT_KEY_ATTRIBUTES_INFO}
  3274. CERT_KEY_ATTRIBUTES_INFO = _CERT_KEY_ATTRIBUTES_INFO;
  3275. {$EXTERNALSYM CERT_KEY_ATTRIBUTES_INFO}
  3276. TCertKeyAttributesInfo = CERT_KEY_ATTRIBUTES_INFO;
  3277. PCertKeyAttributesInfo = PCERT_KEY_ATTRIBUTES_INFO;
  3278. // Byte[0]
  3279. const
  3280. CERT_DIGITAL_SIGNATURE_KEY_USAGE = $80;
  3281. {$EXTERNALSYM CERT_DIGITAL_SIGNATURE_KEY_USAGE}
  3282. CERT_NON_REPUDIATION_KEY_USAGE = $40;
  3283. {$EXTERNALSYM CERT_NON_REPUDIATION_KEY_USAGE}
  3284. CERT_KEY_ENCIPHERMENT_KEY_USAGE = $20;
  3285. {$EXTERNALSYM CERT_KEY_ENCIPHERMENT_KEY_USAGE}
  3286. CERT_DATA_ENCIPHERMENT_KEY_USAGE = $10;
  3287. {$EXTERNALSYM CERT_DATA_ENCIPHERMENT_KEY_USAGE}
  3288. CERT_KEY_AGREEMENT_KEY_USAGE = $08;
  3289. {$EXTERNALSYM CERT_KEY_AGREEMENT_KEY_USAGE}
  3290. CERT_KEY_CERT_SIGN_KEY_USAGE = $04;
  3291. {$EXTERNALSYM CERT_KEY_CERT_SIGN_KEY_USAGE}
  3292. CERT_OFFLINE_CRL_SIGN_KEY_USAGE = $02;
  3293. {$EXTERNALSYM CERT_OFFLINE_CRL_SIGN_KEY_USAGE}
  3294. CERT_CRL_SIGN_KEY_USAGE = $02;
  3295. {$EXTERNALSYM CERT_CRL_SIGN_KEY_USAGE}
  3296. CERT_ENCIPHER_ONLY_KEY_USAGE = $01;
  3297. {$EXTERNALSYM CERT_ENCIPHER_ONLY_KEY_USAGE}
  3298. // Byte[1]
  3299. CERT_DECIPHER_ONLY_KEY_USAGE = $80;
  3300. {$EXTERNALSYM CERT_DECIPHER_ONLY_KEY_USAGE}
  3301. //+-------------------------------------------------------------------------
  3302. // X509_KEY_USAGE_RESTRICTION
  3303. // szOID_KEY_USAGE_RESTRICTION
  3304. //
  3305. // pvStructInfo points to following CERT_KEY_USAGE_RESTRICTION_INFO.
  3306. //--------------------------------------------------------------------------
  3307. type
  3308. PCERT_POLICY_ID = ^CERT_POLICY_ID;
  3309. {$EXTERNALSYM PCERT_POLICY_ID}
  3310. _CERT_POLICY_ID = record
  3311. cCertPolicyElementId: DWORD;
  3312. rgpszCertPolicyElementId: LPSTR; // pszObjId
  3313. end;
  3314. {$EXTERNALSYM _CERT_POLICY_ID}
  3315. CERT_POLICY_ID = _CERT_POLICY_ID;
  3316. {$EXTERNALSYM CERT_POLICY_ID}
  3317. TCertPolicyId = CERT_POLICY_ID;
  3318. PCertPolicyId = PCERT_POLICY_ID;
  3319. PCERT_KEY_USAGE_RESTRICTION_INFO = ^CERT_KEY_USAGE_RESTRICTION_INFO;
  3320. {$EXTERNALSYM PCERT_KEY_USAGE_RESTRICTION_INFO}
  3321. _CERT_KEY_USAGE_RESTRICTION_INFO = record
  3322. cCertPolicyId: DWORD;
  3323. rgCertPolicyId: PCERT_POLICY_ID;
  3324. RestrictedKeyUsage: CRYPT_BIT_BLOB;
  3325. end;
  3326. {$EXTERNALSYM _CERT_KEY_USAGE_RESTRICTION_INFO}
  3327. CERT_KEY_USAGE_RESTRICTION_INFO = _CERT_KEY_USAGE_RESTRICTION_INFO;
  3328. {$EXTERNALSYM CERT_KEY_USAGE_RESTRICTION_INFO}
  3329. TCertKeyUsageRestrictionInfo = CERT_KEY_USAGE_RESTRICTION_INFO;
  3330. PCertKeyUsageRestrictionInfo = PCERT_KEY_USAGE_RESTRICTION_INFO;
  3331. // See CERT_KEY_ATTRIBUTES_INFO for definition of the RestrictedKeyUsage bits
  3332. //+-------------------------------------------------------------------------
  3333. // X509_ALTERNATE_NAME
  3334. // szOID_SUBJECT_ALT_NAME
  3335. // szOID_ISSUER_ALT_NAME
  3336. // szOID_SUBJECT_ALT_NAME2
  3337. // szOID_ISSUER_ALT_NAME2
  3338. //
  3339. // pvStructInfo points to following CERT_ALT_NAME_INFO.
  3340. //--------------------------------------------------------------------------
  3341. PCERT_OTHER_NAME = ^CERT_OTHER_NAME;
  3342. {$EXTERNALSYM PCERT_OTHER_NAME}
  3343. _CERT_OTHER_NAME = record
  3344. pszObjId: LPSTR;
  3345. Value: CRYPT_OBJID_BLOB;
  3346. end;
  3347. {$EXTERNALSYM _CERT_OTHER_NAME}
  3348. CERT_OTHER_NAME = _CERT_OTHER_NAME;
  3349. {$EXTERNALSYM CERT_OTHER_NAME}
  3350. TCertOtherName = CERT_OTHER_NAME;
  3351. PCertOtherName = PCERT_OTHER_NAME;
  3352. PCERT_ALT_NAME_ENTRY = ^CERT_ALT_NAME_ENTRY;
  3353. {$EXTERNALSYM PCERT_ALT_NAME_ENTRY}
  3354. _CERT_ALT_NAME_ENTRY = record
  3355. dwAltNameChoice: DWORD;
  3356. //union {
  3357. case Integer of
  3358. 0: (pOtherName: PCERT_OTHER_NAME); // 1
  3359. 1: (pwszRfc822Name: LPWSTR); // 2 (encoded IA5)
  3360. 2: (pwszDNSName: LPWSTR); // 3 (encoded IA5)
  3361. 3: ();// Not implemented x400Address; // 4
  3362. 4: (DirectoryName: CERT_NAME_BLOB); // 5
  3363. 5: ();// Not implemented pEdiPartyName; // 6
  3364. 6: (pwszURL: LPWSTR); // 7 (encoded IA5)
  3365. 7: (IPAddress: CRYPT_DATA_BLOB); // 8 (Octet String)
  3366. 8: (pszRegisteredID: LPSTR); // 9 (Object Identifer)
  3367. end;
  3368. {$EXTERNALSYM _CERT_ALT_NAME_ENTRY}
  3369. CERT_ALT_NAME_ENTRY = _CERT_ALT_NAME_ENTRY;
  3370. {$EXTERNALSYM CERT_ALT_NAME_ENTRY}
  3371. TCertAltNameEntry = CERT_ALT_NAME_ENTRY;
  3372. PCertAltNameEntry = PCERT_ALT_NAME_ENTRY;
  3373. const
  3374. CERT_ALT_NAME_OTHER_NAME = 1;
  3375. {$EXTERNALSYM CERT_ALT_NAME_OTHER_NAME}
  3376. CERT_ALT_NAME_RFC822_NAME = 2;
  3377. {$EXTERNALSYM CERT_ALT_NAME_RFC822_NAME}
  3378. CERT_ALT_NAME_DNS_NAME = 3;
  3379. {$EXTERNALSYM CERT_ALT_NAME_DNS_NAME}
  3380. CERT_ALT_NAME_X400_ADDRESS = 4;
  3381. {$EXTERNALSYM CERT_ALT_NAME_X400_ADDRESS}
  3382. CERT_ALT_NAME_DIRECTORY_NAME = 5;
  3383. {$EXTERNALSYM CERT_ALT_NAME_DIRECTORY_NAME}
  3384. CERT_ALT_NAME_EDI_PARTY_NAME = 6;
  3385. {$EXTERNALSYM CERT_ALT_NAME_EDI_PARTY_NAME}
  3386. CERT_ALT_NAME_URL = 7;
  3387. {$EXTERNALSYM CERT_ALT_NAME_URL}
  3388. CERT_ALT_NAME_IP_ADDRESS = 8;
  3389. {$EXTERNALSYM CERT_ALT_NAME_IP_ADDRESS}
  3390. CERT_ALT_NAME_REGISTERED_ID = 9;
  3391. {$EXTERNALSYM CERT_ALT_NAME_REGISTERED_ID}
  3392. type
  3393. PCERT_ALT_NAME_INFO = ^CERT_ALT_NAME_INFO;
  3394. {$EXTERNALSYM PCERT_ALT_NAME_INFO}
  3395. _CERT_ALT_NAME_INFO = record
  3396. cAltEntry: DWORD;
  3397. rgAltEntry: PCERT_ALT_NAME_ENTRY;
  3398. end;
  3399. {$EXTERNALSYM _CERT_ALT_NAME_INFO}
  3400. CERT_ALT_NAME_INFO = _CERT_ALT_NAME_INFO;
  3401. {$EXTERNALSYM CERT_ALT_NAME_INFO}
  3402. TCertAltNameInfo = CERT_ALT_NAME_INFO;
  3403. PCertAltNameInfo = PCERT_ALT_NAME_INFO;
  3404. //+-------------------------------------------------------------------------
  3405. // Alternate name IA5 Error Location Definitions for
  3406. // CRYPT_E_INVALID_IA5_STRING.
  3407. //
  3408. // Error location is returned in *pcbEncoded by
  3409. // CryptEncodeObject(X509_ALTERNATE_NAME)
  3410. //
  3411. // Error location consists of:
  3412. // ENTRY_INDEX - 8 bits << 16
  3413. // VALUE_INDEX - 16 bits (unicode character index)
  3414. //--------------------------------------------------------------------------
  3415. const
  3416. CERT_ALT_NAME_ENTRY_ERR_INDEX_MASK = $FF;
  3417. {$EXTERNALSYM CERT_ALT_NAME_ENTRY_ERR_INDEX_MASK}
  3418. CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT = 16;
  3419. {$EXTERNALSYM CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT}
  3420. CERT_ALT_NAME_VALUE_ERR_INDEX_MASK = $0000FFFF;
  3421. {$EXTERNALSYM CERT_ALT_NAME_VALUE_ERR_INDEX_MASK}
  3422. CERT_ALT_NAME_VALUE_ERR_INDEX_SHIFT = 0;
  3423. {$EXTERNALSYM CERT_ALT_NAME_VALUE_ERR_INDEX_SHIFT}
  3424. function GET_CERT_ALT_NAME_ENTRY_ERR_INDEX(X: DWORD): DWORD;
  3425. {$EXTERNALSYM GET_CERT_ALT_NAME_ENTRY_ERR_INDEX}
  3426. function GET_CERT_ALT_NAME_VALUE_ERR_INDEX(X: DWORD): DWORD;
  3427. {$EXTERNALSYM GET_CERT_ALT_NAME_VALUE_ERR_INDEX}
  3428. //+-------------------------------------------------------------------------
  3429. // X509_BASIC_CONSTRAINTS
  3430. // szOID_BASIC_CONSTRAINTS
  3431. //
  3432. // pvStructInfo points to following CERT_BASIC_CONSTRAINTS_INFO.
  3433. //--------------------------------------------------------------------------
  3434. type
  3435. PCERT_BASIC_CONSTRAINTS_INFO = ^CERT_BASIC_CONSTRAINTS_INFO;
  3436. {$EXTERNALSYM PCERT_BASIC_CONSTRAINTS_INFO}
  3437. _CERT_BASIC_CONSTRAINTS_INFO = record
  3438. SubjectType: CRYPT_BIT_BLOB;
  3439. fPathLenConstraint: BOOL;
  3440. dwPathLenConstraint: DWORD;
  3441. cSubtreesConstraint: DWORD;
  3442. rgSubtreesConstraint: PCERT_NAME_BLOB;
  3443. end;
  3444. {$EXTERNALSYM _CERT_BASIC_CONSTRAINTS_INFO}
  3445. CERT_BASIC_CONSTRAINTS_INFO = _CERT_BASIC_CONSTRAINTS_INFO;
  3446. {$EXTERNALSYM CERT_BASIC_CONSTRAINTS_INFO}
  3447. TCertBasicConstraintsInfo = CERT_BASIC_CONSTRAINTS_INFO;
  3448. PCertBasicConstraintsInfo = PCERT_BASIC_CONSTRAINTS_INFO;
  3449. const
  3450. CERT_CA_SUBJECT_FLAG = $80;
  3451. {$EXTERNALSYM CERT_CA_SUBJECT_FLAG}
  3452. CERT_END_ENTITY_SUBJECT_FLAG = $40;
  3453. {$EXTERNALSYM CERT_END_ENTITY_SUBJECT_FLAG}
  3454. //+-------------------------------------------------------------------------
  3455. // X509_BASIC_CONSTRAINTS2
  3456. // szOID_BASIC_CONSTRAINTS2
  3457. //
  3458. // pvStructInfo points to following CERT_BASIC_CONSTRAINTS2_INFO.
  3459. //--------------------------------------------------------------------------
  3460. type
  3461. PCERT_BASIC_CONSTRAINTS2_INFO = ^CERT_BASIC_CONSTRAINTS2_INFO;
  3462. {$EXTERNALSYM PCERT_BASIC_CONSTRAINTS2_INFO}
  3463. _CERT_BASIC_CONSTRAINTS2_INFO = record
  3464. fCA: BOOL;
  3465. fPathLenConstraint: BOOL;
  3466. dwPathLenConstraint: DWORD;
  3467. end;
  3468. {$EXTERNALSYM _CERT_BASIC_CONSTRAINTS2_INFO}
  3469. CERT_BASIC_CONSTRAINTS2_INFO = _CERT_BASIC_CONSTRAINTS2_INFO;
  3470. {$EXTERNALSYM CERT_BASIC_CONSTRAINTS2_INFO}
  3471. TCertBasicConstraints2Info = CERT_BASIC_CONSTRAINTS2_INFO;
  3472. PCertBasicConstraints2Info = PCERT_BASIC_CONSTRAINTS2_INFO;
  3473. //+-------------------------------------------------------------------------
  3474. // X509_KEY_USAGE
  3475. // szOID_KEY_USAGE
  3476. //
  3477. // pvStructInfo points to a CRYPT_BIT_BLOB. Has same bit definitions as
  3478. // CERT_KEY_ATTRIBUTES_INFO's IntendedKeyUsage.
  3479. //--------------------------------------------------------------------------
  3480. //+-------------------------------------------------------------------------
  3481. // X509_CERT_POLICIES
  3482. // szOID_CERT_POLICIES
  3483. // szOID_CERT_POLICIES_95 NOTE--Only allowed for decoding!!!
  3484. //
  3485. // pvStructInfo points to following CERT_POLICIES_INFO.
  3486. //
  3487. // NOTE: when decoding using szOID_CERT_POLICIES_95 the pszPolicyIdentifier
  3488. // may contain an empty string
  3489. //--------------------------------------------------------------------------
  3490. PCERT_POLICY_QUALIFIER_INFO = ^CERT_POLICY_QUALIFIER_INFO;
  3491. {$EXTERNALSYM PCERT_POLICY_QUALIFIER_INFO}
  3492. _CERT_POLICY_QUALIFIER_INFO = record
  3493. pszPolicyQualifierId: LPSTR; // pszObjId
  3494. Qualifier: CRYPT_OBJID_BLOB; // optional
  3495. end;
  3496. {$EXTERNALSYM _CERT_POLICY_QUALIFIER_INFO}
  3497. CERT_POLICY_QUALIFIER_INFO = _CERT_POLICY_QUALIFIER_INFO;
  3498. {$EXTERNALSYM CERT_POLICY_QUALIFIER_INFO}
  3499. TCertPolicyQualifierInfo = CERT_POLICY_QUALIFIER_INFO;
  3500. PCertPolicyQualifierInfo = PCERT_POLICY_QUALIFIER_INFO;
  3501. PCERT_POLICY_INFO = ^CERT_POLICY_INFO;
  3502. {$EXTERNALSYM PCERT_POLICY_INFO}
  3503. _CERT_POLICY_INFO = record
  3504. pszPolicyIdentifier: LPSTR; // pszObjId
  3505. cPolicyQualifier: DWORD; // optional
  3506. rgPolicyQualifier: PCERT_POLICY_QUALIFIER_INFO;
  3507. end;
  3508. {$EXTERNALSYM _CERT_POLICY_INFO}
  3509. CERT_POLICY_INFO = _CERT_POLICY_INFO;
  3510. {$EXTERNALSYM CERT_POLICY_INFO}
  3511. TCertPolicyInfo = CERT_POLICY_INFO;
  3512. PCertPolicyInfo = PCERT_POLICY_INFO;
  3513. PCERT_POLICIES_INFO = ^CERT_POLICIES_INFO;
  3514. {$EXTERNALSYM PCERT_POLICIES_INFO}
  3515. _CERT_POLICIES_INFO = record
  3516. cPolicyInfo: DWORD;
  3517. rgPolicyInfo: PCERT_POLICY_INFO;
  3518. end;
  3519. {$EXTERNALSYM _CERT_POLICIES_INFO}
  3520. CERT_POLICIES_INFO = _CERT_POLICIES_INFO;
  3521. {$EXTERNALSYM CERT_POLICIES_INFO}
  3522. TCertPoliciesInfo = CERT_POLICIES_INFO;
  3523. PCertPoliciesInfo = PCERT_POLICIES_INFO;
  3524. //+-------------------------------------------------------------------------
  3525. // X509_PKIX_POLICY_QUALIFIER_USERNOTICE
  3526. // szOID_PKIX_POLICY_QUALIFIER_USERNOTICE
  3527. //
  3528. // pvStructInfo points to following CERT_POLICY_QUALIFIER_USER_NOTICE.
  3529. //
  3530. //--------------------------------------------------------------------------
  3531. PCERT_POLICY_QUALIFIER_NOTICE_REFERENCE = ^CERT_POLICY_QUALIFIER_NOTICE_REFERENCE;
  3532. {$EXTERNALSYM PCERT_POLICY_QUALIFIER_NOTICE_REFERENCE}
  3533. _CERT_POLICY_QUALIFIER_NOTICE_REFERENCE = record
  3534. pszOrganization: LPSTR;
  3535. cNoticeNumbers: DWORD;
  3536. rgNoticeNumbers: LPINT;
  3537. end;
  3538. {$EXTERNALSYM _CERT_POLICY_QUALIFIER_NOTICE_REFERENCE}
  3539. CERT_POLICY_QUALIFIER_NOTICE_REFERENCE = _CERT_POLICY_QUALIFIER_NOTICE_REFERENCE;
  3540. {$EXTERNALSYM CERT_POLICY_QUALIFIER_NOTICE_REFERENCE}
  3541. TCertPolicyQualifierNoticeReference = CERT_POLICY_QUALIFIER_NOTICE_REFERENCE;
  3542. PCertPolicyQualifierNoticeReference = PCERT_POLICY_QUALIFIER_NOTICE_REFERENCE;
  3543. PCERT_POLICY_QUALIFIER_USER_NOTICE = ^CERT_POLICY_QUALIFIER_USER_NOTICE;
  3544. {$EXTERNALSYM PCERT_POLICY_QUALIFIER_USER_NOTICE}
  3545. _CERT_POLICY_QUALIFIER_USER_NOTICE = record
  3546. pNoticeReference: PCERT_POLICY_QUALIFIER_NOTICE_REFERENCE; // optional
  3547. pszDisplayText: LPWSTR; // optional
  3548. end;
  3549. {$EXTERNALSYM _CERT_POLICY_QUALIFIER_USER_NOTICE}
  3550. CERT_POLICY_QUALIFIER_USER_NOTICE = _CERT_POLICY_QUALIFIER_USER_NOTICE;
  3551. {$EXTERNALSYM CERT_POLICY_QUALIFIER_USER_NOTICE}
  3552. TCertPolicyQualifierUserNotice = CERT_POLICY_QUALIFIER_USER_NOTICE;
  3553. PCertPolicyQualifierUserNotice = PCERT_POLICY_QUALIFIER_USER_NOTICE;
  3554. //+-------------------------------------------------------------------------
  3555. // szOID_CERT_POLICIES_95_QUALIFIER1 - Decode Only!!!!
  3556. //
  3557. // pvStructInfo points to following CERT_POLICY95_QUALIFIER1.
  3558. //
  3559. //--------------------------------------------------------------------------
  3560. PCPS_URLS = ^CPS_URLS;
  3561. {$EXTERNALSYM PCPS_URLS}
  3562. _CPS_URLS = record
  3563. pszURL: LPWSTR;
  3564. pAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER; // optional
  3565. pDigest: PCRYPT_DATA_BLOB; // optional
  3566. end;
  3567. {$EXTERNALSYM _CPS_URLS}
  3568. CPS_URLS = _CPS_URLS;
  3569. {$EXTERNALSYM CPS_URLS}
  3570. TCpsUrls = CPS_URLS;
  3571. PCpsUrls = PCPS_URLS;
  3572. PCERT_POLICY95_QUALIFIER1 = ^CERT_POLICY95_QUALIFIER1;
  3573. {$EXTERNALSYM PCERT_POLICY95_QUALIFIER1}
  3574. _CERT_POLICY95_QUALIFIER1 = record
  3575. pszPracticesReference: LPWSTR; // optional
  3576. pszNoticeIdentifier: LPSTR; // optional
  3577. pszNSINoticeIdentifier: LPSTR; // optional
  3578. cCPSURLs: DWORD;
  3579. rgCPSURLs: PCPS_URLS; // optional
  3580. end;
  3581. {$EXTERNALSYM _CERT_POLICY95_QUALIFIER1}
  3582. CERT_POLICY95_QUALIFIER1 = _CERT_POLICY95_QUALIFIER1;
  3583. {$EXTERNALSYM CERT_POLICY95_QUALIFIER1}
  3584. TCertPolicy95Qualifier1 = CERT_POLICY95_QUALIFIER1;
  3585. PCertPolicy95Qualifier1 = PCERT_POLICY95_QUALIFIER1;
  3586. //+-------------------------------------------------------------------------
  3587. // RSA_CSP_PUBLICKEYBLOB
  3588. //
  3589. // pvStructInfo points to a PUBLICKEYSTRUC immediately followed by a
  3590. // RSAPUBKEY and the modulus bytes.
  3591. //
  3592. // CryptExportKey outputs the above StructInfo for a dwBlobType of
  3593. // PUBLICKEYBLOB. CryptImportKey expects the above StructInfo when
  3594. // importing a public key.
  3595. //
  3596. // For dwCertEncodingType = X509_ASN_ENCODING, the RSA_CSP_PUBLICKEYBLOB is
  3597. // encoded as a PKCS #1 RSAPublicKey consisting of a SEQUENCE of a
  3598. // modulus INTEGER and a publicExponent INTEGER. The modulus is encoded
  3599. // as being a unsigned integer. When decoded, if the modulus was encoded
  3600. // as unsigned integer with a leading 0 byte, the 0 byte is removed before
  3601. // converting to the CSP modulus bytes.
  3602. //
  3603. // For decode, the aiKeyAlg field of PUBLICKEYSTRUC is always set to
  3604. // CALG_RSA_KEYX.
  3605. //--------------------------------------------------------------------------
  3606. //+-------------------------------------------------------------------------
  3607. // X509_KEYGEN_REQUEST_TO_BE_SIGNED
  3608. //
  3609. // pvStructInfo points to CERT_KEYGEN_REQUEST_INFO.
  3610. //
  3611. // For CryptDecodeObject(), the pbEncoded is the "to be signed" plus its
  3612. // signature (output of a X509_CERT CryptEncodeObject()).
  3613. //
  3614. // For CryptEncodeObject(), the pbEncoded is just the "to be signed".
  3615. //--------------------------------------------------------------------------
  3616. //+-------------------------------------------------------------------------
  3617. // PKCS_ATTRIBUTE data structure
  3618. //
  3619. // pvStructInfo points to a CRYPT_ATTRIBUTE.
  3620. //--------------------------------------------------------------------------
  3621. //+-------------------------------------------------------------------------
  3622. // PKCS_ATTRIBUTES data structure
  3623. //
  3624. // pvStructInfo points to a CRYPT_ATTRIBUTES.
  3625. //--------------------------------------------------------------------------
  3626. //+-------------------------------------------------------------------------
  3627. // PKCS_CONTENT_INFO_SEQUENCE_OF_ANY data structure
  3628. //
  3629. // pvStructInfo points to following CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY.
  3630. //
  3631. // For X509_ASN_ENCODING: encoded as a PKCS#7 ContentInfo structure wrapping
  3632. // a sequence of ANY. The value of the contentType field is pszObjId,
  3633. // while the content field is the following structure:
  3634. // SequenceOfAny ::= SEQUENCE OF ANY
  3635. //
  3636. // The CRYPT_DER_BLOBs point to the already encoded ANY content.
  3637. //--------------------------------------------------------------------------
  3638. PCRYPT_CONTENT_INFO_SEQUENCE_OF_ANY = ^CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY;
  3639. {$EXTERNALSYM PCRYPT_CONTENT_INFO_SEQUENCE_OF_ANY}
  3640. _CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY = record
  3641. pszObjId: LPSTR;
  3642. cValue: DWORD;
  3643. rgValue: PCRYPT_DER_BLOB;
  3644. end;
  3645. {$EXTERNALSYM _CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY}
  3646. CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY = _CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY;
  3647. {$EXTERNALSYM CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY}
  3648. TCryptContentInfoSequenceOfAny = CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY;
  3649. PCryptContentInfoSequenceOfAny = PCRYPT_CONTENT_INFO_SEQUENCE_OF_ANY;
  3650. //+-------------------------------------------------------------------------
  3651. // PKCS_CONTENT_INFO data structure
  3652. //
  3653. // pvStructInfo points to following CRYPT_CONTENT_INFO.
  3654. //
  3655. // For X509_ASN_ENCODING: encoded as a PKCS#7 ContentInfo structure.
  3656. // The CRYPT_DER_BLOB points to the already encoded ANY content.
  3657. //--------------------------------------------------------------------------
  3658. PCRYPT_CONTENT_INFO = ^CRYPT_CONTENT_INFO;
  3659. {$EXTERNALSYM PCRYPT_CONTENT_INFO}
  3660. _CRYPT_CONTENT_INFO = record
  3661. pszObjId: LPSTR;
  3662. Content: CRYPT_DER_BLOB;
  3663. end;
  3664. {$EXTERNALSYM _CRYPT_CONTENT_INFO}
  3665. CRYPT_CONTENT_INFO = _CRYPT_CONTENT_INFO;
  3666. {$EXTERNALSYM CRYPT_CONTENT_INFO}
  3667. TCryptContentInfo = CRYPT_CONTENT_INFO;
  3668. PCryptContentInfo = PCRYPT_CONTENT_INFO;
  3669. //+-------------------------------------------------------------------------
  3670. // X509_OCTET_STRING data structure
  3671. //
  3672. // pvStructInfo points to a CRYPT_DATA_BLOB.
  3673. //--------------------------------------------------------------------------
  3674. //+-------------------------------------------------------------------------
  3675. // X509_BITS data structure
  3676. //
  3677. // pvStructInfo points to a CRYPT_BIT_BLOB.
  3678. //--------------------------------------------------------------------------
  3679. //+-------------------------------------------------------------------------
  3680. // X509_BITS_WITHOUT_TRAILING_ZEROES data structure
  3681. //
  3682. // pvStructInfo points to a CRYPT_BIT_BLOB.
  3683. //
  3684. // The same as X509_BITS, except before encoding, the bit length is
  3685. // decremented to exclude trailing zero bits.
  3686. //--------------------------------------------------------------------------
  3687. //+-------------------------------------------------------------------------
  3688. // X509_INTEGER data structure
  3689. //
  3690. // pvStructInfo points to an int.
  3691. //--------------------------------------------------------------------------
  3692. //+-------------------------------------------------------------------------
  3693. // X509_MULTI_BYTE_INTEGER data structure
  3694. //
  3695. // pvStructInfo points to a CRYPT_INTEGER_BLOB.
  3696. //--------------------------------------------------------------------------
  3697. //+-------------------------------------------------------------------------
  3698. // X509_ENUMERATED data structure
  3699. //
  3700. // pvStructInfo points to an int containing the enumerated value
  3701. //--------------------------------------------------------------------------
  3702. //+-------------------------------------------------------------------------
  3703. // X509_CHOICE_OF_TIME data structure
  3704. //
  3705. // pvStructInfo points to a FILETIME.
  3706. //--------------------------------------------------------------------------
  3707. //+-------------------------------------------------------------------------
  3708. // X509_SEQUENCE_OF_ANY data structure
  3709. //
  3710. // pvStructInfo points to following CRYPT_SEQUENCE_OF_ANY.
  3711. //
  3712. // The CRYPT_DER_BLOBs point to the already encoded ANY content.
  3713. //--------------------------------------------------------------------------
  3714. PCRYPT_SEQUENCE_OF_ANY = ^CRYPT_SEQUENCE_OF_ANY;
  3715. {$EXTERNALSYM PCRYPT_SEQUENCE_OF_ANY}
  3716. _CRYPT_SEQUENCE_OF_ANY = record
  3717. cValue: DWORD;
  3718. rgValue: PCRYPT_DER_BLOB;
  3719. end;
  3720. {$EXTERNALSYM _CRYPT_SEQUENCE_OF_ANY}
  3721. CRYPT_SEQUENCE_OF_ANY = _CRYPT_SEQUENCE_OF_ANY;
  3722. {$EXTERNALSYM CRYPT_SEQUENCE_OF_ANY}
  3723. TCryptSequenceOfAny = CRYPT_SEQUENCE_OF_ANY;
  3724. PCryptSequenceOfAny = PCRYPT_SEQUENCE_OF_ANY;
  3725. //+-------------------------------------------------------------------------
  3726. // X509_AUTHORITY_KEY_ID2
  3727. // szOID_AUTHORITY_KEY_IDENTIFIER2
  3728. //
  3729. // pvStructInfo points to following CERT_AUTHORITY_KEY_ID2_INFO.
  3730. //
  3731. // For CRYPT_E_INVALID_IA5_STRING, the error location is returned in
  3732. // *pcbEncoded by CryptEncodeObject(X509_AUTHORITY_KEY_ID2)
  3733. //
  3734. // See X509_ALTERNATE_NAME for error location defines.
  3735. //--------------------------------------------------------------------------
  3736. PCERT_AUTHORITY_KEY_ID2_INFO = ^CERT_AUTHORITY_KEY_ID2_INFO;
  3737. {$EXTERNALSYM PCERT_AUTHORITY_KEY_ID2_INFO}
  3738. _CERT_AUTHORITY_KEY_ID2_INFO = record
  3739. KeyId: CRYPT_DATA_BLOB;
  3740. AuthorityCertIssuer: CERT_ALT_NAME_INFO; // Optional, set cAltEntry
  3741. // to 0 to omit.
  3742. AuthorityCertSerialNumber: CRYPT_INTEGER_BLOB;
  3743. end;
  3744. {$EXTERNALSYM _CERT_AUTHORITY_KEY_ID2_INFO}
  3745. CERT_AUTHORITY_KEY_ID2_INFO = _CERT_AUTHORITY_KEY_ID2_INFO;
  3746. {$EXTERNALSYM CERT_AUTHORITY_KEY_ID2_INFO}
  3747. TCertAuthorityKeyId2Info = CERT_AUTHORITY_KEY_ID2_INFO;
  3748. PCertAuthorityKeyId2Info = PCERT_AUTHORITY_KEY_ID2_INFO;
  3749. //+-------------------------------------------------------------------------
  3750. // szOID_SUBJECT_KEY_IDENTIFIER
  3751. //
  3752. // pvStructInfo points to a CRYPT_DATA_BLOB.
  3753. //--------------------------------------------------------------------------
  3754. //+-------------------------------------------------------------------------
  3755. // X509_AUTHORITY_INFO_ACCESS
  3756. // szOID_AUTHORITY_INFO_ACCESS
  3757. //
  3758. // pvStructInfo points to following CERT_AUTHORITY_INFO_ACCESS.
  3759. //
  3760. // For CRYPT_E_INVALID_IA5_STRING, the error location is returned in
  3761. // *pcbEncoded by CryptEncodeObject(X509_AUTHORITY_INFO_ACCESS)
  3762. //
  3763. // Error location consists of:
  3764. // ENTRY_INDEX - 8 bits << 16
  3765. // VALUE_INDEX - 16 bits (unicode character index)
  3766. //
  3767. // See X509_ALTERNATE_NAME for ENTRY_INDEX and VALUE_INDEX error location
  3768. // defines.
  3769. //--------------------------------------------------------------------------
  3770. PCERT_ACCESS_DESCRIPTION = ^CERT_ACCESS_DESCRIPTION;
  3771. {$EXTERNALSYM PCERT_ACCESS_DESCRIPTION}
  3772. _CERT_ACCESS_DESCRIPTION = record
  3773. pszAccessMethod: LPSTR; // pszObjId
  3774. AccessLocation: CERT_ALT_NAME_ENTRY;
  3775. end;
  3776. {$EXTERNALSYM _CERT_ACCESS_DESCRIPTION}
  3777. CERT_ACCESS_DESCRIPTION = _CERT_ACCESS_DESCRIPTION;
  3778. {$EXTERNALSYM CERT_ACCESS_DESCRIPTION}
  3779. TCertAccessDescription = CERT_ACCESS_DESCRIPTION;
  3780. PCertAccessDescription = PCERT_ACCESS_DESCRIPTION;
  3781. PCERT_AUTHORITY_INFO_ACCESS = ^CERT_AUTHORITY_INFO_ACCESS;
  3782. {$EXTERNALSYM PCERT_AUTHORITY_INFO_ACCESS}
  3783. _CERT_AUTHORITY_INFO_ACCESS = record
  3784. cAccDescr: DWORD;
  3785. rgAccDescr: PCERT_ACCESS_DESCRIPTION;
  3786. end;
  3787. {$EXTERNALSYM _CERT_AUTHORITY_INFO_ACCESS}
  3788. CERT_AUTHORITY_INFO_ACCESS = _CERT_AUTHORITY_INFO_ACCESS;
  3789. {$EXTERNALSYM CERT_AUTHORITY_INFO_ACCESS}
  3790. TCertAuthorityInfoAccess = CERT_AUTHORITY_INFO_ACCESS;
  3791. PCertAuthorityInfoAccess = PCERT_AUTHORITY_INFO_ACCESS;
  3792. //+-------------------------------------------------------------------------
  3793. // PKIX Access Description: Access Method Object Identifiers
  3794. //--------------------------------------------------------------------------
  3795. const
  3796. szOID_PKIX_ACC_DESCR = '1.3.6.1.5.5.7.48';
  3797. {$EXTERNALSYM szOID_PKIX_ACC_DESCR}
  3798. szOID_PKIX_OCSP = '1.3.6.1.5.5.7.48.1';
  3799. {$EXTERNALSYM szOID_PKIX_OCSP}
  3800. szOID_PKIX_CA_ISSUERS = '1.3.6.1.5.5.7.48.2';
  3801. {$EXTERNALSYM szOID_PKIX_CA_ISSUERS}
  3802. //+-------------------------------------------------------------------------
  3803. // X509_CRL_REASON_CODE
  3804. // szOID_CRL_REASON_CODE
  3805. //
  3806. // pvStructInfo points to an int which can be set to one of the following
  3807. // enumerated values:
  3808. //--------------------------------------------------------------------------
  3809. CRL_REASON_UNSPECIFIED = 0;
  3810. {$EXTERNALSYM CRL_REASON_UNSPECIFIED}
  3811. CRL_REASON_KEY_COMPROMISE = 1;
  3812. {$EXTERNALSYM CRL_REASON_KEY_COMPROMISE}
  3813. CRL_REASON_CA_COMPROMISE = 2;
  3814. {$EXTERNALSYM CRL_REASON_CA_COMPROMISE}
  3815. CRL_REASON_AFFILIATION_CHANGED = 3;
  3816. {$EXTERNALSYM CRL_REASON_AFFILIATION_CHANGED}
  3817. CRL_REASON_SUPERSEDED = 4;
  3818. {$EXTERNALSYM CRL_REASON_SUPERSEDED}
  3819. CRL_REASON_CESSATION_OF_OPERATION = 5;
  3820. {$EXTERNALSYM CRL_REASON_CESSATION_OF_OPERATION}
  3821. CRL_REASON_CERTIFICATE_HOLD = 6;
  3822. {$EXTERNALSYM CRL_REASON_CERTIFICATE_HOLD}
  3823. CRL_REASON_REMOVE_FROM_CRL = 8;
  3824. {$EXTERNALSYM CRL_REASON_REMOVE_FROM_CRL}
  3825. //+-------------------------------------------------------------------------
  3826. // X509_CRL_DIST_POINTS
  3827. // szOID_CRL_DIST_POINTS
  3828. //
  3829. // pvStructInfo points to following CRL_DIST_POINTS_INFO.
  3830. //
  3831. // For CRYPT_E_INVALID_IA5_STRING, the error location is returned in
  3832. // *pcbEncoded by CryptEncodeObject(X509_CRL_DIST_POINTS)
  3833. //
  3834. // Error location consists of:
  3835. // CRL_ISSUER_BIT - 1 bit << 31 (0 for FullName, 1 for CRLIssuer)
  3836. // POINT_INDEX - 7 bits << 24
  3837. // ENTRY_INDEX - 8 bits << 16
  3838. // VALUE_INDEX - 16 bits (unicode character index)
  3839. //
  3840. // See X509_ALTERNATE_NAME for ENTRY_INDEX and VALUE_INDEX error location
  3841. // defines.
  3842. //--------------------------------------------------------------------------
  3843. type
  3844. PCRL_DIST_POINT_NAME = ^CRL_DIST_POINT_NAME;
  3845. {$EXTERNALSYM PCRL_DIST_POINT_NAME}
  3846. _CRL_DIST_POINT_NAME = record
  3847. dwDistPointNameChoice: DWORD;
  3848. case Integer of
  3849. 0: (FullName: CERT_ALT_NAME_INFO); // 1
  3850. 1: ();// Not implemented IssuerRDN; // 2
  3851. end;
  3852. {$EXTERNALSYM _CRL_DIST_POINT_NAME}
  3853. CRL_DIST_POINT_NAME = _CRL_DIST_POINT_NAME;
  3854. {$EXTERNALSYM CRL_DIST_POINT_NAME}
  3855. TCrlDistPointName = CRL_DIST_POINT_NAME;
  3856. PCrlDistPointName = PCRL_DIST_POINT_NAME;
  3857. const
  3858. CRL_DIST_POINT_NO_NAME = 0;
  3859. {$EXTERNALSYM CRL_DIST_POINT_NO_NAME}
  3860. CRL_DIST_POINT_FULL_NAME = 1;
  3861. {$EXTERNALSYM CRL_DIST_POINT_FULL_NAME}
  3862. CRL_DIST_POINT_ISSUER_RDN_NAME = 2;
  3863. {$EXTERNALSYM CRL_DIST_POINT_ISSUER_RDN_NAME}
  3864. type
  3865. PCRL_DIST_POINT = ^CRL_DIST_POINT;
  3866. {$EXTERNALSYM PCRL_DIST_POINT}
  3867. _CRL_DIST_POINT = record
  3868. DistPointName: CRL_DIST_POINT_NAME; // OPTIONAL
  3869. ReasonFlags: CRYPT_BIT_BLOB; // OPTIONAL
  3870. CRLIssuer: CERT_ALT_NAME_INFO; // OPTIONAL
  3871. end;
  3872. {$EXTERNALSYM _CRL_DIST_POINT}
  3873. CRL_DIST_POINT = _CRL_DIST_POINT;
  3874. {$EXTERNALSYM CRL_DIST_POINT}
  3875. TCrlDistPoint = CRL_DIST_POINT;
  3876. PCrlDistPoint = PCRL_DIST_POINT;
  3877. const
  3878. CRL_REASON_UNUSED_FLAG = $80;
  3879. {$EXTERNALSYM CRL_REASON_UNUSED_FLAG}
  3880. CRL_REASON_KEY_COMPROMISE_FLAG = $40;
  3881. {$EXTERNALSYM CRL_REASON_KEY_COMPROMISE_FLAG}
  3882. CRL_REASON_CA_COMPROMISE_FLAG = $20;
  3883. {$EXTERNALSYM CRL_REASON_CA_COMPROMISE_FLAG}
  3884. CRL_REASON_AFFILIATION_CHANGED_FLAG = $10;
  3885. {$EXTERNALSYM CRL_REASON_AFFILIATION_CHANGED_FLAG}
  3886. CRL_REASON_SUPERSEDED_FLAG = $08;
  3887. {$EXTERNALSYM CRL_REASON_SUPERSEDED_FLAG}
  3888. CRL_REASON_CESSATION_OF_OPERATION_FLAG = $04;
  3889. {$EXTERNALSYM CRL_REASON_CESSATION_OF_OPERATION_FLAG}
  3890. CRL_REASON_CERTIFICATE_HOLD_FLAG = $02;
  3891. {$EXTERNALSYM CRL_REASON_CERTIFICATE_HOLD_FLAG}
  3892. type
  3893. PCRL_DIST_POINTS_INFO = ^CRL_DIST_POINTS_INFO;
  3894. {$EXTERNALSYM PCRL_DIST_POINTS_INFO}
  3895. _CRL_DIST_POINTS_INFO = record
  3896. cDistPoint: DWORD;
  3897. rgDistPoint: PCRL_DIST_POINT;
  3898. end;
  3899. {$EXTERNALSYM _CRL_DIST_POINTS_INFO}
  3900. CRL_DIST_POINTS_INFO = _CRL_DIST_POINTS_INFO;
  3901. {$EXTERNALSYM CRL_DIST_POINTS_INFO}
  3902. TCrlDistPointsInfo = CRL_DIST_POINTS_INFO;
  3903. PCrlDistPointsInfo = PCRL_DIST_POINTS_INFO;
  3904. const
  3905. CRL_DIST_POINT_ERR_INDEX_MASK = $7F;
  3906. {$EXTERNALSYM CRL_DIST_POINT_ERR_INDEX_MASK}
  3907. CRL_DIST_POINT_ERR_INDEX_SHIFT = 24;
  3908. {$EXTERNALSYM CRL_DIST_POINT_ERR_INDEX_SHIFT}
  3909. function GET_CRL_DIST_POINT_ERR_INDEX(X: DWORD): DWORD;
  3910. {$EXTERNALSYM GET_CRL_DIST_POINT_ERR_INDEX}
  3911. const
  3912. CRL_DIST_POINT_ERR_CRL_ISSUER_BIT = DWORD($80000000);
  3913. {$EXTERNALSYM CRL_DIST_POINT_ERR_CRL_ISSUER_BIT}
  3914. function IS_CRL_DIST_POINT_ERR_CRL_ISSUER(X: DWORD): Boolean;
  3915. {$EXTERNALSYM IS_CRL_DIST_POINT_ERR_CRL_ISSUER}
  3916. //+-------------------------------------------------------------------------
  3917. // X509_ENHANCED_KEY_USAGE
  3918. // szOID_ENHANCED_KEY_USAGE
  3919. //
  3920. // pvStructInfo points to a CERT_ENHKEY_USAGE, CTL_USAGE.
  3921. //--------------------------------------------------------------------------
  3922. //+-------------------------------------------------------------------------
  3923. // szOID_NEXT_UPDATE_LOCATION
  3924. //
  3925. // pvStructInfo points to a CERT_ALT_NAME_INFO.
  3926. //--------------------------------------------------------------------------
  3927. //+-------------------------------------------------------------------------
  3928. // PKCS_CTL
  3929. // szOID_CTL
  3930. //
  3931. // pvStructInfo points to a CTL_INFO.
  3932. //--------------------------------------------------------------------------
  3933. //+-------------------------------------------------------------------------
  3934. // PKCS_SORTED_CTL
  3935. //
  3936. // pvStructInfo points to a CTL_INFO.
  3937. //
  3938. // Same as for PKCS_CTL, except, the CTL entries are sorted. The following
  3939. // extension containing the sort information is inserted as the first
  3940. // extension in the encoded CTL.
  3941. //
  3942. // Only supported for Encoding. CRYPT_ENCODE_ALLOC_FLAG flag must be
  3943. // set.
  3944. //--------------------------------------------------------------------------
  3945. //+-------------------------------------------------------------------------
  3946. // Sorted CTL TrustedSubjects extension
  3947. //
  3948. // Array of little endian DWORDs:
  3949. // [0] - Flags
  3950. // [1] - Count of HashBucket entry offsets
  3951. // [2] - Maximum HashBucket entry collision count
  3952. // [3 ..] (Count + 1) HashBucket entry offsets
  3953. //
  3954. // When this extension is present in the CTL,
  3955. // the ASN.1 encoded sequence of TrustedSubjects are HashBucket ordered.
  3956. //
  3957. // The entry offsets point to the start of the first encoded TrustedSubject
  3958. // sequence for the HashBucket. The encoded TrustedSubjects for a HashBucket
  3959. // continue until the encoded offset of the next HashBucket. A HashBucket has
  3960. // no entries if HashBucket[N] == HashBucket[N + 1].
  3961. //
  3962. // The HashBucket offsets are from the start of the ASN.1 encoded CTL_INFO.
  3963. //--------------------------------------------------------------------------
  3964. const
  3965. SORTED_CTL_EXT_FLAGS_OFFSET = 0 * 4;
  3966. {$EXTERNALSYM SORTED_CTL_EXT_FLAGS_OFFSET}
  3967. SORTED_CTL_EXT_COUNT_OFFSET = 1 * 4;
  3968. {$EXTERNALSYM SORTED_CTL_EXT_COUNT_OFFSET}
  3969. SORTED_CTL_EXT_MAX_COLLISION_OFFSET = 2 * 4;
  3970. {$EXTERNALSYM SORTED_CTL_EXT_MAX_COLLISION_OFFSET}
  3971. SORTED_CTL_EXT_HASH_BUCKET_OFFSET = 3 * 4;
  3972. {$EXTERNALSYM SORTED_CTL_EXT_HASH_BUCKET_OFFSET}
  3973. // If the SubjectIdentifiers are a MD5 or SHA1 hash, the following flag is
  3974. // set. When set, the first 4 bytes of the SubjectIdentifier are used as
  3975. // the dwhash. Otherwise, the SubjectIdentifier bytes are hashed into dwHash.
  3976. // In either case the HashBucket index = dwHash % cHashBucket.
  3977. SORTED_CTL_EXT_HASHED_SUBJECT_IDENTIFIER_FLAG = $1;
  3978. {$EXTERNALSYM SORTED_CTL_EXT_HASHED_SUBJECT_IDENTIFIER_FLAG}
  3979. //+-------------------------------------------------------------------------
  3980. // X509_MULTI_BYTE_UINT
  3981. //
  3982. // pvStructInfo points to a CRYPT_UINT_BLOB. Before encoding, inserts a
  3983. // leading 0x00. After decoding, removes a leading 0x00.
  3984. //--------------------------------------------------------------------------
  3985. //+-------------------------------------------------------------------------
  3986. // X509_DSS_PUBLICKEY
  3987. //
  3988. // pvStructInfo points to a CRYPT_UINT_BLOB.
  3989. //--------------------------------------------------------------------------
  3990. //+-------------------------------------------------------------------------
  3991. // X509_DSS_PARAMETERS
  3992. //
  3993. // pvStructInfo points to following CERT_DSS_PARAMETERS data structure.
  3994. //--------------------------------------------------------------------------
  3995. type
  3996. PCERT_DSS_PARAMETERS = ^CERT_DSS_PARAMETERS;
  3997. {$EXTERNALSYM PCERT_DSS_PARAMETERS}
  3998. _CERT_DSS_PARAMETERS = record
  3999. p: CRYPT_UINT_BLOB;
  4000. q: CRYPT_UINT_BLOB;
  4001. g: CRYPT_UINT_BLOB;
  4002. end;
  4003. {$EXTERNALSYM _CERT_DSS_PARAMETERS}
  4004. CERT_DSS_PARAMETERS = _CERT_DSS_PARAMETERS;
  4005. {$EXTERNALSYM CERT_DSS_PARAMETERS}
  4006. TCertDssParameters = CERT_DSS_PARAMETERS;
  4007. PCertDssParameters = PCERT_DSS_PARAMETERS;
  4008. //+-------------------------------------------------------------------------
  4009. // X509_DSS_SIGNATURE
  4010. //
  4011. // pvStructInfo is a BYTE rgbSignature[CERT_DSS_SIGNATURE_LEN]. The
  4012. // bytes are ordered as output by the DSS CSP's CryptSignHash().
  4013. //--------------------------------------------------------------------------
  4014. const
  4015. CERT_DSS_R_LEN = 20;
  4016. {$EXTERNALSYM CERT_DSS_R_LEN}
  4017. CERT_DSS_S_LEN = 20;
  4018. {$EXTERNALSYM CERT_DSS_S_LEN}
  4019. CERT_DSS_SIGNATURE_LEN = CERT_DSS_R_LEN + CERT_DSS_S_LEN;
  4020. {$EXTERNALSYM CERT_DSS_SIGNATURE_LEN}
  4021. // Sequence of 2 unsigned integers (the extra +1 is for a potential leading
  4022. // 0x00 to make the integer unsigned)
  4023. CERT_MAX_ASN_ENCODED_DSS_SIGNATURE_LEN = 2 + 2 * (2 + 20 + 1);
  4024. {$EXTERNALSYM CERT_MAX_ASN_ENCODED_DSS_SIGNATURE_LEN}
  4025. //+-------------------------------------------------------------------------
  4026. // X509_DH_PUBLICKEY
  4027. //
  4028. // pvStructInfo points to a CRYPT_UINT_BLOB.
  4029. //--------------------------------------------------------------------------
  4030. //+-------------------------------------------------------------------------
  4031. // X509_DH_PARAMETERS
  4032. //
  4033. // pvStructInfo points to following CERT_DH_PARAMETERS data structure.
  4034. //--------------------------------------------------------------------------
  4035. type
  4036. PCERT_DH_PARAMETERS = ^CERT_DH_PARAMETERS;
  4037. {$EXTERNALSYM PCERT_DH_PARAMETERS}
  4038. _CERT_DH_PARAMETERS = record
  4039. p: CRYPT_UINT_BLOB;
  4040. g: CRYPT_UINT_BLOB;
  4041. end;
  4042. {$EXTERNALSYM _CERT_DH_PARAMETERS}
  4043. CERT_DH_PARAMETERS = _CERT_DH_PARAMETERS;
  4044. {$EXTERNALSYM CERT_DH_PARAMETERS}
  4045. TCertDhParameters = CERT_DH_PARAMETERS;
  4046. PCertDhParameters = PCERT_DH_PARAMETERS;
  4047. //+-------------------------------------------------------------------------
  4048. // X942_DH_PARAMETERS
  4049. //
  4050. // pvStructInfo points to following CERT_X942_DH_PARAMETERS data structure.
  4051. //
  4052. // If q.cbData == 0, then, the following fields are zero'ed.
  4053. //--------------------------------------------------------------------------
  4054. PCERT_X942_DH_VALIDATION_PARAMS = ^CERT_X942_DH_VALIDATION_PARAMS;
  4055. {$EXTERNALSYM PCERT_X942_DH_VALIDATION_PARAMS}
  4056. _CERT_X942_DH_VALIDATION_PARAMS = record
  4057. seed: CRYPT_BIT_BLOB;
  4058. pgenCounter: DWORD;
  4059. end;
  4060. {$EXTERNALSYM _CERT_X942_DH_VALIDATION_PARAMS}
  4061. CERT_X942_DH_VALIDATION_PARAMS = _CERT_X942_DH_VALIDATION_PARAMS;
  4062. {$EXTERNALSYM CERT_X942_DH_VALIDATION_PARAMS}
  4063. TCertX942DhValidationParams = CERT_X942_DH_VALIDATION_PARAMS;
  4064. PCertX942DhValidationParams = PCERT_X942_DH_VALIDATION_PARAMS;
  4065. PCERT_X942_DH_PARAMETERS = ^CERT_X942_DH_PARAMETERS;
  4066. {$EXTERNALSYM PCERT_X942_DH_PARAMETERS}
  4067. _CERT_X942_DH_PARAMETERS = record
  4068. p: CRYPT_UINT_BLOB; // odd prime, p = jq + 1
  4069. g: CRYPT_UINT_BLOB; // generator, g
  4070. q: CRYPT_UINT_BLOB; // factor of p - 1, OPTIONAL
  4071. j: CRYPT_UINT_BLOB; // subgroup factor, OPTIONAL
  4072. pValidationParams: PCERT_X942_DH_VALIDATION_PARAMS; // OPTIONAL
  4073. end;
  4074. {$EXTERNALSYM _CERT_X942_DH_PARAMETERS}
  4075. CERT_X942_DH_PARAMETERS = _CERT_X942_DH_PARAMETERS;
  4076. {$EXTERNALSYM CERT_X942_DH_PARAMETERS}
  4077. TCertX942DhParameters = CERT_X942_DH_PARAMETERS;
  4078. PCertX942DhParameters = PCERT_X942_DH_PARAMETERS;
  4079. //+-------------------------------------------------------------------------
  4080. // X942_OTHER_INFO
  4081. //
  4082. // pvStructInfo points to following CRYPT_X942_OTHER_INFO data structure.
  4083. //
  4084. // rgbCounter and rgbKeyLength are in Little Endian order.
  4085. //--------------------------------------------------------------------------
  4086. const
  4087. CRYPT_X942_COUNTER_BYTE_LENGTH = 4;
  4088. {$EXTERNALSYM CRYPT_X942_COUNTER_BYTE_LENGTH}
  4089. CRYPT_X942_KEY_LENGTH_BYTE_LENGTH = 4;
  4090. {$EXTERNALSYM CRYPT_X942_KEY_LENGTH_BYTE_LENGTH}
  4091. CRYPT_X942_PUB_INFO_BYTE_LENGTH = 512 div 8;
  4092. {$EXTERNALSYM CRYPT_X942_PUB_INFO_BYTE_LENGTH}
  4093. type
  4094. PCRYPT_X942_OTHER_INFO = ^CRYPT_X942_OTHER_INFO;
  4095. {$EXTERNALSYM PCRYPT_X942_OTHER_INFO}
  4096. _CRYPT_X942_OTHER_INFO = record
  4097. pszContentEncryptionObjId: LPSTR;
  4098. rgbCounter: array [0..CRYPT_X942_COUNTER_BYTE_LENGTH - 1] of BYTE;
  4099. rgbKeyLength: array [0..CRYPT_X942_KEY_LENGTH_BYTE_LENGTH - 1] of BYTE;
  4100. PubInfo: CRYPT_DATA_BLOB; // OPTIONAL
  4101. end;
  4102. {$EXTERNALSYM _CRYPT_X942_OTHER_INFO}
  4103. CRYPT_X942_OTHER_INFO = _CRYPT_X942_OTHER_INFO;
  4104. {$EXTERNALSYM CRYPT_X942_OTHER_INFO}
  4105. TCryptX942OtherInfo = CRYPT_X942_OTHER_INFO;
  4106. PCryptX942OtherInfo = PCRYPT_X942_OTHER_INFO;
  4107. //+-------------------------------------------------------------------------
  4108. // PKCS_RC2_CBC_PARAMETERS
  4109. // szOID_RSA_RC2CBC
  4110. //
  4111. // pvStructInfo points to following CRYPT_RC2_CBC_PARAMETERS data structure.
  4112. //--------------------------------------------------------------------------
  4113. PCRYPT_RC2_CBC_PARAMETERS = ^CRYPT_RC2_CBC_PARAMETERS;
  4114. {$EXTERNALSYM PCRYPT_RC2_CBC_PARAMETERS}
  4115. _CRYPT_RC2_CBC_PARAMETERS = record
  4116. dwVersion: DWORD;
  4117. fIV: BOOL; // set if has following IV
  4118. rgbIV: array [0..7] of BYTE;
  4119. end;
  4120. {$EXTERNALSYM _CRYPT_RC2_CBC_PARAMETERS}
  4121. CRYPT_RC2_CBC_PARAMETERS = _CRYPT_RC2_CBC_PARAMETERS;
  4122. {$EXTERNALSYM CRYPT_RC2_CBC_PARAMETERS}
  4123. TCryptRc2CbcParameters = CRYPT_RC2_CBC_PARAMETERS;
  4124. PCryptRc2CbcParameters = PCRYPT_RC2_CBC_PARAMETERS;
  4125. const
  4126. CRYPT_RC2_40BIT_VERSION = 160;
  4127. {$EXTERNALSYM CRYPT_RC2_40BIT_VERSION}
  4128. CRYPT_RC2_56BIT_VERSION = 52;
  4129. {$EXTERNALSYM CRYPT_RC2_56BIT_VERSION}
  4130. CRYPT_RC2_64BIT_VERSION = 120;
  4131. {$EXTERNALSYM CRYPT_RC2_64BIT_VERSION}
  4132. CRYPT_RC2_128BIT_VERSION = 58;
  4133. {$EXTERNALSYM CRYPT_RC2_128BIT_VERSION}
  4134. //+-------------------------------------------------------------------------
  4135. // PKCS_SMIME_CAPABILITIES
  4136. // szOID_RSA_SMIMECapabilities
  4137. //
  4138. // pvStructInfo points to following CRYPT_SMIME_CAPABILITIES data structure.
  4139. //
  4140. // Note, for CryptEncodeObject(X509_ASN_ENCODING), Parameters.cbData == 0
  4141. // causes the encoded parameters to be omitted and not encoded as a NULL
  4142. // (05 00) as is done when encoding a CRYPT_ALGORITHM_IDENTIFIER. This
  4143. // is per the SMIME specification for encoding capabilities.
  4144. //--------------------------------------------------------------------------
  4145. type
  4146. PCRYPT_SMIME_CAPABILITY = ^CRYPT_SMIME_CAPABILITY;
  4147. {$EXTERNALSYM PCRYPT_SMIME_CAPABILITY}
  4148. _CRYPT_SMIME_CAPABILITY = record
  4149. pszObjId: LPSTR;
  4150. Parameters: CRYPT_OBJID_BLOB;
  4151. end;
  4152. {$EXTERNALSYM _CRYPT_SMIME_CAPABILITY}
  4153. CRYPT_SMIME_CAPABILITY = _CRYPT_SMIME_CAPABILITY;
  4154. {$EXTERNALSYM CRYPT_SMIME_CAPABILITY}
  4155. TCryptSmimeCapability = CRYPT_SMIME_CAPABILITY;
  4156. PCryptSmimeCapability = PCRYPT_SMIME_CAPABILITY;
  4157. PCRYPT_SMIME_CAPABILITIES = ^CRYPT_SMIME_CAPABILITIES;
  4158. {$EXTERNALSYM PCRYPT_SMIME_CAPABILITIES}
  4159. _CRYPT_SMIME_CAPABILITIES = record
  4160. cCapability: DWORD;
  4161. rgCapability: PCRYPT_SMIME_CAPABILITY;
  4162. end;
  4163. {$EXTERNALSYM _CRYPT_SMIME_CAPABILITIES}
  4164. CRYPT_SMIME_CAPABILITIES = _CRYPT_SMIME_CAPABILITIES;
  4165. {$EXTERNALSYM CRYPT_SMIME_CAPABILITIES}
  4166. TCryptSmimeCapabilities = CRYPT_SMIME_CAPABILITIES;
  4167. PCryptSmimeCapabilities = PCRYPT_SMIME_CAPABILITIES;
  4168. //+-------------------------------------------------------------------------
  4169. // PKCS7_SIGNER_INFO
  4170. //
  4171. // pvStructInfo points to CMSG_SIGNER_INFO.
  4172. //--------------------------------------------------------------------------
  4173. //+-------------------------------------------------------------------------
  4174. // CMS_SIGNER_INFO
  4175. //
  4176. // pvStructInfo points to CMSG_CMS_SIGNER_INFO.
  4177. //--------------------------------------------------------------------------
  4178. //+-------------------------------------------------------------------------
  4179. // Netscape Certificate Extension Object Identifiers
  4180. //--------------------------------------------------------------------------
  4181. const
  4182. szOID_NETSCAPE = '2.16.840.1.113730';
  4183. {$EXTERNALSYM szOID_NETSCAPE}
  4184. szOID_NETSCAPE_CERT_EXTENSION = '2.16.840.1.113730.1';
  4185. {$EXTERNALSYM szOID_NETSCAPE_CERT_EXTENSION}
  4186. szOID_NETSCAPE_CERT_TYPE = '2.16.840.1.113730.1.1';
  4187. {$EXTERNALSYM szOID_NETSCAPE_CERT_TYPE}
  4188. szOID_NETSCAPE_BASE_URL = '2.16.840.1.113730.1.2';
  4189. {$EXTERNALSYM szOID_NETSCAPE_BASE_URL}
  4190. szOID_NETSCAPE_REVOCATION_URL = '2.16.840.1.113730.1.3';
  4191. {$EXTERNALSYM szOID_NETSCAPE_REVOCATION_URL}
  4192. szOID_NETSCAPE_CA_REVOCATION_URL = '2.16.840.1.113730.1.4';
  4193. {$EXTERNALSYM szOID_NETSCAPE_CA_REVOCATION_URL}
  4194. szOID_NETSCAPE_CERT_RENEWAL_URL = '2.16.840.1.113730.1.7';
  4195. {$EXTERNALSYM szOID_NETSCAPE_CERT_RENEWAL_URL}
  4196. szOID_NETSCAPE_CA_POLICY_URL = '2.16.840.1.113730.1.8';
  4197. {$EXTERNALSYM szOID_NETSCAPE_CA_POLICY_URL}
  4198. szOID_NETSCAPE_SSL_SERVER_NAME = '2.16.840.1.113730.1.12';
  4199. {$EXTERNALSYM szOID_NETSCAPE_SSL_SERVER_NAME}
  4200. szOID_NETSCAPE_COMMENT = '2.16.840.1.113730.1.13';
  4201. {$EXTERNALSYM szOID_NETSCAPE_COMMENT}
  4202. //+-------------------------------------------------------------------------
  4203. // Netscape Certificate Data Type Object Identifiers
  4204. //--------------------------------------------------------------------------
  4205. szOID_NETSCAPE_DATA_TYPE = '2.16.840.1.113730.2';
  4206. {$EXTERNALSYM szOID_NETSCAPE_DATA_TYPE}
  4207. szOID_NETSCAPE_CERT_SEQUENCE = '2.16.840.1.113730.2.5';
  4208. {$EXTERNALSYM szOID_NETSCAPE_CERT_SEQUENCE}
  4209. //+-------------------------------------------------------------------------
  4210. // szOID_NETSCAPE_CERT_TYPE extension
  4211. //
  4212. // Its value is a bit string. CryptDecodeObject/CryptEncodeObject using
  4213. // X509_BITS or X509_BITS_WITHOUT_TRAILING_ZEROES.
  4214. //
  4215. // The following bits are defined:
  4216. //--------------------------------------------------------------------------
  4217. NETSCAPE_SSL_CLIENT_AUTH_CERT_TYPE = $80;
  4218. {$EXTERNALSYM NETSCAPE_SSL_CLIENT_AUTH_CERT_TYPE}
  4219. NETSCAPE_SSL_SERVER_AUTH_CERT_TYPE = $40;
  4220. {$EXTERNALSYM NETSCAPE_SSL_SERVER_AUTH_CERT_TYPE}
  4221. NETSCAPE_SMIME_CERT_TYPE = $20;
  4222. {$EXTERNALSYM NETSCAPE_SMIME_CERT_TYPE}
  4223. NETSCAPE_SIGN_CERT_TYPE = $10;
  4224. {$EXTERNALSYM NETSCAPE_SIGN_CERT_TYPE}
  4225. NETSCAPE_SSL_CA_CERT_TYPE = $04;
  4226. {$EXTERNALSYM NETSCAPE_SSL_CA_CERT_TYPE}
  4227. NETSCAPE_SMIME_CA_CERT_TYPE = $02;
  4228. {$EXTERNALSYM NETSCAPE_SMIME_CA_CERT_TYPE}
  4229. NETSCAPE_SIGN_CA_CERT_TYPE = $01;
  4230. {$EXTERNALSYM NETSCAPE_SIGN_CA_CERT_TYPE}
  4231. //+-------------------------------------------------------------------------
  4232. // szOID_NETSCAPE_BASE_URL extension
  4233. //
  4234. // Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  4235. // X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  4236. // dwValueType = CERT_RDN_IA5_STRING.
  4237. //
  4238. // When present this string is added to the beginning of all relative URLs
  4239. // in the certificate. This extension can be considered an optimization
  4240. // to reduce the size of the URL extensions.
  4241. //--------------------------------------------------------------------------
  4242. //+-------------------------------------------------------------------------
  4243. // szOID_NETSCAPE_REVOCATION_URL extension
  4244. //
  4245. // Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  4246. // X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  4247. // dwValueType = CERT_RDN_IA5_STRING.
  4248. //
  4249. // It is a relative or absolute URL that can be used to check the
  4250. // revocation status of a certificate. The revocation check will be
  4251. // performed as an HTTP GET method using a url that is the concatenation of
  4252. // revocation-url and certificate-serial-number.
  4253. // Where the certificate-serial-number is encoded as a string of
  4254. // ascii hexadecimal digits. For example, if the netscape-base-url is
  4255. // https://www.certs-r-us.com/, the netscape-revocation-url is
  4256. // cgi-bin/check-rev.cgi?, and the certificate serial number is 173420,
  4257. // the resulting URL would be:
  4258. // https://www.certs-r-us.com/cgi-bin/check-rev.cgi?02a56c
  4259. //
  4260. // The server should return a document with a Content-Type of
  4261. // application/x-netscape-revocation. The document should contain
  4262. // a single ascii digit, '1' if the certificate is not curently valid,
  4263. // and '0' if it is curently valid.
  4264. //
  4265. // Note: for all of the URLs that include the certificate serial number,
  4266. // the serial number will be encoded as a string which consists of an even
  4267. // number of hexadecimal digits. If the number of significant digits is odd,
  4268. // the string will have a single leading zero to ensure an even number of
  4269. // digits is generated.
  4270. //--------------------------------------------------------------------------
  4271. //+-------------------------------------------------------------------------
  4272. // szOID_NETSCAPE_CA_REVOCATION_URL extension
  4273. //
  4274. // Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  4275. // X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  4276. // dwValueType = CERT_RDN_IA5_STRING.
  4277. //
  4278. // It is a relative or absolute URL that can be used to check the
  4279. // revocation status of any certificates that are signed by the CA that
  4280. // this certificate belongs to. This extension is only valid in CA
  4281. // certificates. The use of this extension is the same as the above
  4282. // szOID_NETSCAPE_REVOCATION_URL extension.
  4283. //--------------------------------------------------------------------------
  4284. //+-------------------------------------------------------------------------
  4285. // szOID_NETSCAPE_CERT_RENEWAL_URL extension
  4286. //
  4287. // Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  4288. // X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  4289. // dwValueType = CERT_RDN_IA5_STRING.
  4290. //
  4291. // It is a relative or absolute URL that points to a certificate renewal
  4292. // form. The renewal form will be accessed with an HTTP GET method using a
  4293. // url that is the concatenation of renewal-url and
  4294. // certificate-serial-number. Where the certificate-serial-number is
  4295. // encoded as a string of ascii hexadecimal digits. For example, if the
  4296. // netscape-base-url is https://www.certs-r-us.com/, the
  4297. // netscape-cert-renewal-url is cgi-bin/check-renew.cgi?, and the
  4298. // certificate serial number is 173420, the resulting URL would be:
  4299. // https://www.certs-r-us.com/cgi-bin/check-renew.cgi?02a56c
  4300. // The document returned should be an HTML form that will allow the user
  4301. // to request a renewal of their certificate.
  4302. //--------------------------------------------------------------------------
  4303. //+-------------------------------------------------------------------------
  4304. // szOID_NETSCAPE_CA_POLICY_URL extension
  4305. //
  4306. // Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  4307. // X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  4308. // dwValueType = CERT_RDN_IA5_STRING.
  4309. //
  4310. // It is a relative or absolute URL that points to a web page that
  4311. // describes the policies under which the certificate was issued.
  4312. //--------------------------------------------------------------------------
  4313. //+-------------------------------------------------------------------------
  4314. // szOID_NETSCAPE_SSL_SERVER_NAME extension
  4315. //
  4316. // Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  4317. // X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  4318. // dwValueType = CERT_RDN_IA5_STRING.
  4319. //
  4320. // It is a "shell expression" that can be used to match the hostname of the
  4321. // SSL server that is using this certificate. It is recommended that if
  4322. // the server's hostname does not match this pattern the user be notified
  4323. // and given the option to terminate the SSL connection. If this extension
  4324. // is not present then the CommonName in the certificate subject's
  4325. // distinguished name is used for the same purpose.
  4326. //--------------------------------------------------------------------------
  4327. //+-------------------------------------------------------------------------
  4328. // szOID_NETSCAPE_COMMENT extension
  4329. //
  4330. // Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  4331. // X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  4332. // dwValueType = CERT_RDN_IA5_STRING.
  4333. //
  4334. // It is a comment that may be displayed to the user when the certificate
  4335. // is viewed.
  4336. //--------------------------------------------------------------------------
  4337. //+-------------------------------------------------------------------------
  4338. // szOID_NETSCAPE_CERT_SEQUENCE
  4339. //
  4340. // Its value is a PKCS#7 ContentInfo structure wrapping a sequence of
  4341. // certificates. The value of the contentType field is
  4342. // szOID_NETSCAPE_CERT_SEQUENCE, while the content field is the following
  4343. // structure:
  4344. // CertificateSequence ::= SEQUENCE OF Certificate.
  4345. //
  4346. // CryptDecodeObject/CryptEncodeObject using
  4347. // PKCS_CONTENT_INFO_SEQUENCE_OF_ANY, where,
  4348. // pszObjId = szOID_NETSCAPE_CERT_SEQUENCE and the CRYPT_DER_BLOBs point
  4349. // to encoded X509 certificates.
  4350. //--------------------------------------------------------------------------
  4351. //+=========================================================================
  4352. // Object IDentifier (OID) Installable Functions: Data Structures and APIs
  4353. //==========================================================================
  4354. type
  4355. HCRYPTOIDFUNCSET = Pointer;
  4356. {$EXTERNALSYM HCRYPTOIDFUNCSET}
  4357. HCRYPTOIDFUNCADDR = Pointer;
  4358. {$EXTERNALSYM HCRYPTOIDFUNCADDR}
  4359. // Predefined OID Function Names
  4360. const
  4361. CRYPT_OID_ENCODE_OBJECT_FUNC = 'CryptDllEncodeObject';
  4362. {$EXTERNALSYM CRYPT_OID_ENCODE_OBJECT_FUNC}
  4363. CRYPT_OID_DECODE_OBJECT_FUNC = 'CryptDllDecodeObject';
  4364. {$EXTERNALSYM CRYPT_OID_DECODE_OBJECT_FUNC}
  4365. CRYPT_OID_ENCODE_OBJECT_EX_FUNC = 'CryptDllEncodeObjectEx';
  4366. {$EXTERNALSYM CRYPT_OID_ENCODE_OBJECT_EX_FUNC}
  4367. CRYPT_OID_DECODE_OBJECT_EX_FUNC = 'CryptDllDecodeObjectEx';
  4368. {$EXTERNALSYM CRYPT_OID_DECODE_OBJECT_EX_FUNC}
  4369. CRYPT_OID_CREATE_COM_OBJECT_FUNC = 'CryptDllCreateCOMObject';
  4370. {$EXTERNALSYM CRYPT_OID_CREATE_COM_OBJECT_FUNC}
  4371. CRYPT_OID_VERIFY_REVOCATION_FUNC = 'CertDllVerifyRevocation';
  4372. {$EXTERNALSYM CRYPT_OID_VERIFY_REVOCATION_FUNC}
  4373. CRYPT_OID_VERIFY_CTL_USAGE_FUNC = 'CertDllVerifyCTLUsage';
  4374. {$EXTERNALSYM CRYPT_OID_VERIFY_CTL_USAGE_FUNC}
  4375. CRYPT_OID_FORMAT_OBJECT_FUNC = 'CryptDllFormatObject';
  4376. {$EXTERNALSYM CRYPT_OID_FORMAT_OBJECT_FUNC}
  4377. CRYPT_OID_FIND_OID_INFO_FUNC = 'CryptDllFindOIDInfo';
  4378. {$EXTERNALSYM CRYPT_OID_FIND_OID_INFO_FUNC}
  4379. CRYPT_OID_FIND_LOCALIZED_NAME_FUNC = 'CryptDllFindLocalizedName';
  4380. {$EXTERNALSYM CRYPT_OID_FIND_LOCALIZED_NAME_FUNC}
  4381. // CryptDllEncodeObject has same function signature as CryptEncodeObject.
  4382. // CryptDllDecodeObject has same function signature as CryptDecodeObject.
  4383. // CryptDllEncodeObjectEx has same function signature as CryptEncodeObjectEx.
  4384. // The Ex version MUST support the CRYPT_ENCODE_ALLOC_FLAG option.
  4385. //
  4386. // If an Ex function isn't installed or registered, then, attempts to find
  4387. // a non-EX version. If the ALLOC flag is set, then, CryptEncodeObjectEx,
  4388. // does the allocation and calls the non-EX version twice.
  4389. // CryptDllDecodeObjectEx has same function signature as CryptDecodeObjectEx.
  4390. // The Ex version MUST support the CRYPT_DECODE_ALLOC_FLAG option.
  4391. //
  4392. // If an Ex function isn't installed or registered, then, attempts to find
  4393. // a non-EX version. If the ALLOC flag is set, then, CryptDecodeObjectEx,
  4394. // does the allocation and calls the non-EX version twice.
  4395. // CryptDllCreateCOMObject has the following signature:
  4396. // BOOL WINAPI CryptDllCreateCOMObject(
  4397. // IN DWORD dwEncodingType,
  4398. // IN LPCSTR pszOID,
  4399. // IN PCRYPT_DATA_BLOB pEncodedContent,
  4400. // IN DWORD dwFlags,
  4401. // IN REFIID riid,
  4402. // OUT void **ppvObj);
  4403. // CertDllVerifyRevocation has the same signature as CertVerifyRevocation
  4404. // (See CertVerifyRevocation for details on when called)
  4405. // CertDllVerifyCTLUsage has the same signature as CertVerifyCTLUsage
  4406. // CryptDllFindOIDInfo currently is only used to store values used by
  4407. // CryptFindOIDInfo. See CryptFindOIDInfo() for more details.
  4408. // CryptDllFindLocalizedName is only used to store localized string
  4409. // values used by CryptFindLocalizedName. See CryptFindLocalizedName() for
  4410. // more details.
  4411. // Example of a complete OID Function Registry Name:
  4412. // HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\OID
  4413. // Encoding Type 1\CryptDllEncodeObject\1.2.3
  4414. //
  4415. // The key's L"Dll" value contains the name of the Dll.
  4416. // The key's L"FuncName" value overrides the default function name
  4417. CRYPT_OID_REGPATH = 'Software\Microsoft\Cryptography\OID';
  4418. {$EXTERNALSYM CRYPT_OID_REGPATH}
  4419. CRYPT_OID_REG_ENCODING_TYPE_PREFIX = 'EncodingType ';
  4420. {$EXTERNALSYM CRYPT_OID_REG_ENCODING_TYPE_PREFIX}
  4421. CRYPT_OID_REG_DLL_VALUE_NAME = 'Dll';
  4422. {$EXTERNALSYM CRYPT_OID_REG_DLL_VALUE_NAME}
  4423. CRYPT_OID_REG_FUNC_NAME_VALUE_NAME = 'FuncName';
  4424. {$EXTERNALSYM CRYPT_OID_REG_FUNC_NAME_VALUE_NAME}
  4425. CRYPT_OID_REG_FUNC_NAME_VALUE_NAME_A = 'FuncName';
  4426. {$EXTERNALSYM CRYPT_OID_REG_FUNC_NAME_VALUE_NAME_A}
  4427. // CRYPT_INSTALL_OID_FUNC_BEFORE_FLAG can be set in the key's L"CryptFlags"
  4428. // value to register the functions before the installed functions.
  4429. //
  4430. // CryptSetOIDFunctionValue must be called to set this value. L"CryptFlags"
  4431. // must be set using a dwValueType of REG_DWORD.
  4432. CRYPT_OID_REG_FLAGS_VALUE_NAME = 'CryptFlags';
  4433. {$EXTERNALSYM CRYPT_OID_REG_FLAGS_VALUE_NAME}
  4434. // OID used for Default OID functions
  4435. CRYPT_DEFAULT_OID = 'DEFAULT';
  4436. {$EXTERNALSYM CRYPT_DEFAULT_OID}
  4437. type
  4438. PCRYPT_OID_FUNC_ENTRY = ^CRYPT_OID_FUNC_ENTRY;
  4439. {$EXTERNALSYM PCRYPT_OID_FUNC_ENTRY}
  4440. _CRYPT_OID_FUNC_ENTRY = record
  4441. pszOID: LPCSTR;
  4442. pvFuncAddr: Pointer;
  4443. end;
  4444. {$EXTERNALSYM _CRYPT_OID_FUNC_ENTRY}
  4445. CRYPT_OID_FUNC_ENTRY = _CRYPT_OID_FUNC_ENTRY;
  4446. {$EXTERNALSYM CRYPT_OID_FUNC_ENTRY}
  4447. TCryptOidFuncEntry = CRYPT_OID_FUNC_ENTRY;
  4448. PCryptOidFuncEntry = PCRYPT_OID_FUNC_ENTRY;
  4449. const
  4450. CRYPT_INSTALL_OID_FUNC_BEFORE_FLAG = 1;
  4451. {$EXTERNALSYM CRYPT_INSTALL_OID_FUNC_BEFORE_FLAG}
  4452. //+-------------------------------------------------------------------------
  4453. // Install a set of callable OID function addresses.
  4454. //
  4455. // By default the functions are installed at end of the list.
  4456. // Set CRYPT_INSTALL_OID_FUNC_BEFORE_FLAG to install at beginning of list.
  4457. //
  4458. // hModule should be updated with the hModule passed to DllMain to prevent
  4459. // the Dll containing the function addresses from being unloaded by
  4460. // CryptGetOIDFuncAddress/CryptFreeOIDFunctionAddress. This would be the
  4461. // case when the Dll has also regsvr32'ed OID functions via
  4462. // CryptRegisterOIDFunction.
  4463. //
  4464. // DEFAULT functions are installed by setting rgFuncEntry[].pszOID =
  4465. // CRYPT_DEFAULT_OID.
  4466. //--------------------------------------------------------------------------
  4467. function CryptInstallOIDFunctionAddress(hModule: HMODULE; dwEncodingType: DWORD;
  4468. pszFuncName: LPCSTR; cFuncEntry: DWORD; rgFuncEntry: PCRYPT_OID_FUNC_ENTRY;
  4469. dwFlags: DWORD): BOOL; stdcall;
  4470. {$EXTERNALSYM CryptInstallOIDFunctionAddress}
  4471. //+-------------------------------------------------------------------------
  4472. // Initialize and return handle to the OID function set identified by its
  4473. // function name.
  4474. //
  4475. // If the set already exists, a handle to the existing set is returned.
  4476. //--------------------------------------------------------------------------
  4477. function CryptInitOIDFunctionSet(pszFuncName: LPCSTR; dwFlags: DWORD): HCRYPTOIDFUNCSET; stdcall;
  4478. {$EXTERNALSYM CryptInitOIDFunctionSet}
  4479. //+-------------------------------------------------------------------------
  4480. // Search the list of installed functions for an encoding type and OID match.
  4481. // If not found, search the registry.
  4482. //
  4483. // For success, returns TRUE with *ppvFuncAddr updated with the function's
  4484. // address and *phFuncAddr updated with the function address's handle.
  4485. // The function's handle is AddRef'ed. CryptFreeOIDFunctionAddress needs to
  4486. // be called to release it.
  4487. //
  4488. // For a registry match, the Dll containing the function is loaded.
  4489. //
  4490. // By default, both the registered and installed function lists are searched.
  4491. // Set CRYPT_GET_INSTALLED_OID_FUNC_FLAG to only search the installed list
  4492. // of functions. This flag would be set by a registered function to get
  4493. // the address of a pre-installed function it was replacing. For example,
  4494. // the registered function might handle a new special case and call the
  4495. // pre-installed function to handle the remaining cases.
  4496. //--------------------------------------------------------------------------
  4497. function CryptGetOIDFunctionAddress(hFuncSet: HCRYPTOIDFUNCSET;
  4498. dwEncodingType: DWORD; pszOID: LPCSTR; dwFlags: DWORD;
  4499. var ppvFuncAddr: Pointer; var phFuncAddr: HCRYPTOIDFUNCADDR): BOOL; stdcall;
  4500. {$EXTERNALSYM CryptGetOIDFunctionAddress}
  4501. const
  4502. CRYPT_GET_INSTALLED_OID_FUNC_FLAG = $1;
  4503. {$EXTERNALSYM CRYPT_GET_INSTALLED_OID_FUNC_FLAG}
  4504. //+-------------------------------------------------------------------------
  4505. // Get the list of registered default Dll entries for the specified
  4506. // function set and encoding type.
  4507. //
  4508. // The returned list consists of none, one or more null terminated Dll file
  4509. // names. The list is terminated with an empty (L"\0") Dll file name.
  4510. // For example: L"first.dll" L"\0" L"second.dll" L"\0" L"\0"
  4511. //--------------------------------------------------------------------------
  4512. function CryptGetDefaultOIDDllList(hFuncSet: HCRYPTOIDFUNCSET; dwEncodingType: DWORD;
  4513. pwszDllList: LPWSTR; pcchDllList: DWORD): BOOL; stdcall;
  4514. {$EXTERNALSYM CryptGetDefaultOIDDllList}
  4515. //+-------------------------------------------------------------------------
  4516. // Either: get the first or next installed DEFAULT function OR
  4517. // load the Dll containing the DEFAULT function.
  4518. //
  4519. // If pwszDll is NULL, search the list of installed DEFAULT functions.
  4520. // *phFuncAddr must be set to NULL to get the first installed function.
  4521. // Successive installed functions are returned by setting *phFuncAddr
  4522. // to the hFuncAddr returned by the previous call.
  4523. //
  4524. // If pwszDll is NULL, the input *phFuncAddr
  4525. // is always CryptFreeOIDFunctionAddress'ed by this function, even for
  4526. // an error.
  4527. //
  4528. // If pwszDll isn't NULL, then, attempts to load the Dll and the DEFAULT
  4529. // function. *phFuncAddr is ignored upon entry and isn't
  4530. // CryptFreeOIDFunctionAddress'ed.
  4531. //
  4532. // For success, returns TRUE with *ppvFuncAddr updated with the function's
  4533. // address and *phFuncAddr updated with the function address's handle.
  4534. // The function's handle is AddRef'ed. CryptFreeOIDFunctionAddress needs to
  4535. // be called to release it or CryptGetDefaultOIDFunctionAddress can also
  4536. // be called for a NULL pwszDll.
  4537. //--------------------------------------------------------------------------
  4538. function CryptGetDefaultOIDFunctionAddress(hFuncSet: HCRYPTOIDFUNCSET;
  4539. dwEncodingType: DWORD; pwszDll: LPCWSTR; dwFlags: DWORD;
  4540. var ppvFuncAddr: Pointer; phFuncAddr: HCRYPTOIDFUNCADDR): BOOL; stdcall;
  4541. {$EXTERNALSYM CryptGetDefaultOIDFunctionAddress}
  4542. //+-------------------------------------------------------------------------
  4543. // Releases the handle AddRef'ed and returned by CryptGetOIDFunctionAddress
  4544. // or CryptGetDefaultOIDFunctionAddress.
  4545. //
  4546. // If a Dll was loaded for the function its unloaded. However, before doing
  4547. // the unload, the DllCanUnloadNow function exported by the loaded Dll is
  4548. // called. It should return S_FALSE to inhibit the unload or S_TRUE to enable
  4549. // the unload. If the Dll doesn't export DllCanUnloadNow, the Dll is unloaded.
  4550. //
  4551. // DllCanUnloadNow has the following signature:
  4552. // STDAPI DllCanUnloadNow(void);
  4553. //--------------------------------------------------------------------------
  4554. function CryptFreeOIDFunctionAddress(hFuncAddr: HCRYPTOIDFUNCADDR; dwFlags: DWORD): BOOL; stdcall;
  4555. {$EXTERNALSYM CryptFreeOIDFunctionAddress}
  4556. //+-------------------------------------------------------------------------
  4557. // Register the Dll containing the function to be called for the specified
  4558. // encoding type, function name and OID.
  4559. //
  4560. // pwszDll may contain environment-variable strings
  4561. // which are ExpandEnvironmentStrings()'ed before loading the Dll.
  4562. //
  4563. // In addition to registering the DLL, you may override the
  4564. // name of the function to be called. For example,
  4565. // pszFuncName = "CryptDllEncodeObject",
  4566. // pszOverrideFuncName = "MyEncodeXyz".
  4567. // This allows a Dll to export multiple OID functions for the same
  4568. // function name without needing to interpose its own OID dispatcher function.
  4569. //--------------------------------------------------------------------------
  4570. function CryptRegisterOIDFunction(dwEncodingType: DWORD; pszFuncName: LPCSTR;
  4571. pszOID: LPCSTR; pwszDll: LPCWSTR; pszOverrideFuncName: LPCSTR): BOOL; stdcall;
  4572. {$EXTERNALSYM CryptRegisterOIDFunction}
  4573. //+-------------------------------------------------------------------------
  4574. // Unregister the Dll containing the function to be called for the specified
  4575. // encoding type, function name and OID.
  4576. //--------------------------------------------------------------------------
  4577. function CryptUnregisterOIDFunction(dwEncodingType: DWORD; pszFuncName: LPCSTR;
  4578. pszOID: LPCSTR): BOOL; stdcall;
  4579. {$EXTERNALSYM CryptUnregisterOIDFunction}
  4580. //+-------------------------------------------------------------------------
  4581. // Register the Dll containing the default function to be called for the
  4582. // specified encoding type and function name.
  4583. //
  4584. // Unlike CryptRegisterOIDFunction, you can't override the function name
  4585. // needing to be exported by the Dll.
  4586. //
  4587. // The Dll is inserted before the entry specified by dwIndex.
  4588. // dwIndex == 0, inserts at the beginning.
  4589. // dwIndex == CRYPT_REGISTER_LAST_INDEX, appends at the end.
  4590. //
  4591. // pwszDll may contain environment-variable strings
  4592. // which are ExpandEnvironmentStrings()'ed before loading the Dll.
  4593. //--------------------------------------------------------------------------
  4594. function CryptRegisterDefaultOIDFunction(dwEncodingType: DWORD; pszFuncName: LPCSTR;
  4595. dwIndex: DWORD; pwszDll: LPCWSTR): BOOL; stdcall;
  4596. {$EXTERNALSYM CryptRegisterDefaultOIDFunction}
  4597. const
  4598. CRYPT_REGISTER_FIRST_INDEX = 0;
  4599. {$EXTERNALSYM CRYPT_REGISTER_FIRST_INDEX}
  4600. CRYPT_REGISTER_LAST_INDEX = DWORD($FFFFFFFF);
  4601. {$EXTERNALSYM CRYPT_REGISTER_LAST_INDEX}
  4602. //+-------------------------------------------------------------------------
  4603. // Unregister the Dll containing the default function to be called for
  4604. // the specified encoding type and function name.
  4605. //--------------------------------------------------------------------------
  4606. function CryptUnregisterDefaultOIDFunction(dwEncodingType: DWORD;
  4607. pszFuncName: LPCSTR; pwszDll: LPCWSTR): BOOL; stdcall;
  4608. {$EXTERNALSYM CryptUnregisterDefaultOIDFunction}
  4609. //+-------------------------------------------------------------------------
  4610. // Set the value for the specified encoding type, function name, OID and
  4611. // value name.
  4612. //
  4613. // See RegSetValueEx for the possible value types.
  4614. //
  4615. // String types are UNICODE.
  4616. //--------------------------------------------------------------------------
  4617. function CryptSetOIDFunctionValue(dwEncodingType: DWORD; pszFuncName: LPCSTR;
  4618. pszOID: LPCSTR; pwszValueName: LPCWSTR; dwValueType: DWORD; pbValueData: LPBYTE;
  4619. cbValueData: DWORD): BOOL; stdcall;
  4620. {$EXTERNALSYM CryptSetOIDFunctionValue}
  4621. //+-------------------------------------------------------------------------
  4622. // Get the value for the specified encoding type, function name, OID and
  4623. // value name.
  4624. //
  4625. // See RegEnumValue for the possible value types.
  4626. //
  4627. // String types are UNICODE.
  4628. //--------------------------------------------------------------------------
  4629. function CryptGetOIDFunctionValue(dwEncodingType: DWORD; pszFuncName: LPCSTR;
  4630. pszOID: LPCSTR; pwszValueName: LPCWSTR; var pdwValueType: DWORD;
  4631. pbValueData: LPBYTE; var pcbValueData: DWORD): BOOL; stdcall;
  4632. {$EXTERNALSYM CryptGetOIDFunctionValue}
  4633. type
  4634. PFN_CRYPT_ENUM_OID_FUNC = function(dwEncodingType: DWORD; pszFuncName,
  4635. pszOID: LPCSTR; cValue: DWORD; rgdwValueType: LPDWORD;
  4636. rgpwszValueName: LPCWSTR; rgpbValueData: LPBYTE; rgcbValueData: LPDWORD;
  4637. pvArg: Pointer): BOOL; stdcall;
  4638. {$EXTERNALSYM PFN_CRYPT_ENUM_OID_FUNC}
  4639. PFnCryptEnumOidFunc = PFN_CRYPT_ENUM_OID_FUNC;
  4640. //+-------------------------------------------------------------------------
  4641. // Enumerate the OID functions identified by their encoding type,
  4642. // function name and OID.
  4643. //
  4644. // pfnEnumOIDFunc is called for each registry key matching the input
  4645. // parameters. Setting dwEncodingType to CRYPT_MATCH_ANY_ENCODING_TYPE matches
  4646. // any. Setting pszFuncName or pszOID to NULL matches any.
  4647. //
  4648. // Set pszOID == CRYPT_DEFAULT_OID to restrict the enumeration to only the
  4649. // DEFAULT functions
  4650. //
  4651. // String types are UNICODE.
  4652. //--------------------------------------------------------------------------
  4653. function CryptEnumOIDFunction(dwEncodingType: DWORD; pszFuncName, pszOID: LPCSTR;
  4654. dwFlags: DWORD; pvArg: Pointer; pfnEnumOIDFunc: PFN_CRYPT_ENUM_OID_FUNC): BOOL; stdcall;
  4655. {$EXTERNALSYM CryptEnumOIDFunction}
  4656. const
  4657. CRYPT_MATCH_ANY_ENCODING_TYPE = DWORD($FFFFFFFF);
  4658. {$EXTERNALSYM CRYPT_MATCH_ANY_ENCODING_TYPE}
  4659. //+=========================================================================
  4660. // Object IDentifier (OID) Information: Data Structures and APIs
  4661. //==========================================================================
  4662. //+-------------------------------------------------------------------------
  4663. // OID Information
  4664. //--------------------------------------------------------------------------
  4665. type
  4666. PCRYPT_OID_INFO = ^CRYPT_OID_INFO;
  4667. {$EXTERNALSYM PCRYPT_OID_INFO}
  4668. _CRYPT_OID_INFO = record
  4669. cbSize: DWORD;
  4670. pszOID: LPCSTR;
  4671. pwszName: LPCWSTR;
  4672. dwGroupId: DWORD;
  4673. Union: record
  4674. case Integer of
  4675. 0: (dwValue: DWORD);
  4676. 1: (Algid: ALG_ID);
  4677. 2: (dwLength: DWORD);
  4678. end;
  4679. ExtraInfo: CRYPT_DATA_BLOB;
  4680. end;
  4681. {$EXTERNALSYM _CRYPT_OID_INFO}
  4682. CRYPT_OID_INFO = _CRYPT_OID_INFO;
  4683. {$EXTERNALSYM CRYPT_OID_INFO}
  4684. TCryptOidInfo = CRYPT_OID_INFO;
  4685. PCryptOidInfo = PCRYPT_OID_INFO;
  4686. CCRYPT_OID_INFO = CRYPT_OID_INFO;
  4687. {$EXTERNALSYM CCRYPT_OID_INFO}
  4688. PCCRYPT_OID_INFO = PCRYPT_OID_INFO;
  4689. {$EXTERNALSYM PCCRYPT_OID_INFO}
  4690. //+-------------------------------------------------------------------------
  4691. // OID Group IDs
  4692. //--------------------------------------------------------------------------
  4693. const
  4694. CRYPT_HASH_ALG_OID_GROUP_ID = 1;
  4695. {$EXTERNALSYM CRYPT_HASH_ALG_OID_GROUP_ID}
  4696. CRYPT_ENCRYPT_ALG_OID_GROUP_ID = 2;
  4697. {$EXTERNALSYM CRYPT_ENCRYPT_ALG_OID_GROUP_ID}
  4698. CRYPT_PUBKEY_ALG_OID_GROUP_ID = 3;
  4699. {$EXTERNALSYM CRYPT_PUBKEY_ALG_OID_GROUP_ID}
  4700. CRYPT_SIGN_ALG_OID_GROUP_ID = 4;
  4701. {$EXTERNALSYM CRYPT_SIGN_ALG_OID_GROUP_ID}
  4702. CRYPT_RDN_ATTR_OID_GROUP_ID = 5;
  4703. {$EXTERNALSYM CRYPT_RDN_ATTR_OID_GROUP_ID}
  4704. CRYPT_EXT_OR_ATTR_OID_GROUP_ID = 6;
  4705. {$EXTERNALSYM CRYPT_EXT_OR_ATTR_OID_GROUP_ID}
  4706. CRYPT_ENHKEY_USAGE_OID_GROUP_ID = 7;
  4707. {$EXTERNALSYM CRYPT_ENHKEY_USAGE_OID_GROUP_ID}
  4708. CRYPT_POLICY_OID_GROUP_ID = 8;
  4709. {$EXTERNALSYM CRYPT_POLICY_OID_GROUP_ID}
  4710. CRYPT_LAST_OID_GROUP_ID = 8;
  4711. {$EXTERNALSYM CRYPT_LAST_OID_GROUP_ID}
  4712. CRYPT_FIRST_ALG_OID_GROUP_ID = CRYPT_HASH_ALG_OID_GROUP_ID;
  4713. {$EXTERNALSYM CRYPT_FIRST_ALG_OID_GROUP_ID}
  4714. CRYPT_LAST_ALG_OID_GROUP_ID = CRYPT_SIGN_ALG_OID_GROUP_ID;
  4715. {$EXTERNALSYM CRYPT_LAST_ALG_OID_GROUP_ID}
  4716. // The CRYPT_*_ALG_OID_GROUP_ID's have an Algid. The CRYPT_RDN_ATTR_OID_GROUP_ID
  4717. // has a dwLength. The CRYPT_EXT_OR_ATTR_OID_GROUP_ID,
  4718. // CRYPT_ENHKEY_USAGE_OID_GROUP_ID or CRYPT_POLICY_OID_GROUP_ID don't have a
  4719. // dwValue.
  4720. //
  4721. // CRYPT_PUBKEY_ALG_OID_GROUP_ID has the following optional ExtraInfo:
  4722. // DWORD[0] - Flags. CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG can be set to
  4723. // inhibit the reformatting of the signature before
  4724. // CryptVerifySignature is called or after CryptSignHash
  4725. // is called. CRYPT_OID_USE_PUBKEY_PARA_FOR_PKCS7_FLAG can
  4726. // be set to include the public key algorithm's parameters
  4727. // in the PKCS7's digestEncryptionAlgorithm's parameters.
  4728. // CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG can be set to omit
  4729. // NULL parameters when encoding.
  4730. CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG = $1;
  4731. {$EXTERNALSYM CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG}
  4732. CRYPT_OID_USE_PUBKEY_PARA_FOR_PKCS7_FLAG = $2;
  4733. {$EXTERNALSYM CRYPT_OID_USE_PUBKEY_PARA_FOR_PKCS7_FLAG}
  4734. CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG = $4;
  4735. {$EXTERNALSYM CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG}
  4736. // CRYPT_SIGN_ALG_OID_GROUP_ID has the following optional ExtraInfo:
  4737. // DWORD[0] - Public Key Algid.
  4738. // DWORD[1] - Flags. Same as above for CRYPT_PUBKEY_ALG_OID_GROUP_ID.
  4739. // DWORD[2] - Optional CryptAcquireContext(CRYPT_VERIFYCONTEXT)'s dwProvType.
  4740. // If omitted or 0, uses Public Key Algid to select
  4741. // appropriate dwProvType for signature verification.
  4742. // CRYPT_RDN_ATTR_OID_GROUP_ID has the following optional ExtraInfo:
  4743. // Array of DWORDs:
  4744. // [0 ..] - Null terminated list of acceptable RDN attribute
  4745. // value types. An empty list implies CERT_RDN_PRINTABLE_STRING,
  4746. // CERT_RDN_UNICODE_STRING, 0.
  4747. //+-------------------------------------------------------------------------
  4748. // Find OID information. Returns NULL if unable to find any information
  4749. // for the specified key and group. Note, returns a pointer to a constant
  4750. // data structure. The returned pointer MUST NOT be freed.
  4751. //
  4752. // dwKeyType's:
  4753. // CRYPT_OID_INFO_OID_KEY, pvKey points to a szOID
  4754. // CRYPT_OID_INFO_NAME_KEY, pvKey points to a wszName
  4755. // CRYPT_OID_INFO_ALGID_KEY, pvKey points to an ALG_ID
  4756. // CRYPT_OID_INFO_SIGN_KEY, pvKey points to an array of two ALG_ID's:
  4757. // ALG_ID[0] - Hash Algid
  4758. // ALG_ID[1] - PubKey Algid
  4759. //
  4760. // Setting dwGroupId to 0, searches all groups according to the dwKeyType.
  4761. // Otherwise, only the dwGroupId is searched.
  4762. //--------------------------------------------------------------------------
  4763. function CryptFindOIDInfo(dwKeyType: DWORD; pvKey: Pointer; dwGroupId: DWORD): PCCRYPT_OID_INFO; stdcall;
  4764. {$EXTERNALSYM CryptFindOIDInfo}
  4765. const
  4766. CRYPT_OID_INFO_OID_KEY = 1;
  4767. {$EXTERNALSYM CRYPT_OID_INFO_OID_KEY}
  4768. CRYPT_OID_INFO_NAME_KEY = 2;
  4769. {$EXTERNALSYM CRYPT_OID_INFO_NAME_KEY}
  4770. CRYPT_OID_INFO_ALGID_KEY = 3;
  4771. {$EXTERNALSYM CRYPT_OID_INFO_ALGID_KEY}
  4772. CRYPT_OID_INFO_SIGN_KEY = 4;
  4773. {$EXTERNALSYM CRYPT_OID_INFO_SIGN_KEY}
  4774. //+-------------------------------------------------------------------------
  4775. // Register OID information. The OID information specified in the
  4776. // CCRYPT_OID_INFO structure is persisted to the registry.
  4777. //
  4778. // crypt32.dll contains information for the commonly known OIDs. This function
  4779. // allows applications to augment crypt32.dll's OID information. During
  4780. // CryptFindOIDInfo's first call, the registered OID information is installed.
  4781. //
  4782. // By default the registered OID information is installed after crypt32.dll's
  4783. // OID entries. Set CRYPT_INSTALL_OID_INFO_BEFORE_FLAG to install before.
  4784. //--------------------------------------------------------------------------
  4785. function CryptRegisterOIDInfo(pInfo: PCCRYPT_OID_INFO; dwFlags: DWORD): BOOL; stdcall;
  4786. {$EXTERNALSYM CryptRegisterOIDInfo}
  4787. const
  4788. CRYPT_INSTALL_OID_INFO_BEFORE_FLAG = 1;
  4789. {$EXTERNALSYM CRYPT_INSTALL_OID_INFO_BEFORE_FLAG}
  4790. //+-------------------------------------------------------------------------
  4791. // Unregister OID information. Only the pszOID and dwGroupId fields are
  4792. // used to identify the OID information to be unregistered.
  4793. //--------------------------------------------------------------------------
  4794. function CryptUnregisterOIDInfo(pInfo: PCCRYPT_OID_INFO): BOOL; stdcall;
  4795. {$EXTERNALSYM CryptUnregisterOIDInfo}
  4796. // If the callback returns FALSE, stops the enumeration.
  4797. type
  4798. PFN_CRYPT_ENUM_OID_INFO = function(pInfo: PCCRYPT_OID_INFO; pvArg: Pointer): BOOL; stdcall;
  4799. {$EXTERNALSYM PFN_CRYPT_ENUM_OID_INFO}
  4800. PFnCryptEnumOidInfo = PFN_CRYPT_ENUM_OID_INFO;
  4801. //+-------------------------------------------------------------------------
  4802. // Enumerate the OID information.
  4803. //
  4804. // pfnEnumOIDInfo is called for each OID information entry.
  4805. //
  4806. // Setting dwGroupId to 0 matches all groups. Otherwise, only enumerates
  4807. // entries in the specified group.
  4808. //
  4809. // dwFlags currently isn't used and must be set to 0.
  4810. //--------------------------------------------------------------------------
  4811. function CryptEnumOIDInfo(dwGroupId: DWORD; dwFlags: DWORD; pvArg: Pointer;
  4812. pfnEnumOIDInfo: PFN_CRYPT_ENUM_OID_INFO): BOOL; stdcall;
  4813. {$EXTERNALSYM CryptEnumOIDInfo}
  4814. //+-------------------------------------------------------------------------
  4815. // Find the localized name for the specified name. For example, find the
  4816. // localized name for the "Root" system store name. A case insensitive
  4817. // string comparison is done.
  4818. //
  4819. // Returns NULL if unable to find the the specified name.
  4820. //
  4821. // Localized names for the predefined system stores ("Root", "My") and
  4822. // predefined physical stores (".Default", ".LocalMachine") are pre-installed
  4823. // as resource strings in crypt32.dll. CryptSetOIDFunctionValue can be called
  4824. // as follows to register additional localized strings:
  4825. // dwEncodingType = CRYPT_LOCALIZED_NAME_ENCODING_TYPE
  4826. // pszFuncName = CRYPT_OID_FIND_LOCALIZED_NAME_FUNC
  4827. // pszOID = CRYPT_LOCALIZED_NAME_OID
  4828. // pwszValueName = Name to be localized, for example, L"ApplicationStore"
  4829. // dwValueType = REG_SZ
  4830. // pbValueData = pointer to the UNICODE localized string
  4831. // cbValueData = (wcslen(UNICODE localized string) + 1) * sizeof(WCHAR)
  4832. //
  4833. // To unregister, set pbValueData to NULL and cbValueData to 0.
  4834. //
  4835. // The registered names are searched before the pre-installed names.
  4836. //--------------------------------------------------------------------------
  4837. function CryptFindLocalizedName(pwszCryptName: LPCWSTR): LPCWSTR; stdcall;
  4838. {$EXTERNALSYM CryptFindLocalizedName}
  4839. const
  4840. CRYPT_LOCALIZED_NAME_ENCODING_TYPE = 0;
  4841. {$EXTERNALSYM CRYPT_LOCALIZED_NAME_ENCODING_TYPE}
  4842. CRYPT_LOCALIZED_NAME_OID = 'LocalizedNames';
  4843. {$EXTERNALSYM CRYPT_LOCALIZED_NAME_OID}
  4844. //+=========================================================================
  4845. // Low Level Cryptographic Message Data Structures and APIs
  4846. //==========================================================================
  4847. type
  4848. HCRYPTMSG = Pointer;
  4849. {$EXTERNALSYM HCRYPTMSG}
  4850. PHCRYPTMSG = ^HCRYPTMSG;
  4851. {$NODEFINE PHCRYPTMSG}
  4852. const
  4853. szOID_PKCS_7_DATA = '1.2.840.113549.1.7.1';
  4854. {$EXTERNALSYM szOID_PKCS_7_DATA}
  4855. szOID_PKCS_7_SIGNED = '1.2.840.113549.1.7.2';
  4856. {$EXTERNALSYM szOID_PKCS_7_SIGNED}
  4857. szOID_PKCS_7_ENVELOPED = '1.2.840.113549.1.7.3';
  4858. {$EXTERNALSYM szOID_PKCS_7_ENVELOPED}
  4859. szOID_PKCS_7_SIGNEDANDENVELOPED = '1.2.840.113549.1.7.4';
  4860. {$EXTERNALSYM szOID_PKCS_7_SIGNEDANDENVELOPED}
  4861. szOID_PKCS_7_DIGESTED = '1.2.840.113549.1.7.5';
  4862. {$EXTERNALSYM szOID_PKCS_7_DIGESTED}
  4863. szOID_PKCS_7_ENCRYPTED = '1.2.840.113549.1.7.6';
  4864. {$EXTERNALSYM szOID_PKCS_7_ENCRYPTED}
  4865. szOID_PKCS_9_CONTENT_TYPE = '1.2.840.113549.1.9.3';
  4866. {$EXTERNALSYM szOID_PKCS_9_CONTENT_TYPE}
  4867. szOID_PKCS_9_MESSAGE_DIGEST = '1.2.840.113549.1.9.4';
  4868. {$EXTERNALSYM szOID_PKCS_9_MESSAGE_DIGEST}
  4869. //+-------------------------------------------------------------------------
  4870. // Message types
  4871. //--------------------------------------------------------------------------
  4872. CMSG_DATA = 1;
  4873. {$EXTERNALSYM CMSG_DATA}
  4874. CMSG_SIGNED = 2;
  4875. {$EXTERNALSYM CMSG_SIGNED}
  4876. CMSG_ENVELOPED = 3;
  4877. {$EXTERNALSYM CMSG_ENVELOPED}
  4878. CMSG_SIGNED_AND_ENVELOPED = 4;
  4879. {$EXTERNALSYM CMSG_SIGNED_AND_ENVELOPED}
  4880. CMSG_HASHED = 5;
  4881. {$EXTERNALSYM CMSG_HASHED}
  4882. CMSG_ENCRYPTED = 6;
  4883. {$EXTERNALSYM CMSG_ENCRYPTED}
  4884. //+-------------------------------------------------------------------------
  4885. // Message Type Bit Flags
  4886. //--------------------------------------------------------------------------
  4887. CMSG_ALL_FLAGS = not 0;
  4888. {$EXTERNALSYM CMSG_ALL_FLAGS}
  4889. CMSG_DATA_FLAG = 1 shl CMSG_DATA;
  4890. {$EXTERNALSYM CMSG_DATA_FLAG}
  4891. CMSG_SIGNED_FLAG = 1 shl CMSG_SIGNED;
  4892. {$EXTERNALSYM CMSG_SIGNED_FLAG}
  4893. CMSG_ENVELOPED_FLAG = 1 shl CMSG_ENVELOPED;
  4894. {$EXTERNALSYM CMSG_ENVELOPED_FLAG}
  4895. CMSG_SIGNED_AND_ENVELOPED_FLAG = 1 shl CMSG_SIGNED_AND_ENVELOPED;
  4896. {$EXTERNALSYM CMSG_SIGNED_AND_ENVELOPED_FLAG}
  4897. CMSG_HASHED_FLAG = 1 shl CMSG_HASHED;
  4898. {$EXTERNALSYM CMSG_HASHED_FLAG}
  4899. CMSG_ENCRYPTED_FLAG = 1 shl CMSG_ENCRYPTED;
  4900. {$EXTERNALSYM CMSG_ENCRYPTED_FLAG}
  4901. //+-------------------------------------------------------------------------
  4902. // Certificate Issuer and SerialNumber
  4903. //--------------------------------------------------------------------------
  4904. type
  4905. PCERT_ISSUER_SERIAL_NUMBER = ^CERT_ISSUER_SERIAL_NUMBER;
  4906. {$EXTERNALSYM PCERT_ISSUER_SERIAL_NUMBER}
  4907. _CERT_ISSUER_SERIAL_NUMBER = record
  4908. Issuer: CERT_NAME_BLOB;
  4909. SerialNumber: CRYPT_INTEGER_BLOB;
  4910. end;
  4911. {$EXTERNALSYM _CERT_ISSUER_SERIAL_NUMBER}
  4912. CERT_ISSUER_SERIAL_NUMBER = _CERT_ISSUER_SERIAL_NUMBER;
  4913. {$EXTERNALSYM CERT_ISSUER_SERIAL_NUMBER}
  4914. TCertIssuerSerialNumber = CERT_ISSUER_SERIAL_NUMBER;
  4915. PCertIssuerSerialNumber = PCERT_ISSUER_SERIAL_NUMBER;
  4916. //+-------------------------------------------------------------------------
  4917. // Certificate Identifier
  4918. //--------------------------------------------------------------------------
  4919. PCERT_ID = ^CERT_ID;
  4920. {$EXTERNALSYM PCERT_ID}
  4921. _CERT_ID = record
  4922. dwIdChoice: DWORD;
  4923. case Integer of
  4924. // CERT_ID_ISSUER_SERIAL_NUMBER
  4925. 0: (IssuerSerialNumber: CERT_ISSUER_SERIAL_NUMBER);
  4926. // CERT_ID_KEY_IDENTIFIER
  4927. 1: (KeyId: CRYPT_HASH_BLOB);
  4928. // CERT_ID_SHA1_HASH
  4929. 2: (HashId: CRYPT_HASH_BLOB);
  4930. end;
  4931. {$EXTERNALSYM _CERT_ID}
  4932. CERT_ID = _CERT_ID;
  4933. {$EXTERNALSYM CERT_ID}
  4934. TCertId = CERT_ID;
  4935. PCertId = PCERT_ID;
  4936. const
  4937. CERT_ID_ISSUER_SERIAL_NUMBER = 1;
  4938. {$EXTERNALSYM CERT_ID_ISSUER_SERIAL_NUMBER}
  4939. CERT_ID_KEY_IDENTIFIER = 2;
  4940. {$EXTERNALSYM CERT_ID_KEY_IDENTIFIER}
  4941. CERT_ID_SHA1_HASH = 3;
  4942. {$EXTERNALSYM CERT_ID_SHA1_HASH}
  4943. //+-------------------------------------------------------------------------
  4944. // The message encode information (pvMsgEncodeInfo) is message type dependent
  4945. //--------------------------------------------------------------------------
  4946. //+-------------------------------------------------------------------------
  4947. // CMSG_DATA: pvMsgEncodeInfo = NULL
  4948. //--------------------------------------------------------------------------
  4949. //+-------------------------------------------------------------------------
  4950. // CMSG_SIGNED
  4951. //
  4952. // The pCertInfo in the CMSG_SIGNER_ENCODE_INFO provides the Issuer, SerialNumber
  4953. // and PublicKeyInfo.Algorithm. The PublicKeyInfo.Algorithm implicitly
  4954. // specifies the HashEncryptionAlgorithm to be used.
  4955. //
  4956. // If the SignerId is present with a nonzero dwIdChoice its used instead
  4957. // of the Issuer and SerialNumber in pCertInfo.
  4958. //
  4959. // CMS supports the KEY_IDENTIFIER and ISSUER_SERIAL_NUMBER CERT_IDs. PKCS #7
  4960. // version 1.5 only supports the ISSUER_SERIAL_NUMBER CERT_ID choice.
  4961. //
  4962. // If HashEncryptionAlgorithm is present and not NULL its used instead of
  4963. // the PublicKeyInfo.Algorithm.
  4964. //
  4965. // Note, for RSA, the hash encryption algorithm is normally the same as
  4966. // the public key algorithm. For DSA, the hash encryption algorithm is
  4967. // normally a DSS signature algorithm.
  4968. //
  4969. // pvHashEncryptionAuxInfo currently isn't used and must be set to NULL if
  4970. // present in the data structure.
  4971. //
  4972. // The hCryptProv and dwKeySpec specify the private key to use. If dwKeySpec
  4973. // == 0, then, defaults to AT_SIGNATURE.
  4974. //
  4975. // If CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags
  4976. // passed to CryptMsgOpenToEncode(), the signer hCryptProv's are released.
  4977. //
  4978. // pvHashAuxInfo currently isn't used and must be set to NULL.
  4979. //
  4980. // CMS signed messages allow the inclusion of Attribute Certs.
  4981. //--------------------------------------------------------------------------
  4982. type
  4983. PCMSG_SIGNER_ENCODE_INFO = ^CMSG_SIGNER_ENCODE_INFO;
  4984. {$EXTERNALSYM PCMSG_SIGNER_ENCODE_INFO}
  4985. _CMSG_SIGNER_ENCODE_INFO = record
  4986. cbSize: DWORD;
  4987. pCertInfo: PCERT_INFO;
  4988. hCryptProv: HCRYPTPROV;
  4989. dwKeySpec: DWORD;
  4990. HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  4991. pvHashAuxInfo: Pointer;
  4992. cAuthAttr: DWORD;
  4993. rgAuthAttr: PCRYPT_ATTRIBUTE;
  4994. cUnauthAttr: DWORD;
  4995. rgUnauthAttr: PCRYPT_ATTRIBUTE;
  4996. {$IFDEF CMSG_SIGNER_ENCODE_INFO_HAS_CMS_FIELDS}
  4997. SignerId: CERT_ID;
  4998. HashEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  4999. pvHashEncryptionAuxInfo: Pointer;
  5000. {$ENDIF CMSG_SIGNER_ENCODE_INFO_HAS_CMS_FIELDS}
  5001. end;
  5002. {$EXTERNALSYM _CMSG_SIGNER_ENCODE_INFO}
  5003. CMSG_SIGNER_ENCODE_INFO = _CMSG_SIGNER_ENCODE_INFO;
  5004. {$EXTERNALSYM CMSG_SIGNER_ENCODE_INFO}
  5005. TCmsgSignerEncodeInfo = CMSG_SIGNER_ENCODE_INFO;
  5006. PCmsgSignerEncodeInfo = PCMSG_SIGNER_ENCODE_INFO;
  5007. PCMSG_SIGNED_ENCODE_INFO = ^CMSG_SIGNED_ENCODE_INFO;
  5008. {$EXTERNALSYM PCMSG_SIGNED_ENCODE_INFO}
  5009. _CMSG_SIGNED_ENCODE_INFO = record
  5010. cbSize: DWORD;
  5011. cSigners: DWORD;
  5012. rgSigners: PCMSG_SIGNER_ENCODE_INFO;
  5013. cCertEncoded: DWORD;
  5014. rgCertEncoded: PCERT_BLOB;
  5015. cCrlEncoded: DWORD;
  5016. rgCrlEncoded: PCRL_BLOB;
  5017. {$IFDEF CMSG_SIGNED_ENCODE_INFO_HAS_CMS_FIELDS}
  5018. cAttrCertEncoded: DWORD;
  5019. rgAttrCertEncoded: PCERT_BLOB;
  5020. {$ENDIF CMSG_SIGNED_ENCODE_INFO_HAS_CMS_FIELDS}
  5021. end;
  5022. {$EXTERNALSYM _CMSG_SIGNED_ENCODE_INFO}
  5023. CMSG_SIGNED_ENCODE_INFO = _CMSG_SIGNED_ENCODE_INFO;
  5024. {$EXTERNALSYM CMSG_SIGNED_ENCODE_INFO}
  5025. TCmsgSignedEncodeInfo = CMSG_SIGNED_ENCODE_INFO;
  5026. PCmsgSignedEncodeInfo = PCMSG_SIGNED_ENCODE_INFO;
  5027. //+-------------------------------------------------------------------------
  5028. // CMSG_ENVELOPED
  5029. //
  5030. // The PCERT_INFO for the rgRecipients provides the Issuer, SerialNumber
  5031. // and PublicKeyInfo. The PublicKeyInfo.Algorithm implicitly
  5032. // specifies the KeyEncryptionAlgorithm to be used.
  5033. //
  5034. // The PublicKeyInfo.PublicKey in PCERT_INFO is used to encrypt the content
  5035. // encryption key for the recipient.
  5036. //
  5037. // hCryptProv is used to do the content encryption, recipient key encryption
  5038. // and export. The hCryptProv's private keys aren't used. If hCryptProv
  5039. // is NULL, a default hCryptProv is chosen according to the
  5040. // ContentEncryptionAlgorithm and the first recipient KeyEncryptionAlgorithm.
  5041. //
  5042. // If CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags
  5043. // passed to CryptMsgOpenToEncode(), the envelope's hCryptProv is released.
  5044. //
  5045. // Note: CAPI currently doesn't support more than one KeyEncryptionAlgorithm
  5046. // per provider. This will need to be fixed.
  5047. //
  5048. // Currently, pvEncryptionAuxInfo is only defined for RC2 or RC4 encryption
  5049. // algorithms. Otherwise, its not used and must be set to NULL.
  5050. // See CMSG_RC2_AUX_INFO for the RC2 encryption algorithms.
  5051. // See CMSG_RC4_AUX_INFO for the RC4 encryption algorithms.
  5052. //
  5053. // To enable SP3 compatible encryption, pvEncryptionAuxInfo should point to
  5054. // a CMSG_SP3_COMPATIBLE_AUX_INFO data structure.
  5055. //
  5056. // To enable the CMS envelope enhancements, rgpRecipients must be set to
  5057. // NULL, and rgCmsRecipients updated to point to an array of
  5058. // CMSG_RECIPIENT_ENCODE_INFO's.
  5059. //
  5060. // Also, CMS envelope enhancements support the inclusion of a bag of
  5061. // Certs, CRLs, Attribute Certs and/or Unprotected Attributes.
  5062. //--------------------------------------------------------------------------
  5063. type
  5064. PCMSG_ENVELOPED_ENCODE_INFO = ^CMSG_ENVELOPED_ENCODE_INFO;
  5065. {$EXTERNALSYM PCMSG_ENVELOPED_ENCODE_INFO}
  5066. _CMSG_ENVELOPED_ENCODE_INFO = record
  5067. cbSize: DWORD;
  5068. hCryptProv: HCRYPTPROV;
  5069. ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5070. pvEncryptionAuxInfo: Pointer;
  5071. cRecipients: DWORD;
  5072. // The following array may only be used for transport recipients identified
  5073. // by their IssuereAndSerialNumber. If rgpRecipients != NULL, then,
  5074. // the rgCmsRecipients must be NULL.
  5075. rgpRecipients: PCERT_INFO;
  5076. {$IFDEF CMSG_ENVELOPED_ENCODE_INFO_HAS_CMS_FIELDS}
  5077. // If rgCmsRecipients != NULL, then, the above rgpRecipients must be
  5078. // NULL.
  5079. rgCmsRecipients: PCMSG_RECIPIENT_ENCODE_INFO;
  5080. cCertEncoded: DWORD;
  5081. rgCertEncoded: PCERT_BLOB;
  5082. cCrlEncoded: DWORD;
  5083. rgCrlEncoded: PCRL_BLOB;
  5084. cAttrCertEncoded: DWORD;
  5085. rgAttrCertEncoded: PCERT_BLOB;
  5086. cUnprotectedAttr: DWORD;
  5087. rgUnprotectedAttr: PCRYPT_ATTRIBUTE;
  5088. {$ENDIF CMSG_ENVELOPED_ENCODE_INFO_HAS_CMS_FIELDS}
  5089. end;
  5090. {$EXTERNALSYM _CMSG_ENVELOPED_ENCODE_INFO}
  5091. CMSG_ENVELOPED_ENCODE_INFO = _CMSG_ENVELOPED_ENCODE_INFO;
  5092. {$EXTERNALSYM CMSG_ENVELOPED_ENCODE_INFO}
  5093. TCmsgEnvelopedEncodeInfo = CMSG_ENVELOPED_ENCODE_INFO;
  5094. PCmsgEnvelopedEncodeInfo = PCMSG_ENVELOPED_ENCODE_INFO;
  5095. //+-------------------------------------------------------------------------
  5096. // Key Transport Recipient Encode Info
  5097. //
  5098. // hCryptProv is used to do the recipient key encryption
  5099. // and export. The hCryptProv's private keys aren't used.
  5100. //
  5101. // If hCryptProv is NULL, then, the hCryptProv specified in
  5102. // CMSG_ENVELOPED_ENCODE_INFO is used.
  5103. //
  5104. // Note, even if CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags
  5105. // passed to CryptMsgOpenToEncode(), this hCryptProv isn't released.
  5106. //
  5107. // CMS supports the KEY_IDENTIFIER and ISSUER_SERIAL_NUMBER CERT_IDs. PKCS #7
  5108. // version 1.5 only supports the ISSUER_SERIAL_NUMBER CERT_ID choice.
  5109. //--------------------------------------------------------------------------
  5110. PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO = ^CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO;
  5111. {$EXTERNALSYM PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO}
  5112. _CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO = record
  5113. cbSize: DWORD;
  5114. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5115. pvKeyEncryptionAuxInfo: Pointer;
  5116. hCryptProv: HCRYPTPROV;
  5117. RecipientPublicKey: CRYPT_BIT_BLOB;
  5118. RecipientId: CERT_ID;
  5119. end;
  5120. {$EXTERNALSYM _CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO}
  5121. CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO = _CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO;
  5122. {$EXTERNALSYM CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO}
  5123. TCmsgKeyTransRecipientEncodeInfo = CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO;
  5124. PCmsgKeyTransRecipientEncodeInfo = PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO;
  5125. //+-------------------------------------------------------------------------
  5126. // Key Agreement Recipient Encode Info
  5127. //
  5128. // If hCryptProv is NULL, then, the hCryptProv specified in
  5129. // CMSG_ENVELOPED_ENCODE_INFO is used.
  5130. //
  5131. // For the CMSG_KEY_AGREE_STATIC_KEY_CHOICE, both the hCryptProv and
  5132. // dwKeySpec must be specified to select the sender's private key.
  5133. //
  5134. // Note, even if CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags
  5135. // passed to CryptMsgOpenToEncode(), this hCryptProv isn't released.
  5136. //
  5137. // CMS supports the KEY_IDENTIFIER and ISSUER_SERIAL_NUMBER CERT_IDs.
  5138. //
  5139. // There is 1 key choice, ephemeral originator. The originator's ephemeral
  5140. // key is generated using the public key algorithm parameters shared
  5141. // amongst all the recipients.
  5142. //
  5143. // There are 2 key choices: ephemeral originator or static sender. The
  5144. // originator's ephemeral key is generated using the public key algorithm
  5145. // parameters shared amongst all the recipients. For the static sender its
  5146. // private key is used. The hCryptProv and dwKeySpec specify the private key.
  5147. // The pSenderId identifies the certificate containing the sender's public key.
  5148. //
  5149. // Currently, pvKeyEncryptionAuxInfo isn't used and must be set to NULL.
  5150. //
  5151. // If KeyEncryptionAlgorithm.Parameters.cbData == 0, then, its Parameters
  5152. // are updated with the encoded KeyWrapAlgorithm.
  5153. //
  5154. // Currently, pvKeyWrapAuxInfo is only defined for algorithms with
  5155. // RC2. Otherwise, its not used and must be set to NULL.
  5156. // When set for RC2 algorithms, points to a CMSG_RC2_AUX_INFO containing
  5157. // the RC2 effective key length.
  5158. //
  5159. // Note, key agreement recipients are not supported in PKCS #7 version 1.5.
  5160. //--------------------------------------------------------------------------
  5161. PCMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO = ^CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO;
  5162. {$EXTERNALSYM PCMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO}
  5163. _CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO = record
  5164. cbSize: DWORD;
  5165. RecipientPublicKey: CRYPT_BIT_BLOB;
  5166. RecipientId: CERT_ID;
  5167. // Following fields are optional and only applicable to KEY_IDENTIFIER
  5168. // CERT_IDs.
  5169. Date: FILETIME;
  5170. pOtherAttr: PCRYPT_ATTRIBUTE_TYPE_VALUE;
  5171. end;
  5172. {$EXTERNALSYM _CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO}
  5173. CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO = _CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO;
  5174. {$EXTERNALSYM CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO}
  5175. TCmsgRecipientEncryptedKeyEncodeInfo = CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO;
  5176. PCmsgRecipientEncryptedKeyEncodeInfo = PCMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO;
  5177. PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO = ^CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO;
  5178. {$EXTERNALSYM PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO}
  5179. _CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO = record
  5180. cbSize: DWORD;
  5181. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5182. pvKeyEncryptionAuxInfo: Pointer;
  5183. KeyWrapAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5184. pvKeyWrapAuxInfo: Pointer;
  5185. // The following hCryptProv and dwKeySpec must be specified for the
  5186. // CMSG_KEY_AGREE_STATIC_KEY_CHOICE.
  5187. //
  5188. // For CMSG_KEY_AGREE_EPHEMERAL_KEY_CHOICE, dwKeySpec isn't applicable
  5189. // and hCryptProv is optional.
  5190. hCryptProv: HCRYPTPROV;
  5191. dwKeySpec: DWORD;
  5192. dwKeyChoice: DWORD;
  5193. Union: record
  5194. case Integer of
  5195. // CMSG_KEY_AGREE_EPHEMERAL_KEY_CHOICE
  5196. //
  5197. // The ephemeral public key algorithm and parameters.
  5198. 0: (pEphemeralAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER);
  5199. // CMSG_KEY_AGREE_STATIC_KEY_CHOICE
  5200. //
  5201. // The CertId of the sender's certificate
  5202. 1: (pSenderId: PCERT_ID);
  5203. end;
  5204. UserKeyingMaterial: CRYPT_DATA_BLOB; // OPTIONAL
  5205. cRecipientEncryptedKeys: DWORD;
  5206. rgpRecipientEncryptedKeys: PCMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO;
  5207. end;
  5208. {$EXTERNALSYM _CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO}
  5209. CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO = _CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO;
  5210. {$EXTERNALSYM CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO}
  5211. TCmsgKeyAgreeRecipientEncodeInfo = CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO;
  5212. PCmsgKeyAgreeRecipientEncodeInfo = PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO;
  5213. const
  5214. CMSG_KEY_AGREE_EPHEMERAL_KEY_CHOICE = 1;
  5215. {$EXTERNALSYM CMSG_KEY_AGREE_EPHEMERAL_KEY_CHOICE}
  5216. CMSG_KEY_AGREE_STATIC_KEY_CHOICE = 2;
  5217. {$EXTERNALSYM CMSG_KEY_AGREE_STATIC_KEY_CHOICE}
  5218. //+-------------------------------------------------------------------------
  5219. // Mail List Recipient Encode Info
  5220. //
  5221. // There is 1 choice for the KeyEncryptionKey: an already created CSP key
  5222. // handle. For the key handle choice, hCryptProv must be nonzero. This key
  5223. // handle isn't destroyed.
  5224. //
  5225. // Note, even if CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags
  5226. // passed to CryptMsgOpenToEncode(), this hCryptProv isn't released.
  5227. //
  5228. // Currently, pvKeyEncryptionAuxInfo is only defined for RC2 key wrap
  5229. // algorithms. Otherwise, its not used and must be set to NULL.
  5230. // When set for RC2 algorithms, points to a CMSG_RC2_AUX_INFO containing
  5231. // the RC2 effective key length.
  5232. //
  5233. // Note, mail list recipients are not supported in PKCS #7 version 1.5.
  5234. //--------------------------------------------------------------------------
  5235. type
  5236. PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO = ^CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO;
  5237. {$EXTERNALSYM PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO}
  5238. _CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO = record
  5239. cbSize: DWORD;
  5240. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5241. pvKeyEncryptionAuxInfo: Pointer;
  5242. hCryptProv: HCRYPTPROV;
  5243. dwKeyChoice: DWORD;
  5244. Union: record
  5245. case Integer of
  5246. // CMSG_MAIL_LIST_HANDLE_KEY_CHOICE
  5247. 0: (hKeyEncryptionKey: HCRYPTKEY);
  5248. // Reserve space for a potential pointer choice
  5249. 1: (pvKeyEncryptionKey: Pointer);
  5250. end;
  5251. KeyId: CRYPT_DATA_BLOB;
  5252. // Following fields are optional.
  5253. Date: FILETIME;
  5254. pOtherAttr: PCRYPT_ATTRIBUTE_TYPE_VALUE;
  5255. end;
  5256. {$EXTERNALSYM _CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO}
  5257. CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO = _CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO;
  5258. {$EXTERNALSYM CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO}
  5259. TCmsgMailListRecipientEncodeInfo = CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO;
  5260. PCmsgMailListRecipientEncodeInfo = PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO;
  5261. const
  5262. CMSG_MAIL_LIST_HANDLE_KEY_CHOICE = 1;
  5263. {$EXTERNALSYM CMSG_MAIL_LIST_HANDLE_KEY_CHOICE}
  5264. //+-------------------------------------------------------------------------
  5265. // Recipient Encode Info
  5266. //
  5267. // Note, only key transport recipients are supported in PKCS #7 version 1.5.
  5268. //--------------------------------------------------------------------------
  5269. type
  5270. PCMSG_RECIPIENT_ENCODE_INFO = ^CMSG_RECIPIENT_ENCODE_INFO;
  5271. {$NODEFINE PCMSG_RECIPIENT_ENCODE_INFO}
  5272. _CMSG_RECIPIENT_ENCODE_INFO = record
  5273. dwRecipientChoice: DWORD;
  5274. case Integer of
  5275. // CMSG_KEY_TRANS_RECIPIENT
  5276. 0: (pKeyTrans: PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO);
  5277. // CMSG_KEY_AGREE_RECIPIENT
  5278. 1: (pKeyAgree: PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO);
  5279. // CMSG_MAIL_LIST_RECIPIENT
  5280. 2: (pMailList: PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO);
  5281. end;
  5282. {$EXTERNALSYM _CMSG_RECIPIENT_ENCODE_INFO}
  5283. CMSG_RECIPIENT_ENCODE_INFO = _CMSG_RECIPIENT_ENCODE_INFO;
  5284. {$NODEFINE CMSG_RECIPIENT_ENCODE_INFO}
  5285. TCmsgRecipientEncodeInfo = CMSG_RECIPIENT_ENCODE_INFO;
  5286. PCmsgRecipientEncodeInfo = PCMSG_RECIPIENT_ENCODE_INFO;
  5287. const
  5288. CMSG_KEY_TRANS_RECIPIENT = 1;
  5289. {$EXTERNALSYM CMSG_KEY_TRANS_RECIPIENT}
  5290. CMSG_KEY_AGREE_RECIPIENT = 2;
  5291. {$EXTERNALSYM CMSG_KEY_AGREE_RECIPIENT}
  5292. CMSG_MAIL_LIST_RECIPIENT = 3;
  5293. {$EXTERNALSYM CMSG_MAIL_LIST_RECIPIENT}
  5294. //+-------------------------------------------------------------------------
  5295. // CMSG_RC2_AUX_INFO
  5296. //
  5297. // AuxInfo for RC2 encryption algorithms. The pvEncryptionAuxInfo field
  5298. // in CMSG_ENCRYPTED_ENCODE_INFO should be updated to point to this
  5299. // structure. If not specified, defaults to 40 bit.
  5300. //
  5301. // Note, this AuxInfo is only used when, the ContentEncryptionAlgorithm's
  5302. // Parameter.cbData is zero. Otherwise, the Parameters is decoded to
  5303. // get the bit length.
  5304. //
  5305. // If CMSG_SP3_COMPATIBLE_ENCRYPT_FLAG is set in dwBitLen, then, SP3
  5306. // compatible encryption is done and the bit length is ignored.
  5307. //--------------------------------------------------------------------------
  5308. type
  5309. PCMSG_RC2_AUX_INFO = ^CMSG_RC2_AUX_INFO;
  5310. {$EXTERNALSYM PCMSG_RC2_AUX_INFO}
  5311. _CMSG_RC2_AUX_INFO = record
  5312. cbSize: DWORD;
  5313. dwBitLen: DWORD;
  5314. end;
  5315. {$EXTERNALSYM _CMSG_RC2_AUX_INFO}
  5316. CMSG_RC2_AUX_INFO = _CMSG_RC2_AUX_INFO;
  5317. {$EXTERNALSYM CMSG_RC2_AUX_INFO}
  5318. TCmsgRc2AuxInfo = CMSG_RC2_AUX_INFO;
  5319. PCmsgRc2AuxInfo = PCMSG_RC2_AUX_INFO;
  5320. //+-------------------------------------------------------------------------
  5321. // CMSG_SP3_COMPATIBLE_AUX_INFO
  5322. //
  5323. // AuxInfo for enabling SP3 compatible encryption.
  5324. //
  5325. // The CMSG_SP3_COMPATIBLE_ENCRYPT_FLAG is set in dwFlags to enable SP3
  5326. // compatible encryption. When set, uses zero salt instead of no salt,
  5327. // the encryption algorithm parameters are NULL instead of containing the
  5328. // encoded RC2 parameters or encoded IV octet string and the encrypted
  5329. // symmetric key is encoded little endian instead of big endian.
  5330. //--------------------------------------------------------------------------
  5331. PCMSG_SP3_COMPATIBLE_AUX_INFO = ^CMSG_SP3_COMPATIBLE_AUX_INFO;
  5332. {$EXTERNALSYM PCMSG_SP3_COMPATIBLE_AUX_INFO}
  5333. _CMSG_SP3_COMPATIBLE_AUX_INFO = record
  5334. cbSize: DWORD;
  5335. dwFlags: DWORD;
  5336. end;
  5337. {$EXTERNALSYM _CMSG_SP3_COMPATIBLE_AUX_INFO}
  5338. CMSG_SP3_COMPATIBLE_AUX_INFO = _CMSG_SP3_COMPATIBLE_AUX_INFO;
  5339. {$EXTERNALSYM CMSG_SP3_COMPATIBLE_AUX_INFO}
  5340. TCmsgSp3CompatibleAuxInfo = CMSG_SP3_COMPATIBLE_AUX_INFO;
  5341. PCmsgSp3CompatibleAuxInfo = PCMSG_SP3_COMPATIBLE_AUX_INFO;
  5342. const
  5343. CMSG_SP3_COMPATIBLE_ENCRYPT_FLAG = DWORD($80000000);
  5344. {$EXTERNALSYM CMSG_SP3_COMPATIBLE_ENCRYPT_FLAG}
  5345. //+-------------------------------------------------------------------------
  5346. // CMSG_RC4_AUX_INFO
  5347. //
  5348. // AuxInfo for RC4 encryption algorithms. The pvEncryptionAuxInfo field
  5349. // in CMSG_ENCRYPTED_ENCODE_INFO should be updated to point to this
  5350. // structure. If not specified, uses the CSP's default bit length with no
  5351. // salt. Note, the base CSP has a 40 bit default and the enhanced CSP has
  5352. // a 128 bit default.
  5353. //
  5354. // If CMSG_RC4_NO_SALT_FLAG is set in dwBitLen, then, no salt is generated.
  5355. // Otherwise, (128 - dwBitLen)/8 bytes of salt are generated and encoded
  5356. // as an OCTET STRING in the algorithm parameters field.
  5357. //--------------------------------------------------------------------------
  5358. type
  5359. PCMSG_RC4_AUX_INFO = ^CMSG_RC4_AUX_INFO;
  5360. {$EXTERNALSYM PCMSG_RC4_AUX_INFO}
  5361. _CMSG_RC4_AUX_INFO = record
  5362. cbSize: DWORD;
  5363. dwBitLen: DWORD;
  5364. end;
  5365. {$EXTERNALSYM _CMSG_RC4_AUX_INFO}
  5366. CMSG_RC4_AUX_INFO = _CMSG_RC4_AUX_INFO;
  5367. {$EXTERNALSYM CMSG_RC4_AUX_INFO}
  5368. TCmsgRc4AuxInfo = CMSG_RC4_AUX_INFO;
  5369. PCmsgRc4AuxInfo = PCMSG_RC4_AUX_INFO;
  5370. const
  5371. CMSG_RC4_NO_SALT_FLAG = $40000000;
  5372. {$EXTERNALSYM CMSG_RC4_NO_SALT_FLAG}
  5373. //+-------------------------------------------------------------------------
  5374. // CMSG_SIGNED_AND_ENVELOPED
  5375. //
  5376. // For PKCS #7, a signed and enveloped message doesn't have the
  5377. // signer's authenticated or unauthenticated attributes. Otherwise, a
  5378. // combination of the CMSG_SIGNED_ENCODE_INFO and CMSG_ENVELOPED_ENCODE_INFO.
  5379. //--------------------------------------------------------------------------
  5380. type
  5381. PCMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO = ^CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO;
  5382. {$EXTERNALSYM PCMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO}
  5383. _CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO = record
  5384. cbSize: DWORD;
  5385. SignedInfo: CMSG_SIGNED_ENCODE_INFO;
  5386. EnvelopedInfo: CMSG_ENVELOPED_ENCODE_INFO;
  5387. end;
  5388. {$EXTERNALSYM _CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO}
  5389. CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO = _CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO;
  5390. {$EXTERNALSYM CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO}
  5391. TCmsgSignedAndEnvelopedEncodeInfo = CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO;
  5392. PCmsgSignedAndEnvelopedEncodeInfo = PCMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO;
  5393. //+-------------------------------------------------------------------------
  5394. // CMSG_HASHED
  5395. //
  5396. // hCryptProv is used to do the hash. Doesn't need to use a private key.
  5397. //
  5398. // If CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags
  5399. // passed to CryptMsgOpenToEncode(), the hCryptProv is released.
  5400. //
  5401. // If fDetachedHash is set, then, the encoded message doesn't contain
  5402. // any content (its treated as NULL Data)
  5403. //
  5404. // pvHashAuxInfo currently isn't used and must be set to NULL.
  5405. //--------------------------------------------------------------------------
  5406. PCMSG_HASHED_ENCODE_INFO = ^CMSG_HASHED_ENCODE_INFO;
  5407. {$EXTERNALSYM PCMSG_HASHED_ENCODE_INFO}
  5408. _CMSG_HASHED_ENCODE_INFO = record
  5409. cbSize: DWORD;
  5410. hCryptProv: HCRYPTPROV;
  5411. HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5412. pvHashAuxInfo: Pointer;
  5413. end;
  5414. {$EXTERNALSYM _CMSG_HASHED_ENCODE_INFO}
  5415. CMSG_HASHED_ENCODE_INFO = _CMSG_HASHED_ENCODE_INFO;
  5416. {$EXTERNALSYM CMSG_HASHED_ENCODE_INFO}
  5417. TCmsgHashedEncodeInfo = CMSG_HASHED_ENCODE_INFO;
  5418. PCmsgHashedEncodeInfo = PCMSG_HASHED_ENCODE_INFO;
  5419. //+-------------------------------------------------------------------------
  5420. // CMSG_ENCRYPTED
  5421. //
  5422. // The key used to encrypt the message is identified outside of the message
  5423. // content (for example, password).
  5424. //
  5425. // The content input to CryptMsgUpdate has already been encrypted.
  5426. //
  5427. // pvEncryptionAuxInfo currently isn't used and must be set to NULL.
  5428. //--------------------------------------------------------------------------
  5429. PCMSG_ENCRYPTED_ENCODE_INFO = ^CMSG_ENCRYPTED_ENCODE_INFO;
  5430. {$EXTERNALSYM PCMSG_ENCRYPTED_ENCODE_INFO}
  5431. _CMSG_ENCRYPTED_ENCODE_INFO = record
  5432. cbSize: DWORD;
  5433. ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5434. pvEncryptionAuxInfo: Pointer;
  5435. end;
  5436. {$EXTERNALSYM _CMSG_ENCRYPTED_ENCODE_INFO}
  5437. CMSG_ENCRYPTED_ENCODE_INFO = _CMSG_ENCRYPTED_ENCODE_INFO;
  5438. {$EXTERNALSYM CMSG_ENCRYPTED_ENCODE_INFO}
  5439. TCmsgEncryptedEncodeInfo = CMSG_ENCRYPTED_ENCODE_INFO;
  5440. PCmsgEncryptedEncodeInfo = PCMSG_ENCRYPTED_ENCODE_INFO;
  5441. //+-------------------------------------------------------------------------
  5442. // This parameter allows messages to be of variable length with streamed
  5443. // output.
  5444. //
  5445. // By default, messages are of a definite length and
  5446. // CryptMsgGetParam(CMSG_CONTENT_PARAM) is
  5447. // called to get the cryptographically processed content. Until closed,
  5448. // the handle keeps a copy of the processed content.
  5449. //
  5450. // With streamed output, the processed content can be freed as its streamed.
  5451. //
  5452. // If the length of the content to be updated is known at the time of the
  5453. // open, then, ContentLength should be set to that length. Otherwise, it
  5454. // should be set to CMSG_INDEFINITE_LENGTH.
  5455. //--------------------------------------------------------------------------
  5456. type
  5457. PFN_CMSG_STREAM_OUTPUT = function(pvArg: Pointer; pbData: LPBYTE;
  5458. cbData: DWORD; fFinal: BOOL): BOOL; stdcall;
  5459. {$EXTERNALSYM PFN_CMSG_STREAM_OUTPUT}
  5460. PFnCMsgStreamOutput = PFN_CMSG_STREAM_OUTPUT;
  5461. const
  5462. CMSG_INDEFINITE_LENGTH = DWORD($FFFFFFFF);
  5463. {$EXTERNALSYM CMSG_INDEFINITE_LENGTH}
  5464. type
  5465. PCMSG_STREAM_INFO = ^CMSG_STREAM_INFO;
  5466. {$EXTERNALSYM PCMSG_STREAM_INFO}
  5467. _CMSG_STREAM_INFO = record
  5468. cbContent: DWORD;
  5469. pfnStreamOutput: PFN_CMSG_STREAM_OUTPUT;
  5470. pvArg: Pointer;
  5471. end;
  5472. {$EXTERNALSYM _CMSG_STREAM_INFO}
  5473. CMSG_STREAM_INFO = _CMSG_STREAM_INFO;
  5474. {$EXTERNALSYM CMSG_STREAM_INFO}
  5475. TCmsgStreamInfo = CMSG_STREAM_INFO;
  5476. PCmsgStreamInfo = PCMSG_STREAM_INFO;
  5477. //+-------------------------------------------------------------------------
  5478. // Open dwFlags
  5479. //--------------------------------------------------------------------------
  5480. const
  5481. CMSG_BARE_CONTENT_FLAG = $00000001;
  5482. {$EXTERNALSYM CMSG_BARE_CONTENT_FLAG}
  5483. CMSG_LENGTH_ONLY_FLAG = $00000002;
  5484. {$EXTERNALSYM CMSG_LENGTH_ONLY_FLAG}
  5485. CMSG_DETACHED_FLAG = $00000004;
  5486. {$EXTERNALSYM CMSG_DETACHED_FLAG}
  5487. CMSG_AUTHENTICATED_ATTRIBUTES_FLAG = $00000008;
  5488. {$EXTERNALSYM CMSG_AUTHENTICATED_ATTRIBUTES_FLAG}
  5489. CMSG_CONTENTS_OCTETS_FLAG = $00000010;
  5490. {$EXTERNALSYM CMSG_CONTENTS_OCTETS_FLAG}
  5491. CMSG_MAX_LENGTH_FLAG = $00000020;
  5492. {$EXTERNALSYM CMSG_MAX_LENGTH_FLAG}
  5493. // When set, nonData type inner content is encapsulated within an
  5494. // OCTET STRING. Applicable to both Signed and Enveloped messages.
  5495. CMSG_CMS_ENCAPSULATED_CONTENT_FLAG = $00000040;
  5496. {$EXTERNALSYM CMSG_CMS_ENCAPSULATED_CONTENT_FLAG}
  5497. // If set, then, the hCryptProv passed to CryptMsgOpenToEncode or
  5498. // CryptMsgOpenToDecode is released on the final CryptMsgClose.
  5499. // Not released if CryptMsgOpenToEncode or CryptMsgOpenToDecode fails.
  5500. //
  5501. // Note, the envelope recipient hCryptProv's aren't released.
  5502. CMSG_CRYPT_RELEASE_CONTEXT_FLAG = $00008000;
  5503. {$EXTERNALSYM CMSG_CRYPT_RELEASE_CONTEXT_FLAG}
  5504. //+-------------------------------------------------------------------------
  5505. // Open a cryptographic message for encoding
  5506. //
  5507. // For PKCS #7:
  5508. // If the content to be passed to CryptMsgUpdate has already
  5509. // been message encoded (the input to CryptMsgUpdate is the streamed output
  5510. // from another message encode), then, the CMSG_ENCODED_CONTENT_INFO_FLAG should
  5511. // be set in dwFlags. If not set, then, the inner ContentType is Data and
  5512. // the input to CryptMsgUpdate is treated as the inner Data type's Content,
  5513. // a string of bytes.
  5514. // If CMSG_BARE_CONTENT_FLAG is specified for a streamed message,
  5515. // the streamed output will not have an outer ContentInfo wrapper. This
  5516. // makes it suitable to be streamed into an enclosing message.
  5517. //
  5518. // The pStreamInfo parameter needs to be set to stream the encoded message
  5519. // output.
  5520. //--------------------------------------------------------------------------
  5521. function CryptMsgOpenToEncode(dwMsgEncodingType, dwFlags, dwMsgType: DWORD;
  5522. pvMsgEncodeInfo: Pointer; pszInnerContentObjID: LPSTR;
  5523. pStreamInfo: PCMSG_STREAM_INFO): HCRYPTMSG; stdcall;
  5524. {$EXTERNALSYM CryptMsgOpenToEncode}
  5525. //+-------------------------------------------------------------------------
  5526. // Calculate the length of an encoded cryptographic message.
  5527. //
  5528. // Calculates the length of the encoded message given the
  5529. // message type, encoding parameters and total length of
  5530. // the data to be updated. Note, this might not be the exact length. However,
  5531. // it will always be greater than or equal to the actual length.
  5532. //--------------------------------------------------------------------------
  5533. function CryptMsgCalculateEncodedLength(dwMsgEncodingType, dwFlags, dwMsgType: DWORD;
  5534. pvMsgEncodeInfo: Pointer; pszInnerContentObjID: LPSTR; cbData: DWORD): DWORD; stdcall;
  5535. {$EXTERNALSYM CryptMsgCalculateEncodedLength}
  5536. //+-------------------------------------------------------------------------
  5537. // Open a cryptographic message for decoding
  5538. //
  5539. // hCryptProv specifies the crypto provider to use for hashing and/or
  5540. // decrypting the message. If hCryptProv is NULL, a default crypt provider
  5541. // is used.
  5542. //
  5543. // Currently pRecipientInfo isn't used and should be set to NULL.
  5544. //
  5545. // The pStreamInfo parameter needs to be set to stream the decoded content
  5546. // output.
  5547. //--------------------------------------------------------------------------
  5548. function CryptMsgOpenToDecode(dwMsgEncodingType, dwFlags, dwMsgType: DWORD;
  5549. hCryptProv: HCRYPTPROV; pRecipientInfo: PCERT_INFO;
  5550. pStreamInfo: PCMSG_STREAM_INFO): HCRYPTMSG; stdcall;
  5551. {$EXTERNALSYM CryptMsgOpenToDecode}
  5552. //+-------------------------------------------------------------------------
  5553. // Duplicate a cryptographic message handle
  5554. //--------------------------------------------------------------------------
  5555. function CryptMsgDuplicate(hCryptMsg: HCRYPTMSG): HCRYPTMSG; stdcall;
  5556. {$EXTERNALSYM CryptMsgDuplicate}
  5557. //+-------------------------------------------------------------------------
  5558. // Close a cryptographic message handle
  5559. //
  5560. // LastError is preserved unless FALSE is returned.
  5561. //--------------------------------------------------------------------------
  5562. function CryptMsgClose(hCryptMsg: HCRYPTMSG): BOOL; stdcall;
  5563. {$EXTERNALSYM CryptMsgClose}
  5564. //+-------------------------------------------------------------------------
  5565. // Update the content of a cryptographic message. Depending on how the
  5566. // message was opened, the content is either encoded or decoded.
  5567. //
  5568. // This function is repetitively called to append to the message content.
  5569. // fFinal is set to identify the last update. On fFinal, the encode/decode
  5570. // is completed. The encoded/decoded content and the decoded parameters
  5571. // are valid until the open and all duplicated handles are closed.
  5572. //--------------------------------------------------------------------------
  5573. function CryptMsgUpdate(hCryptMsg: HCRYPTMSG; pbData: LPBYTE; cbData: DWORD;
  5574. fFinal: BOOL): BOOL; stdcall;
  5575. {$EXTERNALSYM CryptMsgUpdate}
  5576. //+-------------------------------------------------------------------------
  5577. // Get a parameter after encoding/decoding a cryptographic message. Called
  5578. // after the final CryptMsgUpdate. Only the CMSG_CONTENT_PARAM and
  5579. // CMSG_COMPUTED_HASH_PARAM are valid for an encoded message.
  5580. //
  5581. // For an encoded HASHED message, the CMSG_COMPUTED_HASH_PARAM can be got
  5582. // before any CryptMsgUpdates to get its length.
  5583. //
  5584. // The pvData type definition depends on the dwParamType value.
  5585. //
  5586. // Elements pointed to by fields in the pvData structure follow the
  5587. // structure. Therefore, *pcbData may exceed the size of the structure.
  5588. //
  5589. // Upon input, if *pcbData == 0, then, *pcbData is updated with the length
  5590. // of the data and the pvData parameter is ignored.
  5591. //
  5592. // Upon return, *pcbData is updated with the length of the data.
  5593. //
  5594. // The OBJID BLOBs returned in the pvData structures point to
  5595. // their still encoded representation. The appropriate functions
  5596. // must be called to decode the information.
  5597. //
  5598. // See below for a list of the parameters to get.
  5599. //--------------------------------------------------------------------------
  5600. function CryptMsgGetParam(hCryptMsg: HCRYPTMSG; dwParamType, dwIndex: DWORD;
  5601. pvData: Pointer; var pcbData: DWORD): BOOL; stdcall;
  5602. {$EXTERNALSYM CryptMsgGetParam}
  5603. //+-------------------------------------------------------------------------
  5604. // Get parameter types and their corresponding data structure definitions.
  5605. //--------------------------------------------------------------------------
  5606. const
  5607. CMSG_TYPE_PARAM = 1;
  5608. {$EXTERNALSYM CMSG_TYPE_PARAM}
  5609. CMSG_CONTENT_PARAM = 2;
  5610. {$EXTERNALSYM CMSG_CONTENT_PARAM}
  5611. CMSG_BARE_CONTENT_PARAM = 3;
  5612. {$EXTERNALSYM CMSG_BARE_CONTENT_PARAM}
  5613. CMSG_INNER_CONTENT_TYPE_PARAM = 4;
  5614. {$EXTERNALSYM CMSG_INNER_CONTENT_TYPE_PARAM}
  5615. CMSG_SIGNER_COUNT_PARAM = 5;
  5616. {$EXTERNALSYM CMSG_SIGNER_COUNT_PARAM}
  5617. CMSG_SIGNER_INFO_PARAM = 6;
  5618. {$EXTERNALSYM CMSG_SIGNER_INFO_PARAM}
  5619. CMSG_SIGNER_CERT_INFO_PARAM = 7;
  5620. {$EXTERNALSYM CMSG_SIGNER_CERT_INFO_PARAM}
  5621. CMSG_SIGNER_HASH_ALGORITHM_PARAM = 8;
  5622. {$EXTERNALSYM CMSG_SIGNER_HASH_ALGORITHM_PARAM}
  5623. CMSG_SIGNER_AUTH_ATTR_PARAM = 9;
  5624. {$EXTERNALSYM CMSG_SIGNER_AUTH_ATTR_PARAM}
  5625. CMSG_SIGNER_UNAUTH_ATTR_PARAM = 10;
  5626. {$EXTERNALSYM CMSG_SIGNER_UNAUTH_ATTR_PARAM}
  5627. CMSG_CERT_COUNT_PARAM = 11;
  5628. {$EXTERNALSYM CMSG_CERT_COUNT_PARAM}
  5629. CMSG_CERT_PARAM = 12;
  5630. {$EXTERNALSYM CMSG_CERT_PARAM}
  5631. CMSG_CRL_COUNT_PARAM = 13;
  5632. {$EXTERNALSYM CMSG_CRL_COUNT_PARAM}
  5633. CMSG_CRL_PARAM = 14;
  5634. {$EXTERNALSYM CMSG_CRL_PARAM}
  5635. CMSG_ENVELOPE_ALGORITHM_PARAM = 15;
  5636. {$EXTERNALSYM CMSG_ENVELOPE_ALGORITHM_PARAM}
  5637. CMSG_RECIPIENT_COUNT_PARAM = 17;
  5638. {$EXTERNALSYM CMSG_RECIPIENT_COUNT_PARAM}
  5639. CMSG_RECIPIENT_INDEX_PARAM = 18;
  5640. {$EXTERNALSYM CMSG_RECIPIENT_INDEX_PARAM}
  5641. CMSG_RECIPIENT_INFO_PARAM = 19;
  5642. {$EXTERNALSYM CMSG_RECIPIENT_INFO_PARAM}
  5643. CMSG_HASH_ALGORITHM_PARAM = 20;
  5644. {$EXTERNALSYM CMSG_HASH_ALGORITHM_PARAM}
  5645. CMSG_HASH_DATA_PARAM = 21;
  5646. {$EXTERNALSYM CMSG_HASH_DATA_PARAM}
  5647. CMSG_COMPUTED_HASH_PARAM = 22;
  5648. {$EXTERNALSYM CMSG_COMPUTED_HASH_PARAM}
  5649. CMSG_ENCRYPT_PARAM = 26;
  5650. {$EXTERNALSYM CMSG_ENCRYPT_PARAM}
  5651. CMSG_ENCRYPTED_DIGEST = 27;
  5652. {$EXTERNALSYM CMSG_ENCRYPTED_DIGEST}
  5653. CMSG_ENCODED_SIGNER = 28;
  5654. {$EXTERNALSYM CMSG_ENCODED_SIGNER}
  5655. CMSG_ENCODED_MESSAGE = 29;
  5656. {$EXTERNALSYM CMSG_ENCODED_MESSAGE}
  5657. CMSG_VERSION_PARAM = 30;
  5658. {$EXTERNALSYM CMSG_VERSION_PARAM}
  5659. CMSG_ATTR_CERT_COUNT_PARAM = 31;
  5660. {$EXTERNALSYM CMSG_ATTR_CERT_COUNT_PARAM}
  5661. CMSG_ATTR_CERT_PARAM = 32;
  5662. {$EXTERNALSYM CMSG_ATTR_CERT_PARAM}
  5663. CMSG_CMS_RECIPIENT_COUNT_PARAM = 33;
  5664. {$EXTERNALSYM CMSG_CMS_RECIPIENT_COUNT_PARAM}
  5665. CMSG_CMS_RECIPIENT_INDEX_PARAM = 34;
  5666. {$EXTERNALSYM CMSG_CMS_RECIPIENT_INDEX_PARAM}
  5667. CMSG_CMS_RECIPIENT_ENCRYPTED_KEY_INDEX_PARAM = 35;
  5668. {$EXTERNALSYM CMSG_CMS_RECIPIENT_ENCRYPTED_KEY_INDEX_PARAM}
  5669. CMSG_CMS_RECIPIENT_INFO_PARAM = 36;
  5670. {$EXTERNALSYM CMSG_CMS_RECIPIENT_INFO_PARAM}
  5671. CMSG_UNPROTECTED_ATTR_PARAM = 37;
  5672. {$EXTERNALSYM CMSG_UNPROTECTED_ATTR_PARAM}
  5673. CMSG_SIGNER_CERT_ID_PARAM = 38;
  5674. {$EXTERNALSYM CMSG_SIGNER_CERT_ID_PARAM}
  5675. CMSG_CMS_SIGNER_INFO_PARAM = 39;
  5676. {$EXTERNALSYM CMSG_CMS_SIGNER_INFO_PARAM}
  5677. //+-------------------------------------------------------------------------
  5678. // CMSG_TYPE_PARAM
  5679. //
  5680. // The type of the decoded message.
  5681. //
  5682. // pvData points to a DWORD
  5683. //--------------------------------------------------------------------------
  5684. //+-------------------------------------------------------------------------
  5685. // CMSG_CONTENT_PARAM
  5686. //
  5687. // The encoded content of a cryptographic message. Depending on how the
  5688. // message was opened, the content is either the whole PKCS#7
  5689. // message (opened to encode) or the inner content (opened to decode).
  5690. // In the decode case, the decrypted content is returned, if enveloped.
  5691. // If not enveloped, and if the inner content is of type DATA, the returned
  5692. // data is the contents octets of the inner content.
  5693. //
  5694. // pvData points to the buffer receiving the content bytes
  5695. //--------------------------------------------------------------------------
  5696. //+-------------------------------------------------------------------------
  5697. // CMSG_BARE_CONTENT_PARAM
  5698. //
  5699. // The encoded content of an encoded cryptographic message, without the
  5700. // outer layer of ContentInfo. That is, only the encoding of the
  5701. // ContentInfo.content field is returned.
  5702. //
  5703. // pvData points to the buffer receiving the content bytes
  5704. //--------------------------------------------------------------------------
  5705. //+-------------------------------------------------------------------------
  5706. // CMSG_INNER_CONTENT_TYPE_PARAM
  5707. //
  5708. // The type of the inner content of a decoded cryptographic message,
  5709. // in the form of a NULL-terminated object identifier string
  5710. // (eg. "1.2.840.113549.1.7.1").
  5711. //
  5712. // pvData points to the buffer receiving the object identifier string
  5713. //--------------------------------------------------------------------------
  5714. //+-------------------------------------------------------------------------
  5715. // CMSG_SIGNER_COUNT_PARAM
  5716. //
  5717. // Count of signers in a SIGNED or SIGNED_AND_ENVELOPED message
  5718. //
  5719. // pvData points to a DWORD
  5720. //--------------------------------------------------------------------------
  5721. //+-------------------------------------------------------------------------
  5722. // CMSG_SIGNER_CERT_INFO_PARAM
  5723. //
  5724. // To get all the signers, repetitively call CryptMsgGetParam, with
  5725. // dwIndex set to 0 .. SignerCount - 1.
  5726. //
  5727. // pvData points to a CERT_INFO struct.
  5728. //
  5729. // Only the following fields have been updated in the CERT_INFO struct:
  5730. // Issuer and SerialNumber.
  5731. //
  5732. // Note, if the KEYID choice was selected for a CMS SignerId, then, the
  5733. // SerialNumber is 0 and the Issuer is encoded containing a single RDN with a
  5734. // single Attribute whose OID is szOID_KEYID_RDN, value type is
  5735. // CERT_RDN_OCTET_STRING and value is the KEYID. When the
  5736. // CertGetSubjectCertificateFromStore and
  5737. // CertFindCertificateInStore(CERT_FIND_SUBJECT_CERT) APIs see this
  5738. // special KEYID Issuer and SerialNumber, they do a KEYID match.
  5739. //--------------------------------------------------------------------------
  5740. //+-------------------------------------------------------------------------
  5741. // CMSG_SIGNER_INFO_PARAM
  5742. //
  5743. // To get all the signers, repetitively call CryptMsgGetParam, with
  5744. // dwIndex set to 0 .. SignerCount - 1.
  5745. //
  5746. // pvData points to a CMSG_SIGNER_INFO struct.
  5747. //
  5748. // Note, if the KEYID choice was selected for a CMS SignerId, then, the
  5749. // SerialNumber is 0 and the Issuer is encoded containing a single RDN with a
  5750. // single Attribute whose OID is szOID_KEYID_RDN, value type is
  5751. // CERT_RDN_OCTET_STRING and value is the KEYID. When the
  5752. // CertGetSubjectCertificateFromStore and
  5753. // CertFindCertificateInStore(CERT_FIND_SUBJECT_CERT) APIs see this
  5754. // special KEYID Issuer and SerialNumber, they do a KEYID match.
  5755. //--------------------------------------------------------------------------
  5756. type
  5757. PCMSG_SIGNER_INFO = ^CMSG_SIGNER_INFO;
  5758. {$EXTERNALSYM PCMSG_SIGNER_INFO}
  5759. _CMSG_SIGNER_INFO = record
  5760. dwVersion: DWORD;
  5761. Issuer: CERT_NAME_BLOB;
  5762. SerialNumber: CRYPT_INTEGER_BLOB;
  5763. HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5764. HashEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5765. EncryptedHash: CRYPT_DATA_BLOB;
  5766. AuthAttrs: CRYPT_ATTRIBUTES;
  5767. UnauthAttrs: CRYPT_ATTRIBUTES;
  5768. end;
  5769. {$EXTERNALSYM _CMSG_SIGNER_INFO}
  5770. CMSG_SIGNER_INFO = _CMSG_SIGNER_INFO;
  5771. {$EXTERNALSYM CMSG_SIGNER_INFO}
  5772. TCmsgSignerInfo = CMSG_SIGNER_INFO;
  5773. PCmsgSignerInfo = PCMSG_SIGNER_INFO;
  5774. //+-------------------------------------------------------------------------
  5775. // CMSG_SIGNER_CERT_ID_PARAM
  5776. //
  5777. // To get all the signers, repetitively call CryptMsgGetParam, with
  5778. // dwIndex set to 0 .. SignerCount - 1.
  5779. //
  5780. // pvData points to a CERT_ID struct.
  5781. //--------------------------------------------------------------------------
  5782. //+-------------------------------------------------------------------------
  5783. // CMSG_CMS_SIGNER_INFO_PARAM
  5784. //
  5785. // Same as CMSG_SIGNER_INFO_PARAM, except, contains SignerId instead of
  5786. // Issuer and SerialNumber.
  5787. //
  5788. // To get all the signers, repetitively call CryptMsgGetParam, with
  5789. // dwIndex set to 0 .. SignerCount - 1.
  5790. //
  5791. // pvData points to a CMSG_CMS_SIGNER_INFO struct.
  5792. //--------------------------------------------------------------------------
  5793. PCMSG_CMS_SIGNER_INFO = ^CMSG_CMS_SIGNER_INFO;
  5794. {$EXTERNALSYM PCMSG_CMS_SIGNER_INFO}
  5795. _CMSG_CMS_SIGNER_INFO = record
  5796. dwVersion: DWORD;
  5797. SignerId: CERT_ID;
  5798. HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5799. HashEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  5800. EncryptedHash: CRYPT_DATA_BLOB;
  5801. AuthAttrs: CRYPT_ATTRIBUTES;
  5802. UnauthAttrs: CRYPT_ATTRIBUTES;
  5803. end;
  5804. {$EXTERNALSYM _CMSG_CMS_SIGNER_INFO}
  5805. CMSG_CMS_SIGNER_INFO = _CMSG_CMS_SIGNER_INFO;
  5806. {$EXTERNALSYM CMSG_CMS_SIGNER_INFO}
  5807. TCmsgCmsSignerInfo = CMSG_CMS_SIGNER_INFO;
  5808. PCmsgCmsSignerInfo = PCMSG_CMS_SIGNER_INFO;
  5809. //+-------------------------------------------------------------------------
  5810. // CMSG_SIGNER_HASH_ALGORITHM_PARAM
  5811. //
  5812. // This parameter specifies the HashAlgorithm that was used for the signer.
  5813. //
  5814. // Set dwIndex to iterate through all the signers.
  5815. //
  5816. // pvData points to an CRYPT_ALGORITHM_IDENTIFIER struct.
  5817. //--------------------------------------------------------------------------
  5818. //+-------------------------------------------------------------------------
  5819. // CMSG_SIGNER_AUTH_ATTR_PARAM
  5820. //
  5821. // The authenticated attributes for the signer.
  5822. //
  5823. // Set dwIndex to iterate through all the signers.
  5824. //
  5825. // pvData points to a CMSG_ATTR struct.
  5826. //--------------------------------------------------------------------------
  5827. CMSG_ATTR = CRYPT_ATTRIBUTES;
  5828. {$EXTERNALSYM CMSG_ATTR}
  5829. PCMSG_ATTR = ^CRYPT_ATTRIBUTES;
  5830. {$EXTERNALSYM PCMSG_ATTR}
  5831. //+-------------------------------------------------------------------------
  5832. // CMSG_SIGNER_UNAUTH_ATTR_PARAM
  5833. //
  5834. // The unauthenticated attributes for the signer.
  5835. //
  5836. // Set dwIndex to iterate through all the signers.
  5837. //
  5838. // pvData points to a CMSG_ATTR struct.
  5839. //--------------------------------------------------------------------------
  5840. //+-------------------------------------------------------------------------
  5841. // CMSG_CERT_COUNT_PARAM
  5842. //
  5843. // Count of certificates in a SIGNED or SIGNED_AND_ENVELOPED message.
  5844. //
  5845. // CMS, also supports certificates in an ENVELOPED message.
  5846. //
  5847. // pvData points to a DWORD
  5848. //--------------------------------------------------------------------------
  5849. //+-------------------------------------------------------------------------
  5850. // CMSG_CERT_PARAM
  5851. //
  5852. // To get all the certificates, repetitively call CryptMsgGetParam, with
  5853. // dwIndex set to 0 .. CertCount - 1.
  5854. //
  5855. // pvData points to an array of the certificate's encoded bytes.
  5856. //--------------------------------------------------------------------------
  5857. //+-------------------------------------------------------------------------
  5858. // CMSG_CRL_COUNT_PARAM
  5859. //
  5860. // Count of CRLs in a SIGNED or SIGNED_AND_ENVELOPED message.
  5861. //
  5862. // CMS, also supports CRLs in an ENVELOPED message.
  5863. //
  5864. // pvData points to a DWORD
  5865. //--------------------------------------------------------------------------
  5866. //+-------------------------------------------------------------------------
  5867. // CMSG_CRL_PARAM
  5868. //
  5869. // To get all the CRLs, repetitively call CryptMsgGetParam, with
  5870. // dwIndex set to 0 .. CrlCount - 1.
  5871. //
  5872. // pvData points to an array of the CRL's encoded bytes.
  5873. //--------------------------------------------------------------------------
  5874. //+-------------------------------------------------------------------------
  5875. // CMSG_ENVELOPE_ALGORITHM_PARAM
  5876. //
  5877. // The ContentEncryptionAlgorithm that was used in
  5878. // an ENVELOPED or SIGNED_AND_ENVELOPED message.
  5879. //
  5880. // For streaming you must be able to successfully get this parameter before
  5881. // doing a CryptMsgControl decrypt.
  5882. //
  5883. // pvData points to an CRYPT_ALGORITHM_IDENTIFIER struct.
  5884. //--------------------------------------------------------------------------
  5885. //+-------------------------------------------------------------------------
  5886. // CMSG_RECIPIENT_COUNT_PARAM
  5887. //
  5888. // Count of recipients in an ENVELOPED or SIGNED_AND_ENVELOPED message.
  5889. //
  5890. // Count of key transport recepients.
  5891. //
  5892. // The CMSG_CMS_RECIPIENT_COUNT_PARAM has the total count of
  5893. // recipients (it also includes key agree and mail list recipients).
  5894. //
  5895. // pvData points to a DWORD
  5896. //--------------------------------------------------------------------------
  5897. //+-------------------------------------------------------------------------
  5898. // CMSG_RECIPIENT_INDEX_PARAM
  5899. //
  5900. // Index of the recipient used to decrypt an ENVELOPED or SIGNED_AND_ENVELOPED
  5901. // message.
  5902. //
  5903. // Index of a key transport recipient. If a non key transport
  5904. // recipient was used to decrypt, fails with LastError set to
  5905. // CRYPT_E_INVALID_INDEX.
  5906. //
  5907. // pvData points to a DWORD
  5908. //--------------------------------------------------------------------------
  5909. //+-------------------------------------------------------------------------
  5910. // CMSG_RECIPIENT_INFO_PARAM
  5911. //
  5912. // To get all the recipients, repetitively call CryptMsgGetParam, with
  5913. // dwIndex set to 0 .. RecipientCount - 1.
  5914. //
  5915. // Only returns the key transport recepients.
  5916. //
  5917. // The CMSG_CMS_RECIPIENT_INFO_PARAM returns all recipients.
  5918. //
  5919. // pvData points to a CERT_INFO struct.
  5920. //
  5921. // Only the following fields have been updated in the CERT_INFO struct:
  5922. // Issuer, SerialNumber and PublicKeyAlgorithm. The PublicKeyAlgorithm
  5923. // specifies the KeyEncryptionAlgorithm that was used.
  5924. //
  5925. // Note, if the KEYID choice was selected for a key transport recipient, then,
  5926. // the SerialNumber is 0 and the Issuer is encoded containing a single RDN
  5927. // with a single Attribute whose OID is szOID_KEYID_RDN, value type is
  5928. // CERT_RDN_OCTET_STRING and value is the KEYID. When the
  5929. // CertGetSubjectCertificateFromStore and
  5930. // CertFindCertificateInStore(CERT_FIND_SUBJECT_CERT) APIs see this
  5931. // special KEYID Issuer and SerialNumber, they do a KEYID match.
  5932. //--------------------------------------------------------------------------
  5933. //+-------------------------------------------------------------------------
  5934. // CMSG_HASH_ALGORITHM_PARAM
  5935. //
  5936. // The HashAlgorithm in a HASHED message.
  5937. //
  5938. // pvData points to an CRYPT_ALGORITHM_IDENTIFIER struct.
  5939. //--------------------------------------------------------------------------
  5940. //+-------------------------------------------------------------------------
  5941. // CMSG_HASH_DATA_PARAM
  5942. //
  5943. // The hash in a HASHED message.
  5944. //
  5945. // pvData points to an array of bytes.
  5946. //--------------------------------------------------------------------------
  5947. //+-------------------------------------------------------------------------
  5948. // CMSG_COMPUTED_HASH_PARAM
  5949. //
  5950. // The computed hash for a HASHED message.
  5951. // This may be called for either an encoded or decoded message.
  5952. //
  5953. // Also, the computed hash for one of the signer's in a SIGNED message.
  5954. // It may be called for either an encoded or decoded message after the
  5955. // final update. Set dwIndex to iterate through all the signers.
  5956. //
  5957. // pvData points to an array of bytes.
  5958. //--------------------------------------------------------------------------
  5959. //+-------------------------------------------------------------------------
  5960. // CMSG_ENCRYPT_PARAM
  5961. //
  5962. // The ContentEncryptionAlgorithm that was used in an ENCRYPTED message.
  5963. //
  5964. // pvData points to an CRYPT_ALGORITHM_IDENTIFIER struct.
  5965. //--------------------------------------------------------------------------
  5966. //+-------------------------------------------------------------------------
  5967. // CMSG_ENCODED_MESSAGE
  5968. //
  5969. // The full encoded message. This is useful in the case of a decoded
  5970. // message which has been modified (eg. a signed-data or
  5971. // signed-and-enveloped-data message which has been countersigned).
  5972. //
  5973. // pvData points to an array of the message's encoded bytes.
  5974. //--------------------------------------------------------------------------
  5975. //+-------------------------------------------------------------------------
  5976. // CMSG_VERSION_PARAM
  5977. //
  5978. // The version of the decoded message.
  5979. //
  5980. // pvData points to a DWORD
  5981. //--------------------------------------------------------------------------
  5982. const
  5983. CMSG_SIGNED_DATA_V1 = 1;
  5984. {$EXTERNALSYM CMSG_SIGNED_DATA_V1}
  5985. CMSG_SIGNED_DATA_V3 = 3;
  5986. {$EXTERNALSYM CMSG_SIGNED_DATA_V3}
  5987. CMSG_SIGNED_DATA_PKCS_1_5_VERSION = CMSG_SIGNED_DATA_V1;
  5988. {$EXTERNALSYM CMSG_SIGNED_DATA_PKCS_1_5_VERSION}
  5989. CMSG_SIGNED_DATA_CMS_VERSION = CMSG_SIGNED_DATA_V3;
  5990. {$EXTERNALSYM CMSG_SIGNED_DATA_CMS_VERSION}
  5991. CMSG_SIGNER_INFO_V1 = 1;
  5992. {$EXTERNALSYM CMSG_SIGNER_INFO_V1}
  5993. CMSG_SIGNER_INFO_V3 = 3;
  5994. {$EXTERNALSYM CMSG_SIGNER_INFO_V3}
  5995. CMSG_SIGNER_INFO_PKCS_1_5_VERSION = CMSG_SIGNER_INFO_V1;
  5996. {$EXTERNALSYM CMSG_SIGNER_INFO_PKCS_1_5_VERSION}
  5997. CMSG_SIGNER_INFO_CMS_VERSION = CMSG_SIGNER_INFO_V3;
  5998. {$EXTERNALSYM CMSG_SIGNER_INFO_CMS_VERSION}
  5999. CMSG_HASHED_DATA_V0 = 0;
  6000. {$EXTERNALSYM CMSG_HASHED_DATA_V0}
  6001. CMSG_HASHED_DATA_V2 = 2;
  6002. {$EXTERNALSYM CMSG_HASHED_DATA_V2}
  6003. CMSG_HASHED_DATA_PKCS_1_5_VERSION = CMSG_HASHED_DATA_V0;
  6004. {$EXTERNALSYM CMSG_HASHED_DATA_PKCS_1_5_VERSION}
  6005. CMSG_HASHED_DATA_CMS_VERSION = CMSG_HASHED_DATA_V2;
  6006. {$EXTERNALSYM CMSG_HASHED_DATA_CMS_VERSION}
  6007. CMSG_ENVELOPED_DATA_V0 = 0;
  6008. {$EXTERNALSYM CMSG_ENVELOPED_DATA_V0}
  6009. CMSG_ENVELOPED_DATA_V2 = 2;
  6010. {$EXTERNALSYM CMSG_ENVELOPED_DATA_V2}
  6011. CMSG_ENVELOPED_DATA_PKCS_1_5_VERSION = CMSG_ENVELOPED_DATA_V0;
  6012. {$EXTERNALSYM CMSG_ENVELOPED_DATA_PKCS_1_5_VERSION}
  6013. CMSG_ENVELOPED_DATA_CMS_VERSION = CMSG_ENVELOPED_DATA_V2;
  6014. {$EXTERNALSYM CMSG_ENVELOPED_DATA_CMS_VERSION}
  6015. //+-------------------------------------------------------------------------
  6016. // CMSG_ATTR_CERT_COUNT_PARAM
  6017. //
  6018. // Count of attribute certificates in a SIGNED or ENVELOPED message.
  6019. //
  6020. // pvData points to a DWORD
  6021. //--------------------------------------------------------------------------
  6022. //+-------------------------------------------------------------------------
  6023. // CMSG_ATTR_CERT_PARAM
  6024. //
  6025. // To get all the attribute certificates, repetitively call CryptMsgGetParam,
  6026. // with dwIndex set to 0 .. AttrCertCount - 1.
  6027. //
  6028. // pvData points to an array of the attribute certificate's encoded bytes.
  6029. //--------------------------------------------------------------------------
  6030. //+-------------------------------------------------------------------------
  6031. // CMSG_CMS_RECIPIENT_COUNT_PARAM
  6032. //
  6033. // Count of all CMS recipients in an ENVELOPED message.
  6034. //
  6035. // pvData points to a DWORD
  6036. //--------------------------------------------------------------------------
  6037. //+-------------------------------------------------------------------------
  6038. // CMSG_CMS_RECIPIENT_INDEX_PARAM
  6039. //
  6040. // Index of the CMS recipient used to decrypt an ENVELOPED message.
  6041. //
  6042. // pvData points to a DWORD
  6043. //--------------------------------------------------------------------------
  6044. //+-------------------------------------------------------------------------
  6045. // CMSG_CMS_RECIPIENT_ENCRYPTED_KEY_INDEX_PARAM
  6046. //
  6047. // For a CMS key agreement recipient, the index of the encrypted key
  6048. // used to decrypt an ENVELOPED message.
  6049. //
  6050. // pvData points to a DWORD
  6051. //--------------------------------------------------------------------------
  6052. //+-------------------------------------------------------------------------
  6053. // CMSG_CMS_RECIPIENT_INFO_PARAM
  6054. //
  6055. // To get all the CMS recipients, repetitively call CryptMsgGetParam, with
  6056. // dwIndex set to 0 .. CmsRecipientCount - 1.
  6057. //
  6058. // pvData points to a CMSG_CMS_RECIPIENT_INFO struct.
  6059. //--------------------------------------------------------------------------
  6060. type
  6061. PCMSG_KEY_TRANS_RECIPIENT_INFO = ^CMSG_KEY_TRANS_RECIPIENT_INFO;
  6062. {$EXTERNALSYM PCMSG_KEY_TRANS_RECIPIENT_INFO}
  6063. _CMSG_KEY_TRANS_RECIPIENT_INFO = record
  6064. dwVersion: DWORD;
  6065. // Currently, only ISSUER_SERIAL_NUMBER or KEYID choices
  6066. RecipientId: CERT_ID;
  6067. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  6068. EncryptedKey: CRYPT_DATA_BLOB;
  6069. end;
  6070. {$EXTERNALSYM _CMSG_KEY_TRANS_RECIPIENT_INFO}
  6071. CMSG_KEY_TRANS_RECIPIENT_INFO = _CMSG_KEY_TRANS_RECIPIENT_INFO;
  6072. {$EXTERNALSYM CMSG_KEY_TRANS_RECIPIENT_INFO}
  6073. TCmsgKeyTransRecipientInfo = CMSG_KEY_TRANS_RECIPIENT_INFO;
  6074. PCmsgKeyTransRecipientInfo = PCMSG_KEY_TRANS_RECIPIENT_INFO;
  6075. PCMSG_RECIPIENT_ENCRYPTED_KEY_INFO = ^CMSG_RECIPIENT_ENCRYPTED_KEY_INFO;
  6076. {$EXTERNALSYM PCMSG_RECIPIENT_ENCRYPTED_KEY_INFO}
  6077. _CMSG_RECIPIENT_ENCRYPTED_KEY_INFO = record
  6078. // Currently, only ISSUER_SERIAL_NUMBER or KEYID choices
  6079. RecipientId: CERT_ID;
  6080. EncryptedKey: CRYPT_DATA_BLOB;
  6081. // The following optional fields are only applicable to KEYID choice
  6082. Date: FILETIME;
  6083. pOtherAttr: PCRYPT_ATTRIBUTE_TYPE_VALUE;
  6084. end;
  6085. {$EXTERNALSYM _CMSG_RECIPIENT_ENCRYPTED_KEY_INFO}
  6086. CMSG_RECIPIENT_ENCRYPTED_KEY_INFO = _CMSG_RECIPIENT_ENCRYPTED_KEY_INFO;
  6087. {$EXTERNALSYM CMSG_RECIPIENT_ENCRYPTED_KEY_INFO}
  6088. TCmsgRecipientEncryptedKeyInfo = CMSG_RECIPIENT_ENCRYPTED_KEY_INFO;
  6089. PCmsgRecipientEncryptedKeyInfo = PCMSG_RECIPIENT_ENCRYPTED_KEY_INFO;
  6090. PCMSG_KEY_AGREE_RECIPIENT_INFO = ^CMSG_KEY_AGREE_RECIPIENT_INFO;
  6091. {$EXTERNALSYM PCMSG_KEY_AGREE_RECIPIENT_INFO}
  6092. _CMSG_KEY_AGREE_RECIPIENT_INFO = record
  6093. dwVersion: DWORD;
  6094. dwOriginatorChoice: DWORD;
  6095. Union: record
  6096. case Integer of
  6097. // CMSG_KEY_AGREE_ORIGINATOR_CERT
  6098. 0: (OriginatorCertId: CERT_ID);
  6099. // CMSG_KEY_AGREE_ORIGINATOR_PUBLIC_KEY
  6100. 1: (OriginatorPublicKeyInfo: CERT_PUBLIC_KEY_INFO);
  6101. end;
  6102. UserKeyingMaterial: CRYPT_DATA_BLOB;
  6103. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  6104. cRecipientEncryptedKeys: DWORD;
  6105. rgpRecipientEncryptedKeys: PCMSG_RECIPIENT_ENCRYPTED_KEY_INFO;
  6106. end;
  6107. {$EXTERNALSYM _CMSG_KEY_AGREE_RECIPIENT_INFO}
  6108. CMSG_KEY_AGREE_RECIPIENT_INFO = _CMSG_KEY_AGREE_RECIPIENT_INFO;
  6109. {$EXTERNALSYM CMSG_KEY_AGREE_RECIPIENT_INFO}
  6110. TCmsgKeyAgreeRecipientInfo = CMSG_KEY_AGREE_RECIPIENT_INFO;
  6111. PCmsgKeyAgreeRecipientInfo = PCMSG_KEY_AGREE_RECIPIENT_INFO;
  6112. const
  6113. CMSG_KEY_AGREE_ORIGINATOR_CERT = 1;
  6114. {$EXTERNALSYM CMSG_KEY_AGREE_ORIGINATOR_CERT}
  6115. CMSG_KEY_AGREE_ORIGINATOR_PUBLIC_KEY = 2;
  6116. {$EXTERNALSYM CMSG_KEY_AGREE_ORIGINATOR_PUBLIC_KEY}
  6117. type
  6118. PCMSG_MAIL_LIST_RECIPIENT_INFO = ^CMSG_MAIL_LIST_RECIPIENT_INFO;
  6119. {$EXTERNALSYM PCMSG_MAIL_LIST_RECIPIENT_INFO}
  6120. _CMSG_MAIL_LIST_RECIPIENT_INFO = record
  6121. dwVersion: DWORD;
  6122. KeyId: CRYPT_DATA_BLOB;
  6123. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  6124. EncryptedKey: CRYPT_DATA_BLOB;
  6125. // The following fields are optional
  6126. Date: FILETIME;
  6127. pOtherAttr: PCRYPT_ATTRIBUTE_TYPE_VALUE;
  6128. end;
  6129. {$EXTERNALSYM _CMSG_MAIL_LIST_RECIPIENT_INFO}
  6130. CMSG_MAIL_LIST_RECIPIENT_INFO = _CMSG_MAIL_LIST_RECIPIENT_INFO;
  6131. {$EXTERNALSYM CMSG_MAIL_LIST_RECIPIENT_INFO}
  6132. TCmsgMailListRecipientInfo = CMSG_MAIL_LIST_RECIPIENT_INFO;
  6133. PCmsgMailListRecipientInfo = PCMSG_MAIL_LIST_RECIPIENT_INFO;
  6134. PCMSG_CMS_RECIPIENT_INFO = ^CMSG_CMS_RECIPIENT_INFO;
  6135. {$EXTERNALSYM PCMSG_CMS_RECIPIENT_INFO}
  6136. _CMSG_CMS_RECIPIENT_INFO = record
  6137. dwRecipientChoice: DWORD;
  6138. case Integer of
  6139. // CMSG_KEY_TRANS_RECIPIENT
  6140. 0: (pKeyTrans: PCMSG_KEY_TRANS_RECIPIENT_INFO);
  6141. // CMSG_KEY_AGREE_RECIPIENT
  6142. 1: (pKeyAgree: PCMSG_KEY_AGREE_RECIPIENT_INFO);
  6143. // CMSG_MAIL_LIST_RECIPIENT
  6144. 2: (pMailList: PCMSG_MAIL_LIST_RECIPIENT_INFO);
  6145. end;
  6146. {$EXTERNALSYM _CMSG_CMS_RECIPIENT_INFO}
  6147. CMSG_CMS_RECIPIENT_INFO = _CMSG_CMS_RECIPIENT_INFO;
  6148. {$EXTERNALSYM CMSG_CMS_RECIPIENT_INFO}
  6149. TCmsgCmsRecipientInfo = CMSG_CMS_RECIPIENT_INFO;
  6150. PCmsgCmsRecipientInfo = PCMSG_CMS_RECIPIENT_INFO;
  6151. // dwVersion numbers for the KeyTrans, KeyAgree and MailList recipients
  6152. const
  6153. CMSG_ENVELOPED_RECIPIENT_V0 = 0;
  6154. {$EXTERNALSYM CMSG_ENVELOPED_RECIPIENT_V0}
  6155. CMSG_ENVELOPED_RECIPIENT_V2 = 2;
  6156. {$EXTERNALSYM CMSG_ENVELOPED_RECIPIENT_V2}
  6157. CMSG_ENVELOPED_RECIPIENT_V3 = 3;
  6158. {$EXTERNALSYM CMSG_ENVELOPED_RECIPIENT_V3}
  6159. CMSG_ENVELOPED_RECIPIENT_V4 = 4;
  6160. {$EXTERNALSYM CMSG_ENVELOPED_RECIPIENT_V4}
  6161. CMSG_KEY_TRANS_PKCS_1_5_VERSION = CMSG_ENVELOPED_RECIPIENT_V0;
  6162. {$EXTERNALSYM CMSG_KEY_TRANS_PKCS_1_5_VERSION}
  6163. CMSG_KEY_TRANS_CMS_VERSION = CMSG_ENVELOPED_RECIPIENT_V2;
  6164. {$EXTERNALSYM CMSG_KEY_TRANS_CMS_VERSION}
  6165. CMSG_KEY_AGREE_VERSION = CMSG_ENVELOPED_RECIPIENT_V3;
  6166. {$EXTERNALSYM CMSG_KEY_AGREE_VERSION}
  6167. CMSG_MAIL_LIST_VERSION = CMSG_ENVELOPED_RECIPIENT_V4;
  6168. {$EXTERNALSYM CMSG_MAIL_LIST_VERSION}
  6169. //+-------------------------------------------------------------------------
  6170. // CMSG_UNPROTECTED_ATTR_PARAM
  6171. //
  6172. // The unprotected attributes in the envelped message.
  6173. //
  6174. // pvData points to a CMSG_ATTR struct.
  6175. //--------------------------------------------------------------------------
  6176. //+-------------------------------------------------------------------------
  6177. // Perform a special "control" function after the final CryptMsgUpdate of a
  6178. // encoded/decoded cryptographic message.
  6179. //
  6180. // The dwCtrlType parameter specifies the type of operation to be performed.
  6181. //
  6182. // The pvCtrlPara definition depends on the dwCtrlType value.
  6183. //
  6184. // See below for a list of the control operations and their pvCtrlPara
  6185. // type definition.
  6186. //--------------------------------------------------------------------------
  6187. function CryptMsgControl(hCryptMsg: HCRYPTMSG; dwFlags, dwCtrlType: DWORD;
  6188. pvCtrlPara: Pointer): BOOL; stdcall;
  6189. {$EXTERNALSYM CryptMsgControl}
  6190. //+-------------------------------------------------------------------------
  6191. // Message control types
  6192. //--------------------------------------------------------------------------
  6193. const
  6194. CMSG_CTRL_VERIFY_SIGNATURE = 1;
  6195. {$EXTERNALSYM CMSG_CTRL_VERIFY_SIGNATURE}
  6196. CMSG_CTRL_DECRYPT = 2;
  6197. {$EXTERNALSYM CMSG_CTRL_DECRYPT}
  6198. CMSG_CTRL_VERIFY_HASH = 5;
  6199. {$EXTERNALSYM CMSG_CTRL_VERIFY_HASH}
  6200. CMSG_CTRL_ADD_SIGNER = 6;
  6201. {$EXTERNALSYM CMSG_CTRL_ADD_SIGNER}
  6202. CMSG_CTRL_DEL_SIGNER = 7;
  6203. {$EXTERNALSYM CMSG_CTRL_DEL_SIGNER}
  6204. CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR = 8;
  6205. {$EXTERNALSYM CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR}
  6206. CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR = 9;
  6207. {$EXTERNALSYM CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR}
  6208. CMSG_CTRL_ADD_CERT = 10;
  6209. {$EXTERNALSYM CMSG_CTRL_ADD_CERT}
  6210. CMSG_CTRL_DEL_CERT = 11;
  6211. {$EXTERNALSYM CMSG_CTRL_DEL_CERT}
  6212. CMSG_CTRL_ADD_CRL = 12;
  6213. {$EXTERNALSYM CMSG_CTRL_ADD_CRL}
  6214. CMSG_CTRL_DEL_CRL = 13;
  6215. {$EXTERNALSYM CMSG_CTRL_DEL_CRL}
  6216. CMSG_CTRL_ADD_ATTR_CERT = 14;
  6217. {$EXTERNALSYM CMSG_CTRL_ADD_ATTR_CERT}
  6218. CMSG_CTRL_DEL_ATTR_CERT = 15;
  6219. {$EXTERNALSYM CMSG_CTRL_DEL_ATTR_CERT}
  6220. CMSG_CTRL_KEY_TRANS_DECRYPT = 16;
  6221. {$EXTERNALSYM CMSG_CTRL_KEY_TRANS_DECRYPT}
  6222. CMSG_CTRL_KEY_AGREE_DECRYPT = 17;
  6223. {$EXTERNALSYM CMSG_CTRL_KEY_AGREE_DECRYPT}
  6224. CMSG_CTRL_MAIL_LIST_DECRYPT = 18;
  6225. {$EXTERNALSYM CMSG_CTRL_MAIL_LIST_DECRYPT}
  6226. CMSG_CTRL_VERIFY_SIGNATURE_EX = 19;
  6227. {$EXTERNALSYM CMSG_CTRL_VERIFY_SIGNATURE_EX}
  6228. CMSG_CTRL_ADD_CMS_SIGNER_INFO = 20;
  6229. {$EXTERNALSYM CMSG_CTRL_ADD_CMS_SIGNER_INFO}
  6230. //+-------------------------------------------------------------------------
  6231. // CMSG_CTRL_VERIFY_SIGNATURE
  6232. //
  6233. // Verify the signature of a SIGNED or SIGNED_AND_ENVELOPED
  6234. // message after it has been decoded.
  6235. //
  6236. // For a SIGNED_AND_ENVELOPED message, called after
  6237. // CryptMsgControl(CMSG_CTRL_DECRYPT), if CryptMsgOpenToDecode was called
  6238. // with a NULL pRecipientInfo.
  6239. //
  6240. // pvCtrlPara points to a CERT_INFO struct.
  6241. //
  6242. // The CERT_INFO contains the Issuer and SerialNumber identifying
  6243. // the Signer of the message. The CERT_INFO also contains the
  6244. // PublicKeyInfo
  6245. // used to verify the signature. The cryptographic provider specified
  6246. // in CryptMsgOpenToDecode is used.
  6247. //
  6248. // Note, if the message contains CMS signers identified by KEYID, then,
  6249. // the CERT_INFO's Issuer and SerialNumber is ignored and only the public
  6250. // key is used to find a signer whose signature verifies.
  6251. //
  6252. // The following CMSG_CTRL_VERIFY_SIGNATURE_EX should be used instead.
  6253. //--------------------------------------------------------------------------
  6254. //+-------------------------------------------------------------------------
  6255. // CMSG_CTRL_VERIFY_SIGNATURE_EX
  6256. //
  6257. // Verify the signature of a SIGNED message after it has been decoded.
  6258. //
  6259. // pvCtrlPara points to the following CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA.
  6260. //
  6261. // If hCryptProv is NULL, uses the cryptographic provider specified in
  6262. // CryptMsgOpenToDecode. If CryptMsgOpenToDecode's hCryptProv is also NULL,
  6263. // gets default provider according to the signer's public key OID.
  6264. //
  6265. // dwSignerIndex is the index of the signer to use to verify the signature.
  6266. //
  6267. // The signer can be a pointer to a CERT_PUBLIC_KEY_INFO, certificate
  6268. // context or a chain context.
  6269. //--------------------------------------------------------------------------
  6270. type
  6271. PCMSG_CTRL_VERIFY_SIGNATURE_EX_PARA = ^CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA;
  6272. {$EXTERNALSYM PCMSG_CTRL_VERIFY_SIGNATURE_EX_PARA}
  6273. _CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA = record
  6274. cbSize: DWORD;
  6275. hCryptProv: HCRYPTPROV;
  6276. dwSignerIndex: DWORD;
  6277. dwSignerType: DWORD;
  6278. pvSigner: Pointer;
  6279. end;
  6280. {$EXTERNALSYM _CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA}
  6281. CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA = _CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA;
  6282. {$EXTERNALSYM CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA}
  6283. TCmsgCtrlVerifySignatureExPara = CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA;
  6284. PCmsgCtrlVerifySignatureExPara = PCMSG_CTRL_VERIFY_SIGNATURE_EX_PARA;
  6285. // Signer Types
  6286. const
  6287. CMSG_VERIFY_SIGNER_PUBKEY = 1;
  6288. {$EXTERNALSYM CMSG_VERIFY_SIGNER_PUBKEY}
  6289. // pvSigner :: PCERT_PUBLIC_KEY_INFO
  6290. CMSG_VERIFY_SIGNER_CERT = 2;
  6291. {$EXTERNALSYM CMSG_VERIFY_SIGNER_CERT}
  6292. // pvSigner :: PCCERT_CONTEXT
  6293. CMSG_VERIFY_SIGNER_CHAIN = 3;
  6294. {$EXTERNALSYM CMSG_VERIFY_SIGNER_CHAIN}
  6295. // pvSigner :: PCCERT_CHAIN_CONTEXT
  6296. //+-------------------------------------------------------------------------
  6297. // CMSG_CTRL_DECRYPT
  6298. //
  6299. // Decrypt an ENVELOPED or SIGNED_AND_ENVELOPED message after it has been
  6300. // decoded.
  6301. //
  6302. // This decrypt is only applicable to key transport recipients.
  6303. //
  6304. // hCryptProv and dwKeySpec specify the private key to use. For dwKeySpec ==
  6305. // 0, defaults to AT_KEYEXCHANGE.
  6306. //
  6307. // If CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags passed
  6308. // to CryptMsgControl, then, the hCryptProv is released on the final
  6309. // CryptMsgClose. Not released if CryptMsgControl fails.
  6310. //
  6311. // dwRecipientIndex is the index of the recipient in the message associated
  6312. // with the hCryptProv's private key.
  6313. //
  6314. // The dwRecipientIndex is the index of a key transport recipient.
  6315. //
  6316. // Note, the message can only be decrypted once.
  6317. //--------------------------------------------------------------------------
  6318. type
  6319. PCMSG_CTRL_DECRYPT_PARA = ^CMSG_CTRL_DECRYPT_PARA;
  6320. {$EXTERNALSYM PCMSG_CTRL_DECRYPT_PARA}
  6321. _CMSG_CTRL_DECRYPT_PARA = record
  6322. cbSize: DWORD;
  6323. hCryptProv: HCRYPTPROV;
  6324. dwKeySpec: DWORD;
  6325. dwRecipientIndex: DWORD;
  6326. end;
  6327. {$EXTERNALSYM _CMSG_CTRL_DECRYPT_PARA}
  6328. CMSG_CTRL_DECRYPT_PARA = _CMSG_CTRL_DECRYPT_PARA;
  6329. {$EXTERNALSYM CMSG_CTRL_DECRYPT_PARA}
  6330. TCmsgCtrlDecryptPara = CMSG_CTRL_DECRYPT_PARA;
  6331. PCmsgCtrlDecryptPara = PCMSG_CTRL_DECRYPT_PARA;
  6332. //+-------------------------------------------------------------------------
  6333. // CMSG_CTRL_KEY_TRANS_DECRYPT
  6334. //
  6335. // Decrypt an ENVELOPED message after it has been decoded for a key
  6336. // transport recipient.
  6337. //
  6338. // hCryptProv and dwKeySpec specify the private key to use. For dwKeySpec ==
  6339. // 0, defaults to AT_KEYEXCHANGE.
  6340. //
  6341. // If CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags passed
  6342. // to CryptMsgControl, then, the hCryptProv is released on the final
  6343. // CryptMsgClose. Not released if CryptMsgControl fails.
  6344. //
  6345. // pKeyTrans points to the CMSG_KEY_TRANS_RECIPIENT_INFO obtained via
  6346. // CryptMsgGetParam(CMSG_CMS_RECIPIENT_INFO_PARAM)
  6347. //
  6348. // dwRecipientIndex is the index of the recipient in the message associated
  6349. // with the hCryptProv's private key.
  6350. //
  6351. // Note, the message can only be decrypted once.
  6352. //--------------------------------------------------------------------------
  6353. PCMSG_CTRL_KEY_TRANS_DECRYPT_PARA = ^CMSG_CTRL_KEY_TRANS_DECRYPT_PARA;
  6354. {$EXTERNALSYM PCMSG_CTRL_KEY_TRANS_DECRYPT_PARA}
  6355. _CMSG_CTRL_KEY_TRANS_DECRYPT_PARA = record
  6356. cbSize: DWORD;
  6357. hCryptProv: HCRYPTPROV;
  6358. dwKeySpec: DWORD;
  6359. pKeyTrans: PCMSG_KEY_TRANS_RECIPIENT_INFO;
  6360. dwRecipientIndex: DWORD;
  6361. end;
  6362. {$EXTERNALSYM _CMSG_CTRL_KEY_TRANS_DECRYPT_PARA}
  6363. CMSG_CTRL_KEY_TRANS_DECRYPT_PARA = _CMSG_CTRL_KEY_TRANS_DECRYPT_PARA;
  6364. {$EXTERNALSYM CMSG_CTRL_KEY_TRANS_DECRYPT_PARA}
  6365. TCmsgCtrlKeyTransDecryptPara = CMSG_CTRL_KEY_TRANS_DECRYPT_PARA;
  6366. PCmsgCtrlKeyTransDecryptPara = PCMSG_CTRL_KEY_TRANS_DECRYPT_PARA;
  6367. //+-------------------------------------------------------------------------
  6368. // CMSG_CTRL_KEY_AGREE_DECRYPT
  6369. //
  6370. // Decrypt an ENVELOPED message after it has been decoded for a key
  6371. // agreement recipient.
  6372. //
  6373. // hCryptProv and dwKeySpec specify the private key to use. For dwKeySpec ==
  6374. // 0, defaults to AT_KEYEXCHANGE.
  6375. //
  6376. // If CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags passed
  6377. // to CryptMsgControl, then, the hCryptProv is released on the final
  6378. // CryptMsgClose. Not released if CryptMsgControl fails.
  6379. //
  6380. // pKeyAgree points to the CMSG_KEY_AGREE_RECIPIENT_INFO obtained via
  6381. // CryptMsgGetParam(CMSG_CMS_RECIPIENT_INFO_PARAM) for dwRecipientIndex.
  6382. //
  6383. // dwRecipientIndex, dwRecipientEncryptedKeyIndex are the indices of the
  6384. // recipient's encrypted key in the message associated with the hCryptProv's
  6385. // private key.
  6386. //
  6387. // OriginatorPublicKey is the originator's public key obtained from either
  6388. // the originator's certificate or the CMSG_KEY_AGREE_RECIPIENT_INFO obtained
  6389. // via the CMSG_CMS_RECIPIENT_INFO_PARAM.
  6390. //
  6391. // Note, the message can only be decrypted once.
  6392. //--------------------------------------------------------------------------
  6393. PCMSG_CTRL_KEY_AGREE_DECRYPT_PARA = ^CMSG_CTRL_KEY_AGREE_DECRYPT_PARA;
  6394. {$EXTERNALSYM PCMSG_CTRL_KEY_AGREE_DECRYPT_PARA}
  6395. _CMSG_CTRL_KEY_AGREE_DECRYPT_PARA = record
  6396. cbSize: DWORD;
  6397. hCryptProv: HCRYPTPROV;
  6398. dwKeySpec: DWORD;
  6399. pKeyAgree: PCMSG_KEY_AGREE_RECIPIENT_INFO;
  6400. dwRecipientIndex: DWORD;
  6401. dwRecipientEncryptedKeyIndex: DWORD;
  6402. OriginatorPublicKey: CRYPT_BIT_BLOB;
  6403. end;
  6404. {$EXTERNALSYM _CMSG_CTRL_KEY_AGREE_DECRYPT_PARA}
  6405. CMSG_CTRL_KEY_AGREE_DECRYPT_PARA = _CMSG_CTRL_KEY_AGREE_DECRYPT_PARA;
  6406. {$EXTERNALSYM CMSG_CTRL_KEY_AGREE_DECRYPT_PARA}
  6407. TCmsgCtrlKeyAgreeDecryptPara = CMSG_CTRL_KEY_AGREE_DECRYPT_PARA;
  6408. PCmsgCtrlKeyAgreeDecryptPara = PCMSG_CTRL_KEY_AGREE_DECRYPT_PARA;
  6409. //+-------------------------------------------------------------------------
  6410. // CMSG_CTRL_MAIL_LIST_DECRYPT
  6411. //
  6412. // Decrypt an ENVELOPED message after it has been decoded for a mail
  6413. // list recipient.
  6414. //
  6415. // pMailList points to the CMSG_MAIL_LIST_RECIPIENT_INFO obtained via
  6416. // CryptMsgGetParam(CMSG_CMS_RECIPIENT_INFO_PARAM) for dwRecipientIndex.
  6417. //
  6418. // There is 1 choice for the KeyEncryptionKey: an already created CSP key
  6419. // handle. For the key handle choice, hCryptProv must be nonzero. This key
  6420. // handle isn't destroyed.
  6421. //
  6422. // If CMSG_CRYPT_RELEASE_CONTEXT_FLAG is set in the dwFlags passed
  6423. // to CryptMsgControl, then, the hCryptProv is released on the final
  6424. // CryptMsgClose. Not released if CryptMsgControl fails.
  6425. //
  6426. // For RC2 wrap, the effective key length is obtained from the
  6427. // KeyEncryptionAlgorithm parameters and set on the hKeyEncryptionKey before
  6428. // decrypting.
  6429. //
  6430. // Note, the message can only be decrypted once.
  6431. //--------------------------------------------------------------------------
  6432. PCMSG_CTRL_MAIL_LIST_DECRYPT_PARA = ^CMSG_CTRL_MAIL_LIST_DECRYPT_PARA;
  6433. {$EXTERNALSYM PCMSG_CTRL_MAIL_LIST_DECRYPT_PARA}
  6434. _CMSG_CTRL_MAIL_LIST_DECRYPT_PARA = record
  6435. cbSize: DWORD;
  6436. hCryptProv: HCRYPTPROV;
  6437. pMailList: PCMSG_MAIL_LIST_RECIPIENT_INFO;
  6438. dwRecipientIndex: DWORD;
  6439. dwKeyChoice: DWORD;
  6440. case Integer of
  6441. // CMSG_MAIL_LIST_HANDLE_KEY_CHOICE
  6442. 0: (hKeyEncryptionKey: HCRYPTKEY);
  6443. // Reserve space for a potential pointer choice
  6444. 1: (pvKeyEncryptionKey: Pointer);
  6445. end;
  6446. {$EXTERNALSYM _CMSG_CTRL_MAIL_LIST_DECRYPT_PARA}
  6447. CMSG_CTRL_MAIL_LIST_DECRYPT_PARA = _CMSG_CTRL_MAIL_LIST_DECRYPT_PARA;
  6448. {$EXTERNALSYM CMSG_CTRL_MAIL_LIST_DECRYPT_PARA}
  6449. TCmsgCtrlMailListDecryptPara = CMSG_CTRL_MAIL_LIST_DECRYPT_PARA;
  6450. PCmsgCtrlMailListDecryptPara = PCMSG_CTRL_MAIL_LIST_DECRYPT_PARA;
  6451. //+-------------------------------------------------------------------------
  6452. // CMSG_CTRL_VERIFY_HASH
  6453. //
  6454. // Verify the hash of a HASHED message after it has been decoded.
  6455. //
  6456. // Only the hCryptMsg parameter is used, to specify the message whose
  6457. // hash is being verified.
  6458. //--------------------------------------------------------------------------
  6459. //+-------------------------------------------------------------------------
  6460. // CMSG_CTRL_ADD_SIGNER
  6461. //
  6462. // Add a signer to a signed-data message.
  6463. //
  6464. // pvCtrlPara points to a CMSG_SIGNER_ENCODE_INFO.
  6465. //--------------------------------------------------------------------------
  6466. //+-------------------------------------------------------------------------
  6467. // CMSG_CTRL_ADD_CMS_SIGNER_INFO
  6468. //
  6469. // Add a signer to a signed-data message.
  6470. //
  6471. // Differs from the above, CMSG_CTRL_ADD_SIGNER, wherein, the signer info
  6472. // already contains the signature.
  6473. //
  6474. // pvCtrlPara points to a CMSG_CMS_SIGNER_INFO.
  6475. //--------------------------------------------------------------------------
  6476. //+-------------------------------------------------------------------------
  6477. // CMSG_CTRL_DEL_SIGNER
  6478. //
  6479. // Remove a signer from a signed-data or signed-and-enveloped-data message.
  6480. //
  6481. // pvCtrlPara points to a DWORD containing the 0-based index of the
  6482. // signer to be removed.
  6483. //--------------------------------------------------------------------------
  6484. //+-------------------------------------------------------------------------
  6485. // CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR
  6486. //
  6487. // Add an unauthenticated attribute to the SignerInfo of a signed-data or
  6488. // signed-and-enveloped-data message.
  6489. //
  6490. // The unauthenticated attribute is input in the form of an encoded blob.
  6491. //--------------------------------------------------------------------------
  6492. PCMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA = ^CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA;
  6493. {$EXTERNALSYM PCMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA}
  6494. _CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA = record
  6495. cbSize: DWORD;
  6496. dwSignerIndex: DWORD;
  6497. blob: CRYPT_DATA_BLOB;
  6498. end;
  6499. {$EXTERNALSYM _CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA}
  6500. CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA = _CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA;
  6501. {$EXTERNALSYM CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA}
  6502. TCmsgCtrlAddSignerUnauthAttrPara = CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA;
  6503. PCmsgCtrlAddSignerUnauthAttrPara = PCMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA;
  6504. //+-------------------------------------------------------------------------
  6505. // CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR
  6506. //
  6507. // Delete an unauthenticated attribute from the SignerInfo of a signed-data
  6508. // or signed-and-enveloped-data message.
  6509. //
  6510. // The unauthenticated attribute to be removed is specified by
  6511. // a 0-based index.
  6512. //--------------------------------------------------------------------------
  6513. PCMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA = ^CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA;
  6514. {$EXTERNALSYM PCMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA}
  6515. _CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA = record
  6516. cbSize: DWORD;
  6517. dwSignerIndex: DWORD;
  6518. dwUnauthAttrIndex: DWORD;
  6519. end;
  6520. {$EXTERNALSYM _CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA}
  6521. CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA = _CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA;
  6522. {$EXTERNALSYM CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA}
  6523. TCmsgCtrlDelSignerUnauthAttrPara = CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA;
  6524. PCmsgCtrlDelSignerUnauthAttrPara = PCMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA;
  6525. //+-------------------------------------------------------------------------
  6526. // CMSG_CTRL_ADD_CERT
  6527. //
  6528. // Add a certificate to a signed-data or signed-and-enveloped-data message.
  6529. //
  6530. // pvCtrlPara points to a CRYPT_DATA_BLOB containing the certificate's
  6531. // encoded bytes.
  6532. //--------------------------------------------------------------------------
  6533. //+-------------------------------------------------------------------------
  6534. // CMSG_CTRL_DEL_CERT
  6535. //
  6536. // Delete a certificate from a signed-data or signed-and-enveloped-data
  6537. // message.
  6538. //
  6539. // pvCtrlPara points to a DWORD containing the 0-based index of the
  6540. // certificate to be removed.
  6541. //--------------------------------------------------------------------------
  6542. //+-------------------------------------------------------------------------
  6543. // CMSG_CTRL_ADD_CRL
  6544. //
  6545. // Add a CRL to a signed-data or signed-and-enveloped-data message.
  6546. //
  6547. // pvCtrlPara points to a CRYPT_DATA_BLOB containing the CRL's
  6548. // encoded bytes.
  6549. //--------------------------------------------------------------------------
  6550. //+-------------------------------------------------------------------------
  6551. // CMSG_CTRL_DEL_CRL
  6552. //
  6553. // Delete a CRL from a signed-data or signed-and-enveloped-data message.
  6554. //
  6555. // pvCtrlPara points to a DWORD containing the 0-based index of the CRL
  6556. // to be removed.
  6557. //--------------------------------------------------------------------------
  6558. //+-------------------------------------------------------------------------
  6559. // CMSG_CTRL_ADD_ATTR_CERT
  6560. //
  6561. // Add an attribute certificate to a signed-data message.
  6562. //
  6563. // pvCtrlPara points to a CRYPT_DATA_BLOB containing the attribute
  6564. // certificate's encoded bytes.
  6565. //--------------------------------------------------------------------------
  6566. //+-------------------------------------------------------------------------
  6567. // CMSG_CTRL_DEL_ATTR_CERT
  6568. //
  6569. // Delete an attribute certificate from a signed-data message.
  6570. //
  6571. // pvCtrlPara points to a DWORD containing the 0-based index of the
  6572. // attribute certificate to be removed.
  6573. //--------------------------------------------------------------------------
  6574. //+-------------------------------------------------------------------------
  6575. // Verify a countersignature, at the SignerInfo level.
  6576. // ie. verify that pbSignerInfoCountersignature contains the encrypted
  6577. // hash of the encryptedDigest field of pbSignerInfo.
  6578. //
  6579. // hCryptProv is used to hash the encryptedDigest field of pbSignerInfo.
  6580. // The only fields referenced from pciCountersigner are SerialNumber, Issuer,
  6581. // and SubjectPublicKeyInfo.
  6582. //--------------------------------------------------------------------------
  6583. function CryptMsgVerifyCountersignatureEncoded(hCryptProv: HCRYPTPROV;
  6584. dwEncodingType: DWORD; pbSignerInfo: PBYTE; cbSignerInfo: DWORD;
  6585. pbSignerInfoCountersignature: PBYTE; cbSignerInfoCountersignature: DWORD;
  6586. pciCountersigner: PCERT_INFO): BOOL; stdcall;
  6587. {$EXTERNALSYM CryptMsgVerifyCountersignatureEncoded}
  6588. //+-------------------------------------------------------------------------
  6589. // Verify a countersignature, at the SignerInfo level.
  6590. // ie. verify that pbSignerInfoCountersignature contains the encrypted
  6591. // hash of the encryptedDigest field of pbSignerInfo.
  6592. //
  6593. // hCryptProv is used to hash the encryptedDigest field of pbSignerInfo.
  6594. //
  6595. // The signer can be a CERT_PUBLIC_KEY_INFO, certificate context or a
  6596. // chain context.
  6597. //--------------------------------------------------------------------------
  6598. function CryptMsgVerifyCountersignatureEncodedEx(hCryptProv: HCRYPTPROV;
  6599. dwEncodingType: DWORD; pbSignerInfo: PBYTE; cbSignerInfo: DWORD;
  6600. pbSignerInfoCountersignature: PBYTE; cbSignerInfoCountersignature: DWORD;
  6601. dwSignerType: DWORD; pvSigner: Pointer; dwFlags: DWORD; pvReserved: Pointer): BOOL; stdcall;
  6602. {$EXTERNALSYM CryptMsgVerifyCountersignatureEncodedEx}
  6603. // See CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA for dwSignerType definitions
  6604. //+-------------------------------------------------------------------------
  6605. // Countersign an already-existing signature in a message
  6606. //
  6607. // dwIndex is a zero-based index of the SignerInfo to be countersigned.
  6608. //--------------------------------------------------------------------------
  6609. function CryptMsgCountersign(hCryptMsg: HCRYPTMSG; dwIndex, cCountersigners: DWORD;
  6610. rgCountersigners: PCMSG_SIGNER_ENCODE_INFO): BOOL; stdcall;
  6611. {$EXTERNALSYM CryptMsgCountersign}
  6612. //+-------------------------------------------------------------------------
  6613. // Countersign an already-existing signature (encoded SignerInfo).
  6614. // Output an encoded SignerInfo blob, suitable for use as a countersignature
  6615. // attribute in the unauthenticated attributes of a signed-data or
  6616. // signed-and-enveloped-data message.
  6617. //--------------------------------------------------------------------------
  6618. function CryptMsgCountersignEncoded(dwEncodingType: DWORD; pbSignerInfo: PBYTE;
  6619. cbSignerInfo: DWORD; cCountersigners: DWORD; rgCountersigners: PCMSG_SIGNER_ENCODE_INFO;
  6620. pbCountersignature: PBYTE; var pcbCountersignature: DWORD): BOOL; stdcall;
  6621. {$EXTERNALSYM CryptMsgCountersignEncoded}
  6622. //+-------------------------------------------------------------------------
  6623. // CryptMsg OID installable functions
  6624. //--------------------------------------------------------------------------
  6625. type
  6626. PFN_CMSG_ALLOC = function(cb: size_t): Pointer; stdcall;
  6627. {$EXTERNALSYM PFN_CMSG_ALLOC}
  6628. PFnCMsgAlloc = PFN_CMSG_ALLOC;
  6629. PFN_CMSG_FREE = procedure(pv: Pointer); stdcall;
  6630. {$EXTERNALSYM PFN_CMSG_FREE}
  6631. PFnCMsgFree = PFN_CMSG_FREE;
  6632. // Note, the following 3 installable functions are obsolete and have been
  6633. // replaced with GenContentEncryptKey, ExportKeyTrans, ExportKeyAgree,
  6634. // ExportMailList, ImportKeyTrans, ImportKeyAgree and ImportMailList
  6635. // installable functions.
  6636. // If *phCryptProv is NULL upon entry, then, if supported, the installable
  6637. // function should acquire a default provider and return. Note, its up
  6638. // to the installable function to release at process detach.
  6639. //
  6640. // If paiEncrypt->Parameters.cbData is 0, then, the callback may optionally
  6641. // return default encoded parameters in *ppbEncryptParameters and
  6642. // *pcbEncryptParameters. pfnAlloc must be called for the allocation.
  6643. const
  6644. CMSG_OID_GEN_ENCRYPT_KEY_FUNC = 'CryptMsgDllGenEncryptKey';
  6645. {$EXTERNALSYM CMSG_OID_GEN_ENCRYPT_KEY_FUNC}
  6646. type
  6647. PFN_CMSG_GEN_ENCRYPT_KEY = function(phCryptProv: PHCRYPTPROV;
  6648. paiEncrypt: PCRYPT_ALGORITHM_IDENTIFIER; pvEncryptAuxInfo: PVOID;
  6649. pPublicKeyInfo: PCERT_PUBLIC_KEY_INFO; pfnAlloc: PFN_CMSG_ALLOC;
  6650. var phEncryptKey: HCRYPTKEY; var ppbEncryptParameters: PBYTE;
  6651. pcbEncryptParameters: PDWORD): BOOL; stdcall;
  6652. {$EXTERNALSYM PFN_CMSG_GEN_ENCRYPT_KEY}
  6653. PfnCmsgGenEncryptKey = PFN_CMSG_GEN_ENCRYPT_KEY;
  6654. const
  6655. CMSG_OID_EXPORT_ENCRYPT_KEY_FUNC = 'CryptMsgDllExportEncryptKey';
  6656. {$EXTERNALSYM CMSG_OID_EXPORT_ENCRYPT_KEY_FUNC}
  6657. type
  6658. PFN_CMSG_EXPORT_ENCRYPT_KEY = function(hCryptProv: HCRYPTPROV;
  6659. hEncryptKey: HCRYPTKEY; pPublicKeyInfo: PCERT_PUBLIC_KEY_INFO;
  6660. pbData: PBYTE; var pcbData: DWORD): BOOL; stdcall;
  6661. {$EXTERNALSYM PFN_CMSG_EXPORT_ENCRYPT_KEY}
  6662. PfnCmsgExportEncryptKey = PFN_CMSG_EXPORT_ENCRYPT_KEY;
  6663. const
  6664. CMSG_OID_IMPORT_ENCRYPT_KEY_FUNC = 'CryptMsgDllImportEncryptKey';
  6665. {$EXTERNALSYM CMSG_OID_IMPORT_ENCRYPT_KEY_FUNC}
  6666. type
  6667. PFN_CMSG_IMPORT_ENCRYPT_KEY = function(hCryptProv: HCRYPTPROV;
  6668. dwKeySpec: DWORD; paiEncrypt: PCRYPT_ALGORITHM_IDENTIFIER;
  6669. paiPubKey: PCRYPT_ALGORITHM_IDENTIFIER; pbEncodedKey: PBYTE;
  6670. cbEncodedKey: DWORD; var phEncryptKey: HCRYPTKEY): BOOL; stdcall;
  6671. {$EXTERNALSYM PFN_CMSG_IMPORT_ENCRYPT_KEY}
  6672. PfnCmsgImportEncryptKey = PFN_CMSG_IMPORT_ENCRYPT_KEY;
  6673. // To get the default installable function for GenContentEncryptKey,
  6674. // ExportKeyTrans, ExportKeyAgree, ExportMailList, ImportKeyTrans,
  6675. // ImportKeyAgree or ImportMailList call CryptGetOIDFunctionAddress()
  6676. // with the pszOID argument set to the following constant. dwEncodingType
  6677. // should be set to CRYPT_ASN_ENCODING or X509_ASN_ENCODING.
  6678. const
  6679. CMSG_DEFAULT_INSTALLABLE_FUNC_OID = LPCSTR(1);
  6680. {$EXTERNALSYM CMSG_DEFAULT_INSTALLABLE_FUNC_OID}
  6681. //+-------------------------------------------------------------------------
  6682. // Content Encrypt Info
  6683. //
  6684. // The following data structure contains the information shared between
  6685. // the GenContentEncryptKey and the ExportKeyTrans, ExportKeyAgree and
  6686. // ExportMailList installable functions.
  6687. //--------------------------------------------------------------------------
  6688. type
  6689. PCMSG_CONTENT_ENCRYPT_INFO = ^CMSG_CONTENT_ENCRYPT_INFO;
  6690. {$EXTERNALSYM PCMSG_CONTENT_ENCRYPT_INFO}
  6691. _CMSG_CONTENT_ENCRYPT_INFO = record
  6692. cbSize: DWORD;
  6693. hCryptProv: HCRYPTPROV;
  6694. ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  6695. pvEncryptionAuxInfo: Pointer;
  6696. cRecipients: DWORD;
  6697. rgCmsRecipients: PCMSG_RECIPIENT_ENCODE_INFO;
  6698. pfnAlloc: PFN_CMSG_ALLOC;
  6699. pfnFree: PFN_CMSG_FREE;
  6700. dwEncryptFlags: DWORD;
  6701. hContentEncryptKey: HCRYPTKEY;
  6702. dwFlags: DWORD;
  6703. end;
  6704. {$EXTERNALSYM _CMSG_CONTENT_ENCRYPT_INFO}
  6705. CMSG_CONTENT_ENCRYPT_INFO = _CMSG_CONTENT_ENCRYPT_INFO;
  6706. {$EXTERNALSYM CMSG_CONTENT_ENCRYPT_INFO}
  6707. TCmsgContentEncryptInfo = CMSG_CONTENT_ENCRYPT_INFO;
  6708. PCmsgContentEncryptInfo = PCMSG_CONTENT_ENCRYPT_INFO;
  6709. const
  6710. CMSG_CONTENT_ENCRYPT_PAD_ENCODED_LEN_FLAG = $00000001;
  6711. {$EXTERNALSYM CMSG_CONTENT_ENCRYPT_PAD_ENCODED_LEN_FLAG}
  6712. CMSG_CONTENT_ENCRYPT_FREE_PARA_FLAG = $00000001;
  6713. {$EXTERNALSYM CMSG_CONTENT_ENCRYPT_FREE_PARA_FLAG}
  6714. CMSG_CONTENT_ENCRYPT_RELEASE_CONTEXT_FLAG = $00008000;
  6715. {$EXTERNALSYM CMSG_CONTENT_ENCRYPT_RELEASE_CONTEXT_FLAG}
  6716. //+-------------------------------------------------------------------------
  6717. // Upon input, ContentEncryptInfo has been initialized from the
  6718. // EnvelopedEncodeInfo.
  6719. //
  6720. // Note, if rgpRecipients instead of rgCmsRecipients are set in the
  6721. // EnvelopedEncodeInfo, then, the rgpRecipients have been converted
  6722. // to rgCmsRecipients in the ContentEncryptInfo.
  6723. //
  6724. // The following fields may be changed in ContentEncryptInfo:
  6725. // hContentEncryptKey
  6726. // hCryptProv
  6727. // ContentEncryptionAlgorithm.Parameters
  6728. // dwFlags
  6729. //
  6730. // All other fields in the ContentEncryptInfo are READONLY.
  6731. //
  6732. // If CMSG_CONTENT_ENCRYPT_PAD_ENCODED_LEN_FLAG is set upon entry
  6733. // in dwEncryptFlags, then, any potentially variable length encoded
  6734. // output should be padded with zeroes to always obtain the
  6735. // same maximum encoded length. This is necessary for
  6736. // CryptMsgCalculateEncodedLength() or CryptMsgOpenToEncode() with
  6737. // definite length streaming.
  6738. //
  6739. // The hContentEncryptKey must be updated.
  6740. //
  6741. // If hCryptProv is NULL upon input, then, it must be updated.
  6742. // If a HCRYPTPROV is acquired that must be released, then, the
  6743. // CMSG_CONTENT_ENCRYPT_RELEASE_CONTEXT_FLAG must be set in dwFlags.
  6744. //
  6745. // If ContentEncryptionAlgorithm.Parameters is updated, then, the
  6746. // CMSG_CONTENT_ENCRYPT_FREE_PARA_FLAG must be set in dwFlags. pfnAlloc and
  6747. // pfnFree must be used for doing the allocation.
  6748. //
  6749. // ContentEncryptionAlgorithm.pszObjId is used to get the OIDFunctionAddress.
  6750. //--------------------------------------------------------------------------
  6751. const
  6752. CMSG_OID_GEN_CONTENT_ENCRYPT_KEY_FUNC = 'CryptMsgDllGenContentEncryptKey';
  6753. {$EXTERNALSYM CMSG_OID_GEN_CONTENT_ENCRYPT_KEY_FUNC}
  6754. type
  6755. PFN_CMSG_GEN_CONTENT_ENCRYPT_KEY = function(pContentEncryptInfo: PCMSG_CONTENT_ENCRYPT_INFO;
  6756. dwFlags: DWORD; pvReserved: PPointer): BOOL; stdcall;
  6757. {$EXTERNALSYM PFN_CMSG_GEN_CONTENT_ENCRYPT_KEY}
  6758. PfnCmsgGenContentEncryptKey = PFN_CMSG_GEN_CONTENT_ENCRYPT_KEY;
  6759. //+-------------------------------------------------------------------------
  6760. // Key Transport Encrypt Info
  6761. //
  6762. // The following data structure contains the information updated by the
  6763. // ExportKeyTrans installable function.
  6764. //--------------------------------------------------------------------------
  6765. type
  6766. PCMSG_KEY_TRANS_ENCRYPT_INFO = ^CMSG_KEY_TRANS_ENCRYPT_INFO;
  6767. {$EXTERNALSYM PCMSG_KEY_TRANS_ENCRYPT_INFO}
  6768. _CMSG_KEY_TRANS_ENCRYPT_INFO = record
  6769. cbSize: DWORD;
  6770. dwRecipientIndex: DWORD;
  6771. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  6772. EncryptedKey: CRYPT_DATA_BLOB;
  6773. dwFlags: DWORD;
  6774. end;
  6775. {$EXTERNALSYM _CMSG_KEY_TRANS_ENCRYPT_INFO}
  6776. CMSG_KEY_TRANS_ENCRYPT_INFO = _CMSG_KEY_TRANS_ENCRYPT_INFO;
  6777. {$EXTERNALSYM CMSG_KEY_TRANS_ENCRYPT_INFO}
  6778. TCmsgKeyTransEncryptInfo = CMSG_KEY_TRANS_ENCRYPT_INFO;
  6779. PCmsgKeyTransEncryptInfo = PCMSG_KEY_TRANS_ENCRYPT_INFO;
  6780. const
  6781. CMSG_KEY_TRANS_ENCRYPT_FREE_PARA_FLAG = $00000001;
  6782. {$EXTERNALSYM CMSG_KEY_TRANS_ENCRYPT_FREE_PARA_FLAG}
  6783. //+-------------------------------------------------------------------------
  6784. // Upon input, KeyTransEncryptInfo has been initialized from the
  6785. // KeyTransEncodeInfo.
  6786. //
  6787. // The following fields may be changed in KeyTransEncryptInfo:
  6788. // EncryptedKey
  6789. // KeyEncryptionAlgorithm.Parameters
  6790. // dwFlags
  6791. //
  6792. // All other fields in the KeyTransEncryptInfo are READONLY.
  6793. //
  6794. // The EncryptedKey must be updated. The pfnAlloc and pfnFree specified in
  6795. // ContentEncryptInfo must be used for doing the allocation.
  6796. //
  6797. // If the KeyEncryptionAlgorithm.Parameters is updated, then, the
  6798. // CMSG_KEY_TRANS_ENCRYPT_FREE_PARA_FLAG must be set in dwFlags.
  6799. // The pfnAlloc and pfnFree specified in ContentEncryptInfo must be used
  6800. // for doing the allocation.
  6801. //
  6802. // KeyEncryptionAlgorithm.pszObjId is used to get the OIDFunctionAddress.
  6803. //--------------------------------------------------------------------------
  6804. const
  6805. CMSG_OID_EXPORT_KEY_TRANS_FUNC = 'CryptMsgDllExportKeyTrans';
  6806. {$EXTERNALSYM CMSG_OID_EXPORT_KEY_TRANS_FUNC}
  6807. type
  6808. PFN_CMSG_EXPORT_KEY_TRANS = function(pContentEncryptInfo: PCMSG_CONTENT_ENCRYPT_INFO;
  6809. pKeyTransEncodeInfo: PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO;
  6810. pKeyTransEncryptInfo: PCMSG_KEY_TRANS_ENCRYPT_INFO; dwFlags: DWORD;
  6811. pvReserved: Pointer): BOOL; stdcall;
  6812. {$EXTERNALSYM PFN_CMSG_EXPORT_KEY_TRANS}
  6813. PfnCmsgExportKeyTrans = PFN_CMSG_EXPORT_KEY_TRANS;
  6814. //+-------------------------------------------------------------------------
  6815. // Key Agree Key Encrypt Info
  6816. //
  6817. // The following data structure contains the information updated by the
  6818. // ExportKeyAgree installable function for each encrypted key agree
  6819. // recipient.
  6820. //--------------------------------------------------------------------------
  6821. type
  6822. PCMSG_KEY_AGREE_KEY_ENCRYPT_INFO = ^CMSG_KEY_AGREE_KEY_ENCRYPT_INFO;
  6823. {$EXTERNALSYM PCMSG_KEY_AGREE_KEY_ENCRYPT_INFO}
  6824. _CMSG_KEY_AGREE_KEY_ENCRYPT_INFO = record
  6825. cbSize: DWORD;
  6826. EncryptedKey: CRYPT_DATA_BLOB;
  6827. end;
  6828. {$EXTERNALSYM _CMSG_KEY_AGREE_KEY_ENCRYPT_INFO}
  6829. CMSG_KEY_AGREE_KEY_ENCRYPT_INFO = _CMSG_KEY_AGREE_KEY_ENCRYPT_INFO;
  6830. {$EXTERNALSYM CMSG_KEY_AGREE_KEY_ENCRYPT_INFO}
  6831. TCmsgKeyAgreeKeyEncryptInfo = CMSG_KEY_AGREE_KEY_ENCRYPT_INFO;
  6832. PCmsgKeyAgreeKeyEncryptInfo = PCMSG_KEY_AGREE_KEY_ENCRYPT_INFO;
  6833. PPCMSG_KEY_AGREE_KEY_ENCRYPT_INFO = ^PCMSG_KEY_AGREE_KEY_ENCRYPT_INFO;
  6834. {$NODEFINE PPCMSG_KEY_AGREE_KEY_ENCRYPT_INFO}
  6835. //+-------------------------------------------------------------------------
  6836. // Key Agree Encrypt Info
  6837. //
  6838. // The following data structure contains the information applicable to
  6839. // all recipients. Its updated by the ExportKeyAgree installable function.
  6840. //--------------------------------------------------------------------------
  6841. PCMSG_KEY_AGREE_ENCRYPT_INFO = ^CMSG_KEY_AGREE_ENCRYPT_INFO;
  6842. {$EXTERNALSYM PCMSG_KEY_AGREE_ENCRYPT_INFO}
  6843. _CMSG_KEY_AGREE_ENCRYPT_INFO = record
  6844. cbSize: DWORD;
  6845. dwRecipientIndex: DWORD;
  6846. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  6847. UserKeyingMaterial: CRYPT_DATA_BLOB;
  6848. dwOriginatorChoice: DWORD;
  6849. Union: record
  6850. case Integer of
  6851. // CMSG_KEY_AGREE_ORIGINATOR_CERT
  6852. 0: (OriginatorCertId: CERT_ID);
  6853. // CMSG_KEY_AGREE_ORIGINATOR_PUBLIC_KEY
  6854. 1: (OriginatorPublicKeyInfo: CERT_PUBLIC_KEY_INFO);
  6855. end;
  6856. cKeyAgreeKeyEncryptInfo: DWORD;
  6857. rgpKeyAgreeKeyEncryptInfo: PPCMSG_KEY_AGREE_KEY_ENCRYPT_INFO;
  6858. dwFlags: DWORD;
  6859. end;
  6860. {$EXTERNALSYM _CMSG_KEY_AGREE_ENCRYPT_INFO}
  6861. CMSG_KEY_AGREE_ENCRYPT_INFO = _CMSG_KEY_AGREE_ENCRYPT_INFO;
  6862. {$EXTERNALSYM CMSG_KEY_AGREE_ENCRYPT_INFO}
  6863. TCmsgKeyAgreeEncryptInfo = CMSG_KEY_AGREE_ENCRYPT_INFO;
  6864. PCmsgKeyAgreeEncryptInfo = PCMSG_KEY_AGREE_ENCRYPT_INFO;
  6865. const
  6866. CMSG_KEY_AGREE_ENCRYPT_FREE_PARA_FLAG = $00000001;
  6867. {$EXTERNALSYM CMSG_KEY_AGREE_ENCRYPT_FREE_PARA_FLAG}
  6868. CMSG_KEY_AGREE_ENCRYPT_FREE_MATERIAL_FLAG = $00000002;
  6869. {$EXTERNALSYM CMSG_KEY_AGREE_ENCRYPT_FREE_MATERIAL_FLAG}
  6870. CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_ALG_FLAG = $00000004;
  6871. {$EXTERNALSYM CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_ALG_FLAG}
  6872. CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_PARA_FLAG = $00000008;
  6873. {$EXTERNALSYM CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_PARA_FLAG}
  6874. CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_BITS_FLAG = $00000010;
  6875. {$EXTERNALSYM CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_BITS_FLAG}
  6876. //+-------------------------------------------------------------------------
  6877. // Upon input, KeyAgreeEncryptInfo has been initialized from the
  6878. // KeyAgreeEncodeInfo.
  6879. //
  6880. // The following fields may be changed in KeyAgreeEncryptInfo:
  6881. // KeyEncryptionAlgorithm.Parameters
  6882. // UserKeyingMaterial
  6883. // dwOriginatorChoice
  6884. // OriginatorCertId
  6885. // OriginatorPublicKeyInfo
  6886. // dwFlags
  6887. //
  6888. // All other fields in the KeyAgreeEncryptInfo are READONLY.
  6889. //
  6890. // If the KeyEncryptionAlgorithm.Parameters is updated, then, the
  6891. // CMSG_KEY_AGREE_ENCRYPT_FREE_PARA_FLAG must be set in dwFlags.
  6892. // The pfnAlloc and pfnFree specified in ContentEncryptInfo must be used
  6893. // for doing the allocation.
  6894. //
  6895. // If the UserKeyingMaterial is updated, then, the
  6896. // CMSG_KEY_AGREE_ENCRYPT_FREE_MATERIAL_FLAG must be set in dwFlags.
  6897. // pfnAlloc and pfnFree must be used for doing the allocation.
  6898. //
  6899. // The dwOriginatorChoice must be updated to either
  6900. // CMSG_KEY_AGREE_ORIGINATOR_CERT or CMSG_KEY_AGREE_ORIGINATOR_PUBLIC_KEY.
  6901. //
  6902. // If the OriginatorPublicKeyInfo is updated, then, the appropriate
  6903. // CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_*_FLAG must be set in dwFlags and
  6904. // pfnAlloc and pfnFree must be used for doing the allocation.
  6905. //
  6906. // If CMSG_CONTENT_ENCRYPT_PAD_ENCODED_LEN_FLAG is set upon entry
  6907. // in pContentEncryptInfo->dwEncryptFlags, then, the OriginatorPublicKeyInfo's
  6908. // Ephemeral PublicKey should be padded with zeroes to always obtain the
  6909. // same maximum encoded length. Note, the length of the generated ephemeral Y
  6910. // public key can vary depending on the number of leading zero bits.
  6911. //
  6912. // Upon input, the array of *rgpKeyAgreeKeyEncryptInfo has been initialized.
  6913. // The EncryptedKey must be updated for each recipient key.
  6914. // The pfnAlloc and pfnFree specified in
  6915. // ContentEncryptInfo must be used for doing the allocation.
  6916. //
  6917. // KeyEncryptionAlgorithm.pszObjId is used to get the OIDFunctionAddress.
  6918. //--------------------------------------------------------------------------
  6919. const
  6920. CMSG_OID_EXPORT_KEY_AGREE_FUNC = 'CryptMsgDllExportKeyAgree';
  6921. {$EXTERNALSYM CMSG_OID_EXPORT_KEY_AGREE_FUNC}
  6922. type
  6923. PFN_CMSG_EXPORT_KEY_AGREE = function(pContentEncryptInfo: PCMSG_CONTENT_ENCRYPT_INFO;
  6924. pKeyAgreeEncodeInfo: PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO;
  6925. pKeyAgreeEncryptInfo: PCMSG_KEY_AGREE_ENCRYPT_INFO; dwFlags: DWORD;
  6926. pvReserved: Pointer): BOOL; stdcall;
  6927. {$EXTERNALSYM PFN_CMSG_EXPORT_KEY_AGREE}
  6928. PfnCmsgExportKeyAgree = PFN_CMSG_EXPORT_KEY_AGREE;
  6929. //+-------------------------------------------------------------------------
  6930. // Mail List Encrypt Info
  6931. //
  6932. // The following data structure contains the information updated by the
  6933. // ExportMailList installable function.
  6934. //--------------------------------------------------------------------------
  6935. type
  6936. PCMSG_MAIL_LIST_ENCRYPT_INFO = ^CMSG_MAIL_LIST_ENCRYPT_INFO;
  6937. {$EXTERNALSYM PCMSG_MAIL_LIST_ENCRYPT_INFO}
  6938. _CMSG_MAIL_LIST_ENCRYPT_INFO = record
  6939. cbSize: DWORD;
  6940. dwRecipientIndex: DWORD;
  6941. KeyEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  6942. EncryptedKey: CRYPT_DATA_BLOB;
  6943. dwFlags: DWORD;
  6944. end;
  6945. {$EXTERNALSYM _CMSG_MAIL_LIST_ENCRYPT_INFO}
  6946. CMSG_MAIL_LIST_ENCRYPT_INFO = _CMSG_MAIL_LIST_ENCRYPT_INFO;
  6947. {$EXTERNALSYM CMSG_MAIL_LIST_ENCRYPT_INFO}
  6948. TCmsgMailListEncryptInfo = CMSG_MAIL_LIST_ENCRYPT_INFO;
  6949. PCmsgMailListEncryptInfo = PCMSG_MAIL_LIST_ENCRYPT_INFO;
  6950. const
  6951. CMSG_MAIL_LIST_ENCRYPT_FREE_PARA_FLAG = $00000001;
  6952. {$EXTERNALSYM CMSG_MAIL_LIST_ENCRYPT_FREE_PARA_FLAG}
  6953. //+-------------------------------------------------------------------------
  6954. // Upon input, MailListEncryptInfo has been initialized from the
  6955. // MailListEncodeInfo.
  6956. //
  6957. // The following fields may be changed in MailListEncryptInfo:
  6958. // EncryptedKey
  6959. // KeyEncryptionAlgorithm.Parameters
  6960. // dwFlags
  6961. //
  6962. // All other fields in the MailListEncryptInfo are READONLY.
  6963. //
  6964. // The EncryptedKey must be updated. The pfnAlloc and pfnFree specified in
  6965. // ContentEncryptInfo must be used for doing the allocation.
  6966. //
  6967. // If the KeyEncryptionAlgorithm.Parameters is updated, then, the
  6968. // CMSG_MAIL_LIST_ENCRYPT_FREE_PARA_FLAG must be set in dwFlags.
  6969. // The pfnAlloc and pfnFree specified in ContentEncryptInfo must be used
  6970. // for doing the allocation.
  6971. //
  6972. // KeyEncryptionAlgorithm.pszObjId is used to get the OIDFunctionAddress.
  6973. //--------------------------------------------------------------------------
  6974. const
  6975. CMSG_OID_EXPORT_MAIL_LIST_FUNC = 'CryptMsgDllExportMailList';
  6976. {$EXTERNALSYM CMSG_OID_EXPORT_MAIL_LIST_FUNC}
  6977. type
  6978. PFN_CMSG_EXPORT_MAIL_LIST = function(pContentEncryptInfo: PCMSG_CONTENT_ENCRYPT_INFO;
  6979. pMailListEncodeInfo: PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO;
  6980. pMailListEncryptInfo: PCMSG_MAIL_LIST_ENCRYPT_INFO; dwFlags: DWORD;
  6981. pvReserved: Pointer): BOOL; stdcall;
  6982. {$EXTERNALSYM PFN_CMSG_EXPORT_MAIL_LIST}
  6983. PfnCmsgExportMailList = PFN_CMSG_EXPORT_MAIL_LIST;
  6984. //+-------------------------------------------------------------------------
  6985. // OID Installable functions for importing an encoded and encrypted content
  6986. // encryption key.
  6987. //
  6988. // There's a different installable function for each CMS Recipient choice:
  6989. // ImportKeyTrans
  6990. // ImportKeyAgree
  6991. // ImportMailList
  6992. //
  6993. // Iterates through the following OIDs to get the OID installable function:
  6994. // KeyEncryptionOID!ContentEncryptionOID
  6995. // KeyEncryptionOID
  6996. // ContentEncryptionOID
  6997. //
  6998. // If the OID installable function doesn't support the specified
  6999. // KeyEncryption and ContentEncryption OIDs, then, return FALSE with
  7000. // LastError set to E_NOTIMPL.
  7001. //--------------------------------------------------------------------------
  7002. const
  7003. CMSG_OID_IMPORT_KEY_TRANS_FUNC = 'CryptMsgDllImportKeyTrans';
  7004. {$EXTERNALSYM CMSG_OID_IMPORT_KEY_TRANS_FUNC}
  7005. type
  7006. PFN_CMSG_IMPORT_KEY_TRANS = function(pContentEncryptionAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER;
  7007. pKeyTransDecryptPara: PCMSG_CTRL_KEY_TRANS_DECRYPT_PARA; dwFlags: DWORD;
  7008. pvReserved: Pointer; var phContentEncryptKey: HCRYPTKEY): BOOL; stdcall;
  7009. {$EXTERNALSYM PFN_CMSG_IMPORT_KEY_TRANS}
  7010. PfnCmsgImportKeyTrans = PFN_CMSG_IMPORT_KEY_TRANS;
  7011. const
  7012. CMSG_OID_IMPORT_KEY_AGREE_FUNC = 'CryptMsgDllImportKeyAgree';
  7013. {$EXTERNALSYM CMSG_OID_IMPORT_KEY_AGREE_FUNC}
  7014. type
  7015. PFN_CMSG_IMPORT_KEY_AGREE = function(pContentEncryptionAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER;
  7016. pKeyAgreeDecryptPara: PCMSG_CTRL_KEY_AGREE_DECRYPT_PARA; dwFlags: DWORD;
  7017. pvReserved: Pointer; var phContentEncryptKey: HCRYPTKEY): BOOL; stdcall;
  7018. {$EXTERNALSYM PFN_CMSG_IMPORT_KEY_AGREE}
  7019. PfnCmsgImportKeyAgree = PFN_CMSG_IMPORT_KEY_AGREE;
  7020. const
  7021. CMSG_OID_IMPORT_MAIL_LIST_FUNC = 'CryptMsgDllImportMailList';
  7022. {$EXTERNALSYM CMSG_OID_IMPORT_MAIL_LIST_FUNC}
  7023. type
  7024. PFN_CMSG_IMPORT_MAIL_LIST = function(pContentEncryptionAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER;
  7025. pMailListDecryptPara: PCMSG_CTRL_MAIL_LIST_DECRYPT_PARA; dwFlags: DWORD;
  7026. pvReserved: Pointer; var phContentEncryptKey: HCRYPTKEY): BOOL; stdcall;
  7027. {$EXTERNALSYM PFN_CMSG_IMPORT_MAIL_LIST}
  7028. PfnCmsgImportMailList = PFN_CMSG_IMPORT_MAIL_LIST;
  7029. //+=========================================================================
  7030. // Certificate Store Data Structures and APIs
  7031. //==========================================================================
  7032. //+-------------------------------------------------------------------------
  7033. // In its most basic implementation, a cert store is simply a
  7034. // collection of certificates and/or CRLs. This is the case when
  7035. // a cert store is opened with all of its certificates and CRLs
  7036. // coming from a PKCS #7 encoded cryptographic message.
  7037. //
  7038. // Nonetheless, all cert stores have the following properties:
  7039. // - A public key may have more than one certificate in the store.
  7040. // For example, a private/public key used for signing may have a
  7041. // certificate issued for VISA and another issued for
  7042. // Mastercard. Also, when a certificate is renewed there might
  7043. // be more than one certificate with the same subject and
  7044. // issuer.
  7045. // - However, each certificate in the store is uniquely
  7046. // identified by its Issuer and SerialNumber.
  7047. // - There's an issuer of subject certificate relationship. A
  7048. // certificate's issuer is found by doing a match of
  7049. // pSubjectCert->Issuer with pIssuerCert->Subject.
  7050. // The relationship is verified by using
  7051. // the issuer's public key to verify the subject certificate's
  7052. // signature. Note, there might be X.509 v3 extensions
  7053. // to assist in finding the issuer certificate.
  7054. // - Since issuer certificates might be renewed, a subject
  7055. // certificate might have more than one issuer certificate.
  7056. // - There's an issuer of CRL relationship. An
  7057. // issuer's CRL is found by doing a match of
  7058. // pIssuerCert->Subject with pCrl->Issuer.
  7059. // The relationship is verified by using
  7060. // the issuer's public key to verify the CRL's
  7061. // signature. Note, there might be X.509 v3 extensions
  7062. // to assist in finding the CRL.
  7063. // - Since some issuers might support the X.509 v3 delta CRL
  7064. // extensions, an issuer might have more than one CRL.
  7065. // - The store shouldn't have any redundant certificates or
  7066. // CRLs. There shouldn't be two certificates with the same
  7067. // Issuer and SerialNumber. There shouldn't be two CRLs with
  7068. // the same Issuer, ThisUpdate and NextUpdate.
  7069. // - The store has NO policy or trust information. No
  7070. // certificates are tagged as being "root". Its up to
  7071. // the application to maintain a list of CertIds (Issuer +
  7072. // SerialNumber) for certificates it trusts.
  7073. // - The store might contain bad certificates and/or CRLs.
  7074. // The issuer's signature of a subject certificate or CRL may
  7075. // not verify. Certificates or CRLs may not satisfy their
  7076. // time validity requirements. Certificates may be
  7077. // revoked.
  7078. //
  7079. // In addition to the certificates and CRLs, properties can be
  7080. // stored. There are two predefined property IDs for a user
  7081. // certificate: CERT_KEY_PROV_HANDLE_PROP_ID and
  7082. // CERT_KEY_PROV_INFO_PROP_ID. The CERT_KEY_PROV_HANDLE_PROP_ID
  7083. // is a HCRYPTPROV handle to the private key assoicated
  7084. // with the certificate. The CERT_KEY_PROV_INFO_PROP_ID contains
  7085. // information to be used to call
  7086. // CryptAcquireContext and CryptSetProvParam to get a handle
  7087. // to the private key associated with the certificate.
  7088. //
  7089. // There exists two more predefined property IDs for certificates
  7090. // and CRLs, CERT_SHA1_HASH_PROP_ID and CERT_MD5_HASH_PROP_ID.
  7091. // If these properties don't already exist, then, a hash of the
  7092. // content is computed. (CERT_HASH_PROP_ID maps to the default
  7093. // hash algorithm, currently, CERT_SHA1_HASH_PROP_ID).
  7094. //
  7095. // There are additional APIs for creating certificate and CRL
  7096. // contexts not in a store (CertCreateCertificateContext and
  7097. // CertCreateCRLContext).
  7098. //
  7099. //--------------------------------------------------------------------------
  7100. type
  7101. HCERTSTORE = Pointer;
  7102. {$EXTERNALSYM HCERTSTORE}
  7103. PHCERTSTORE = ^HCERTSTORE;
  7104. {$NODEFINE PHCERTSTORE}
  7105. //+-------------------------------------------------------------------------
  7106. // Certificate context.
  7107. //
  7108. // A certificate context contains both the encoded and decoded representation
  7109. // of a certificate. A certificate context returned by a cert store function
  7110. // must be freed by calling the CertFreeCertificateContext function. The
  7111. // CertDuplicateCertificateContext function can be called to make a duplicate
  7112. // copy (which also must be freed by calling CertFreeCertificateContext).
  7113. //--------------------------------------------------------------------------
  7114. PCERT_CONTEXT = ^CERT_CONTEXT;
  7115. {$EXTERNALSYM CERT_CONTEXT}
  7116. _CERT_CONTEXT = record
  7117. dwCertEncodingType: DWORD;
  7118. pbCertEncoded: LPBYTE;
  7119. cbCertEncoded: DWORD;
  7120. pCertInfo: PCERT_INFO;
  7121. hCertStore: HCERTSTORE;
  7122. end;
  7123. {$EXTERNALSYM _CERT_CONTEXT}
  7124. CERT_CONTEXT = _CERT_CONTEXT;
  7125. {$EXTERNALSYM CERT_CONTEXT}
  7126. TCertContext = CERT_CONTEXT;
  7127. PCertContext = PCERT_CONTEXT;
  7128. PCCERT_CONTEXT = PCERT_CONTEXT;
  7129. {$EXTERNALSYM PCCERT_CONTEXT}
  7130. PPCCERT_CONTEXT = ^PCCERT_CONTEXT;
  7131. {$NODEFINE PCCERT_CONTEXT}
  7132. //+-------------------------------------------------------------------------
  7133. // CRL context.
  7134. //
  7135. // A CRL context contains both the encoded and decoded representation
  7136. // of a CRL. A CRL context returned by a cert store function
  7137. // must be freed by calling the CertFreeCRLContext function. The
  7138. // CertDuplicateCRLContext function can be called to make a duplicate
  7139. // copy (which also must be freed by calling CertFreeCRLContext).
  7140. //--------------------------------------------------------------------------
  7141. PCRL_CONTEXT = ^CRL_CONTEXT;
  7142. {$EXTERNALSYM PCRL_CONTEXT}
  7143. _CRL_CONTEXT = record
  7144. dwCertEncodingType: DWORD;
  7145. pbCrlEncoded: LPBYTE;
  7146. cbCrlEncoded: DWORD;
  7147. pCrlInfo: PCRL_INFO;
  7148. hCertStore: HCERTSTORE;
  7149. end;
  7150. {$EXTERNALSYM _CRL_CONTEXT}
  7151. CRL_CONTEXT = _CRL_CONTEXT;
  7152. {$EXTERNALSYM CRL_CONTEXT}
  7153. TCrlContext = CRL_CONTEXT;
  7154. PCrlContext = PCRL_CONTEXT;
  7155. PCCRL_CONTEXT = PCRL_CONTEXT;
  7156. {$EXTERNALSYM PCCRL_CONTEXT}
  7157. PPCCRL_CONTEXT = ^PCCRL_CONTEXT;
  7158. {$NODEFINE PPCCRL_CONTEXT}
  7159. //+-------------------------------------------------------------------------
  7160. // Certificate Trust List (CTL) context.
  7161. //
  7162. // A CTL context contains both the encoded and decoded representation
  7163. // of a CTL. Also contains an opened HCRYPTMSG handle to the decoded
  7164. // cryptographic signed message containing the CTL_INFO as its inner content.
  7165. // pbCtlContent is the encoded inner content of the signed message.
  7166. //
  7167. // The CryptMsg APIs can be used to extract additional signer information.
  7168. //--------------------------------------------------------------------------
  7169. PCTL_CONTEXT = ^CTL_CONTEXT;
  7170. {$EXTERNALSYM PCTL_CONTEXT}
  7171. _CTL_CONTEXT = record
  7172. dwMsgAndCertEncodingType: DWORD;
  7173. pbCtlEncoded: LPBYTE;
  7174. cbCtlEncoded: DWORD;
  7175. pCtlInfo: PCTL_INFO;
  7176. hCertStore: HCERTSTORE;
  7177. hCryptMsg: HCRYPTMSG;
  7178. pbCtlContent: LPBYTE;
  7179. cbCtlContent: DWORD;
  7180. end;
  7181. {$EXTERNALSYM _CTL_CONTEXT}
  7182. CTL_CONTEXT = _CTL_CONTEXT;
  7183. {$EXTERNALSYM CTL_CONTEXT}
  7184. TCtlContext = CTL_CONTEXT;
  7185. PCtlContext = PCTL_CONTEXT;
  7186. PCCTL_CONTEXT = PCTL_CONTEXT;
  7187. {$EXTERNALSYM PCCTL_CONTEXT}
  7188. PPCCTL_CONTEXT = ^PCCTL_CONTEXT;
  7189. {$EXTERNALSYM PPCCTL_CONTEXT}
  7190. //+-------------------------------------------------------------------------
  7191. // Certificate, CRL and CTL property IDs
  7192. //
  7193. // See CertSetCertificateContextProperty or CertGetCertificateContextProperty
  7194. // for usage information.
  7195. //--------------------------------------------------------------------------
  7196. const
  7197. CERT_KEY_PROV_HANDLE_PROP_ID = 1;
  7198. {$EXTERNALSYM CERT_KEY_PROV_HANDLE_PROP_ID}
  7199. CERT_KEY_PROV_INFO_PROP_ID = 2;
  7200. {$EXTERNALSYM CERT_KEY_PROV_INFO_PROP_ID}
  7201. CERT_SHA1_HASH_PROP_ID = 3;
  7202. {$EXTERNALSYM CERT_SHA1_HASH_PROP_ID}
  7203. CERT_MD5_HASH_PROP_ID = 4;
  7204. {$EXTERNALSYM CERT_MD5_HASH_PROP_ID}
  7205. CERT_HASH_PROP_ID = CERT_SHA1_HASH_PROP_ID;
  7206. {$EXTERNALSYM CERT_HASH_PROP_ID}
  7207. CERT_KEY_CONTEXT_PROP_ID = 5;
  7208. {$EXTERNALSYM CERT_KEY_CONTEXT_PROP_ID}
  7209. CERT_KEY_SPEC_PROP_ID = 6;
  7210. {$EXTERNALSYM CERT_KEY_SPEC_PROP_ID}
  7211. CERT_IE30_RESERVED_PROP_ID = 7;
  7212. {$EXTERNALSYM CERT_IE30_RESERVED_PROP_ID}
  7213. CERT_PUBKEY_HASH_RESERVED_PROP_ID = 8;
  7214. {$EXTERNALSYM CERT_PUBKEY_HASH_RESERVED_PROP_ID}
  7215. CERT_ENHKEY_USAGE_PROP_ID = 9;
  7216. {$EXTERNALSYM CERT_ENHKEY_USAGE_PROP_ID}
  7217. CERT_CTL_USAGE_PROP_ID = CERT_ENHKEY_USAGE_PROP_ID;
  7218. {$EXTERNALSYM CERT_CTL_USAGE_PROP_ID}
  7219. CERT_NEXT_UPDATE_LOCATION_PROP_ID = 10;
  7220. {$EXTERNALSYM CERT_NEXT_UPDATE_LOCATION_PROP_ID}
  7221. CERT_FRIENDLY_NAME_PROP_ID = 11;
  7222. {$EXTERNALSYM CERT_FRIENDLY_NAME_PROP_ID}
  7223. CERT_PVK_FILE_PROP_ID = 12;
  7224. {$EXTERNALSYM CERT_PVK_FILE_PROP_ID}
  7225. CERT_DESCRIPTION_PROP_ID = 13;
  7226. {$EXTERNALSYM CERT_DESCRIPTION_PROP_ID}
  7227. CERT_ACCESS_STATE_PROP_ID = 14;
  7228. {$EXTERNALSYM CERT_ACCESS_STATE_PROP_ID}
  7229. CERT_SIGNATURE_HASH_PROP_ID = 15;
  7230. {$EXTERNALSYM CERT_SIGNATURE_HASH_PROP_ID}
  7231. CERT_SMART_CARD_DATA_PROP_ID = 16;
  7232. {$EXTERNALSYM CERT_SMART_CARD_DATA_PROP_ID}
  7233. CERT_EFS_PROP_ID = 17;
  7234. {$EXTERNALSYM CERT_EFS_PROP_ID}
  7235. CERT_FORTEZZA_DATA_PROP_ID = 18;
  7236. {$EXTERNALSYM CERT_FORTEZZA_DATA_PROP_ID}
  7237. CERT_ARCHIVED_PROP_ID = 19;
  7238. {$EXTERNALSYM CERT_ARCHIVED_PROP_ID}
  7239. CERT_KEY_IDENTIFIER_PROP_ID = 20;
  7240. {$EXTERNALSYM CERT_KEY_IDENTIFIER_PROP_ID}
  7241. CERT_AUTO_ENROLL_PROP_ID = 21;
  7242. {$EXTERNALSYM CERT_AUTO_ENROLL_PROP_ID}
  7243. CERT_PUBKEY_ALG_PARA_PROP_ID = 22;
  7244. {$EXTERNALSYM CERT_PUBKEY_ALG_PARA_PROP_ID}
  7245. CERT_FIRST_RESERVED_PROP_ID = 23;
  7246. {$EXTERNALSYM CERT_FIRST_RESERVED_PROP_ID}
  7247. // Note, 32 - 35 are reserved for the CERT, CRL, CTL and KeyId file element IDs.
  7248. CERT_LAST_RESERVED_PROP_ID = $00007FFF;
  7249. {$EXTERNALSYM CERT_LAST_RESERVED_PROP_ID}
  7250. CERT_FIRST_USER_PROP_ID = $00008000;
  7251. {$EXTERNALSYM CERT_FIRST_USER_PROP_ID}
  7252. CERT_LAST_USER_PROP_ID = $0000FFFF;
  7253. {$EXTERNALSYM CERT_LAST_USER_PROP_ID}
  7254. function IS_CERT_HASH_PROP_ID(X: DWORD): Boolean;
  7255. {$EXTERNALSYM IS_CERT_HASH_PROP_ID}
  7256. //+-------------------------------------------------------------------------
  7257. // Access State flags returned by CERT_ACCESS_STATE_PROP_ID. Note,
  7258. // CERT_ACCESS_PROP_ID is read only.
  7259. //--------------------------------------------------------------------------
  7260. // Set if context property writes are persisted. For instance, not set for
  7261. // memory store contexts. Set for registry based stores opened as read or write.
  7262. // Not set for registry based stores opened as read only.
  7263. const
  7264. CERT_ACCESS_STATE_WRITE_PERSIST_FLAG = $1;
  7265. {$EXTERNALSYM CERT_ACCESS_STATE_WRITE_PERSIST_FLAG}
  7266. // Set if context resides in a SYSTEM or SYSTEM_REGISTRY store.
  7267. CERT_ACCESS_STATE_SYSTEM_STORE_FLAG = $2;
  7268. {$EXTERNALSYM CERT_ACCESS_STATE_SYSTEM_STORE_FLAG}
  7269. //+-------------------------------------------------------------------------
  7270. // Cryptographic Key Provider Information
  7271. //
  7272. // CRYPT_KEY_PROV_INFO defines the CERT_KEY_PROV_INFO_PROP_ID's pvData.
  7273. //
  7274. // The CRYPT_KEY_PROV_INFO fields are passed to CryptAcquireContext
  7275. // to get a HCRYPTPROV handle. The optional CRYPT_KEY_PROV_PARAM fields are
  7276. // passed to CryptSetProvParam to further initialize the provider.
  7277. //
  7278. // The dwKeySpec field identifies the private key to use from the container
  7279. // For example, AT_KEYEXCHANGE or AT_SIGNATURE.
  7280. //--------------------------------------------------------------------------
  7281. type
  7282. PCRYPT_KEY_PROV_PARAM = ^CRYPT_KEY_PROV_PARAM;
  7283. {$EXTERNALSYM PCRYPT_KEY_PROV_PARAM}
  7284. _CRYPT_KEY_PROV_PARAM = record
  7285. dwParam: DWORD;
  7286. pbData: LPBYTE;
  7287. cbData: DWORD;
  7288. dwFlags: DWORD;
  7289. end;
  7290. {$EXTERNALSYM _CRYPT_KEY_PROV_PARAM}
  7291. CRYPT_KEY_PROV_PARAM = _CRYPT_KEY_PROV_PARAM;
  7292. {$EXTERNALSYM CRYPT_KEY_PROV_PARAM}
  7293. TCryptKeyProvParam = CRYPT_KEY_PROV_PARAM;
  7294. PCryptKeyProvParam = PCRYPT_KEY_PROV_PARAM;
  7295. PCRYPT_KEY_PROV_INFO = ^CRYPT_KEY_PROV_INFO;
  7296. {$EXTERNALSYM PCRYPT_KEY_PROV_INFO}
  7297. _CRYPT_KEY_PROV_INFO = record
  7298. pwszContainerName: LPWSTR;
  7299. pwszProvName: LPWSTR;
  7300. dwProvType: DWORD;
  7301. dwFlags: DWORD;
  7302. cProvParam: DWORD;
  7303. rgProvParam: PCRYPT_KEY_PROV_PARAM;
  7304. dwKeySpec: DWORD;
  7305. end;
  7306. {$EXTERNALSYM _CRYPT_KEY_PROV_INFO}
  7307. CRYPT_KEY_PROV_INFO = _CRYPT_KEY_PROV_INFO;
  7308. {$EXTERNALSYM CRYPT_KEY_PROV_INFO}
  7309. TCryptKeyProvInfo = CRYPT_KEY_PROV_INFO;
  7310. PCryptKeyProvInfo = PCRYPT_KEY_PROV_INFO;
  7311. //+-------------------------------------------------------------------------
  7312. // The following flag should be set in the above dwFlags to enable
  7313. // a CertSetCertificateContextProperty(CERT_KEY_CONTEXT_PROP_ID) after a
  7314. // CryptAcquireContext is done in the Sign or Decrypt Message functions.
  7315. //
  7316. // The following define must not collide with any of the
  7317. // CryptAcquireContext dwFlag defines.
  7318. //--------------------------------------------------------------------------
  7319. const
  7320. CERT_SET_KEY_PROV_HANDLE_PROP_ID = $00000001;
  7321. {$EXTERNALSYM CERT_SET_KEY_PROV_HANDLE_PROP_ID}
  7322. CERT_SET_KEY_CONTEXT_PROP_ID = $00000001;
  7323. {$EXTERNALSYM CERT_SET_KEY_CONTEXT_PROP_ID}
  7324. //+-------------------------------------------------------------------------
  7325. // Certificate Key Context
  7326. //
  7327. // CERT_KEY_CONTEXT defines the CERT_KEY_CONTEXT_PROP_ID's pvData.
  7328. //--------------------------------------------------------------------------
  7329. type
  7330. PCERT_KEY_CONTEXT = ^CERT_KEY_CONTEXT;
  7331. {$EXTERNALSYM PCERT_KEY_CONTEXT}
  7332. _CERT_KEY_CONTEXT = record
  7333. cbSize: DWORD; // sizeof(CERT_KEY_CONTEXT)
  7334. hCryptProv: HCRYPTPROV;
  7335. dwKeySpec: DWORD;
  7336. end;
  7337. {$EXTERNALSYM _CERT_KEY_CONTEXT}
  7338. CERT_KEY_CONTEXT = _CERT_KEY_CONTEXT;
  7339. {$EXTERNALSYM CERT_KEY_CONTEXT}
  7340. TCertKeyContext = CERT_KEY_CONTEXT;
  7341. PCertKeyContext = PCERT_KEY_CONTEXT;
  7342. //+-------------------------------------------------------------------------
  7343. // Certificate Store Provider Types
  7344. //--------------------------------------------------------------------------
  7345. const
  7346. CERT_STORE_PROV_MSG = LPCSTR(1);
  7347. {$EXTERNALSYM CERT_STORE_PROV_MSG}
  7348. CERT_STORE_PROV_MEMORY = LPCSTR(2);
  7349. {$EXTERNALSYM CERT_STORE_PROV_MEMORY}
  7350. CERT_STORE_PROV_FILE = LPCSTR(3);
  7351. {$EXTERNALSYM CERT_STORE_PROV_FILE}
  7352. CERT_STORE_PROV_REG = LPCSTR(4);
  7353. {$EXTERNALSYM CERT_STORE_PROV_REG}
  7354. CERT_STORE_PROV_PKCS7 = LPCSTR(5);
  7355. {$EXTERNALSYM CERT_STORE_PROV_PKCS7}
  7356. CERT_STORE_PROV_SERIALIZED = LPCSTR(6);
  7357. {$EXTERNALSYM CERT_STORE_PROV_SERIALIZED}
  7358. CERT_STORE_PROV_FILENAME_A = LPCSTR(7);
  7359. {$EXTERNALSYM CERT_STORE_PROV_FILENAME_A}
  7360. CERT_STORE_PROV_FILENAME_W = LPCSTR(8);
  7361. {$EXTERNALSYM CERT_STORE_PROV_FILENAME_W}
  7362. CERT_STORE_PROV_FILENAME = CERT_STORE_PROV_FILENAME_W;
  7363. {$EXTERNALSYM CERT_STORE_PROV_FILENAME}
  7364. CERT_STORE_PROV_SYSTEM_A = LPCSTR(9);
  7365. {$EXTERNALSYM CERT_STORE_PROV_SYSTEM_A}
  7366. CERT_STORE_PROV_SYSTEM_W = LPCSTR(10);
  7367. {$EXTERNALSYM CERT_STORE_PROV_SYSTEM_W}
  7368. CERT_STORE_PROV_SYSTEM = CERT_STORE_PROV_SYSTEM_W;
  7369. {$EXTERNALSYM CERT_STORE_PROV_SYSTEM}
  7370. CERT_STORE_PROV_COLLECTION = LPCSTR(11);
  7371. {$EXTERNALSYM CERT_STORE_PROV_COLLECTION}
  7372. CERT_STORE_PROV_SYSTEM_REGISTRY_A = LPCSTR(12);
  7373. {$EXTERNALSYM CERT_STORE_PROV_SYSTEM_REGISTRY_A}
  7374. CERT_STORE_PROV_SYSTEM_REGISTRY_W = LPCSTR(13);
  7375. {$EXTERNALSYM CERT_STORE_PROV_SYSTEM_REGISTRY_W}
  7376. CERT_STORE_PROV_SYSTEM_REGISTRY = CERT_STORE_PROV_SYSTEM_REGISTRY_W;
  7377. {$EXTERNALSYM CERT_STORE_PROV_SYSTEM_REGISTRY}
  7378. CERT_STORE_PROV_PHYSICAL_W = LPCSTR(14);
  7379. {$EXTERNALSYM CERT_STORE_PROV_PHYSICAL_W}
  7380. CERT_STORE_PROV_PHYSICAL = CERT_STORE_PROV_PHYSICAL_W;
  7381. {$EXTERNALSYM CERT_STORE_PROV_PHYSICAL}
  7382. CERT_STORE_PROV_SMART_CARD_W = LPCSTR(15);
  7383. {$EXTERNALSYM CERT_STORE_PROV_SMART_CARD_W}
  7384. CERT_STORE_PROV_SMART_CARD = CERT_STORE_PROV_SMART_CARD_W;
  7385. {$EXTERNALSYM CERT_STORE_PROV_SMART_CARD}
  7386. CERT_STORE_PROV_LDAP_W = LPCSTR(16);
  7387. {$EXTERNALSYM CERT_STORE_PROV_LDAP_W}
  7388. CERT_STORE_PROV_LDAP = CERT_STORE_PROV_LDAP_W;
  7389. {$EXTERNALSYM CERT_STORE_PROV_LDAP}
  7390. sz_CERT_STORE_PROV_MEMORY = 'Memory';
  7391. {$EXTERNALSYM sz_CERT_STORE_PROV_MEMORY}
  7392. sz_CERT_STORE_PROV_FILENAME_W = 'File';
  7393. {$EXTERNALSYM sz_CERT_STORE_PROV_FILENAME_W}
  7394. sz_CERT_STORE_PROV_FILENAME = sz_CERT_STORE_PROV_FILENAME_W;
  7395. {$EXTERNALSYM sz_CERT_STORE_PROV_FILENAME}
  7396. sz_CERT_STORE_PROV_SYSTEM_W = 'System';
  7397. {$EXTERNALSYM sz_CERT_STORE_PROV_SYSTEM_W}
  7398. sz_CERT_STORE_PROV_SYSTEM = sz_CERT_STORE_PROV_SYSTEM_W;
  7399. {$EXTERNALSYM sz_CERT_STORE_PROV_SYSTEM}
  7400. sz_CERT_STORE_PROV_PKCS7 = 'PKCS7';
  7401. {$EXTERNALSYM sz_CERT_STORE_PROV_PKCS7}
  7402. sz_CERT_STORE_PROV_SERIALIZED = 'Serialized';
  7403. {$EXTERNALSYM sz_CERT_STORE_PROV_SERIALIZED}
  7404. sz_CERT_STORE_PROV_COLLECTION = 'Collection';
  7405. {$EXTERNALSYM sz_CERT_STORE_PROV_COLLECTION}
  7406. sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W = 'SystemRegistry';
  7407. {$EXTERNALSYM sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W}
  7408. sz_CERT_STORE_PROV_SYSTEM_REGISTRY = sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W;
  7409. {$EXTERNALSYM sz_CERT_STORE_PROV_SYSTEM_REGISTRY}
  7410. sz_CERT_STORE_PROV_PHYSICAL_W = 'Physical';
  7411. {$EXTERNALSYM sz_CERT_STORE_PROV_PHYSICAL_W}
  7412. sz_CERT_STORE_PROV_PHYSICAL = sz_CERT_STORE_PROV_PHYSICAL_W;
  7413. {$EXTERNALSYM sz_CERT_STORE_PROV_PHYSICAL}
  7414. sz_CERT_STORE_PROV_SMART_CARD_W = 'SmartCard';
  7415. {$EXTERNALSYM sz_CERT_STORE_PROV_SMART_CARD_W}
  7416. sz_CERT_STORE_PROV_SMART_CARD = sz_CERT_STORE_PROV_SMART_CARD_W;
  7417. {$EXTERNALSYM sz_CERT_STORE_PROV_SMART_CARD}
  7418. sz_CERT_STORE_PROV_LDAP_W = 'Ldap';
  7419. {$EXTERNALSYM sz_CERT_STORE_PROV_LDAP_W}
  7420. sz_CERT_STORE_PROV_LDAP = sz_CERT_STORE_PROV_LDAP_W;
  7421. {$EXTERNALSYM sz_CERT_STORE_PROV_LDAP}
  7422. //+-------------------------------------------------------------------------
  7423. // Certificate Store verify/results flags
  7424. //--------------------------------------------------------------------------
  7425. CERT_STORE_SIGNATURE_FLAG = $00000001;
  7426. {$EXTERNALSYM CERT_STORE_SIGNATURE_FLAG}
  7427. CERT_STORE_TIME_VALIDITY_FLAG = $00000002;
  7428. {$EXTERNALSYM CERT_STORE_TIME_VALIDITY_FLAG}
  7429. CERT_STORE_REVOCATION_FLAG = $00000004;
  7430. {$EXTERNALSYM CERT_STORE_REVOCATION_FLAG}
  7431. CERT_STORE_NO_CRL_FLAG = $00010000;
  7432. {$EXTERNALSYM CERT_STORE_NO_CRL_FLAG}
  7433. CERT_STORE_NO_ISSUER_FLAG = $00020000;
  7434. {$EXTERNALSYM CERT_STORE_NO_ISSUER_FLAG}
  7435. //+-------------------------------------------------------------------------
  7436. // Certificate Store open/property flags
  7437. //--------------------------------------------------------------------------
  7438. CERT_STORE_NO_CRYPT_RELEASE_FLAG = $00000001;
  7439. {$EXTERNALSYM CERT_STORE_NO_CRYPT_RELEASE_FLAG}
  7440. CERT_STORE_SET_LOCALIZED_NAME_FLAG = $00000002;
  7441. {$EXTERNALSYM CERT_STORE_SET_LOCALIZED_NAME_FLAG}
  7442. CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG = $00000004;
  7443. {$EXTERNALSYM CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG}
  7444. CERT_STORE_DELETE_FLAG = $00000010;
  7445. {$EXTERNALSYM CERT_STORE_DELETE_FLAG}
  7446. CERT_STORE_MANIFOLD_FLAG = $00000100;
  7447. {$EXTERNALSYM CERT_STORE_MANIFOLD_FLAG}
  7448. CERT_STORE_ENUM_ARCHIVED_FLAG = $00000200;
  7449. {$EXTERNALSYM CERT_STORE_ENUM_ARCHIVED_FLAG}
  7450. CERT_STORE_UPDATE_KEYID_FLAG = $00000400;
  7451. {$EXTERNALSYM CERT_STORE_UPDATE_KEYID_FLAG}
  7452. CERT_STORE_READONLY_FLAG = $00008000;
  7453. {$EXTERNALSYM CERT_STORE_READONLY_FLAG}
  7454. CERT_STORE_OPEN_EXISTING_FLAG = $00004000;
  7455. {$EXTERNALSYM CERT_STORE_OPEN_EXISTING_FLAG}
  7456. CERT_STORE_CREATE_NEW_FLAG = $00002000;
  7457. {$EXTERNALSYM CERT_STORE_CREATE_NEW_FLAG}
  7458. CERT_STORE_MAXIMUM_ALLOWED_FLAG = $00001000;
  7459. {$EXTERNALSYM CERT_STORE_MAXIMUM_ALLOWED_FLAG}
  7460. //+-------------------------------------------------------------------------
  7461. // Certificate Store Provider flags are in the HiWord (0xFFFF0000)
  7462. //--------------------------------------------------------------------------
  7463. //+-------------------------------------------------------------------------
  7464. // Certificate System Store Flag Values
  7465. //--------------------------------------------------------------------------
  7466. // Includes flags and location
  7467. CERT_SYSTEM_STORE_MASK = DWORD($FFFF0000);
  7468. {$EXTERNALSYM CERT_SYSTEM_STORE_MASK}
  7469. // Set if pvPara points to a CERT_SYSTEM_STORE_RELOCATE_PARA structure
  7470. CERT_SYSTEM_STORE_RELOCATE_FLAG = DWORD($80000000);
  7471. {$EXTERNALSYM CERT_SYSTEM_STORE_RELOCATE_FLAG}
  7472. type
  7473. PCERT_SYSTEM_STORE_RELOCATE_PARA = ^CERT_SYSTEM_STORE_RELOCATE_PARA;
  7474. {$EXTERNALSYM PCERT_SYSTEM_STORE_RELOCATE_PARA}
  7475. _CERT_SYSTEM_STORE_RELOCATE_PARA = record
  7476. Union1: record
  7477. case Integer of
  7478. 0: (hKeyBase: HKEY);
  7479. 1: (pvBase: Pointer);
  7480. end;
  7481. case Integer of
  7482. 0: (pvSystemStore: Pointer);
  7483. 1: (pszSystemStore: LPCSTR);
  7484. 2: (pwszSystemStore: LPCWSTR);
  7485. end;
  7486. {$EXTERNALSYM _CERT_SYSTEM_STORE_RELOCATE_PARA}
  7487. CERT_SYSTEM_STORE_RELOCATE_PARA = _CERT_SYSTEM_STORE_RELOCATE_PARA;
  7488. {$EXTERNALSYM CERT_SYSTEM_STORE_RELOCATE_PARA}
  7489. TCertSystemStoreRelocatePara = CERT_SYSTEM_STORE_RELOCATE_PARA;
  7490. PCertSystemStoreRelocatePara = PCERT_SYSTEM_STORE_RELOCATE_PARA;
  7491. // By default, when the CurrentUser "Root" store is opened, any SystemRegistry
  7492. // roots not also on the protected root list are deleted from the cache before
  7493. // CertOpenStore() returns. Set the following flag to return all the roots
  7494. // in the SystemRegistry without checking the protected root list.
  7495. const
  7496. CERT_SYSTEM_STORE_UNPROTECTED_FLAG = $40000000;
  7497. {$EXTERNALSYM CERT_SYSTEM_STORE_UNPROTECTED_FLAG}
  7498. // Location of the system store:
  7499. CERT_SYSTEM_STORE_LOCATION_MASK = $00FF0000;
  7500. {$EXTERNALSYM CERT_SYSTEM_STORE_LOCATION_MASK}
  7501. CERT_SYSTEM_STORE_LOCATION_SHIFT = 16;
  7502. {$EXTERNALSYM CERT_SYSTEM_STORE_LOCATION_SHIFT}
  7503. // Registry: HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE
  7504. CERT_SYSTEM_STORE_CURRENT_USER_ID = 1;
  7505. {$EXTERNALSYM CERT_SYSTEM_STORE_CURRENT_USER_ID}
  7506. CERT_SYSTEM_STORE_LOCAL_MACHINE_ID = 2;
  7507. {$EXTERNALSYM CERT_SYSTEM_STORE_LOCAL_MACHINE_ID}
  7508. // Registry: HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Services
  7509. CERT_SYSTEM_STORE_CURRENT_SERVICE_ID = 4;
  7510. {$EXTERNALSYM CERT_SYSTEM_STORE_CURRENT_SERVICE_ID}
  7511. CERT_SYSTEM_STORE_SERVICES_ID = 5;
  7512. {$EXTERNALSYM CERT_SYSTEM_STORE_SERVICES_ID}
  7513. // Registry: HKEY_USERS
  7514. CERT_SYSTEM_STORE_USERS_ID = 6;
  7515. {$EXTERNALSYM CERT_SYSTEM_STORE_USERS_ID}
  7516. // Registry: HKEY_CURRENT_USER\Software\Policies\Microsoft\SystemCertificates
  7517. CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID = 7;
  7518. {$EXTERNALSYM CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID}
  7519. // Registry: HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\SystemCertificates
  7520. CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID = 8;
  7521. {$EXTERNALSYM CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID}
  7522. // Registry: HKEY_LOCAL_MACHINE\Software\Microsoft\EnterpriseCertificates
  7523. CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID = 9;
  7524. {$EXTERNALSYM CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID}
  7525. CERT_SYSTEM_STORE_CURRENT_USER = CERT_SYSTEM_STORE_CURRENT_USER_ID shl CERT_SYSTEM_STORE_LOCATION_SHIFT;
  7526. {$EXTERNALSYM CERT_SYSTEM_STORE_CURRENT_USER}
  7527. CERT_SYSTEM_STORE_LOCAL_MACHINE = CERT_SYSTEM_STORE_LOCAL_MACHINE_ID shl CERT_SYSTEM_STORE_LOCATION_SHIFT;
  7528. {$EXTERNALSYM CERT_SYSTEM_STORE_LOCAL_MACHINE}
  7529. CERT_SYSTEM_STORE_CURRENT_SERVICE = CERT_SYSTEM_STORE_CURRENT_SERVICE_ID shl CERT_SYSTEM_STORE_LOCATION_SHIFT;
  7530. {$EXTERNALSYM CERT_SYSTEM_STORE_CURRENT_SERVICE}
  7531. CERT_SYSTEM_STORE_SERVICES = CERT_SYSTEM_STORE_SERVICES_ID shl CERT_SYSTEM_STORE_LOCATION_SHIFT;
  7532. {$EXTERNALSYM CERT_SYSTEM_STORE_SERVICES}
  7533. CERT_SYSTEM_STORE_USERS = CERT_SYSTEM_STORE_USERS_ID shl CERT_SYSTEM_STORE_LOCATION_SHIFT;
  7534. {$EXTERNALSYM CERT_SYSTEM_STORE_USERS}
  7535. CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY = CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID shl CERT_SYSTEM_STORE_LOCATION_SHIFT;
  7536. {$EXTERNALSYM CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY}
  7537. CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY = CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID shl CERT_SYSTEM_STORE_LOCATION_SHIFT;
  7538. {$EXTERNALSYM CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY}
  7539. CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE = CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID shl CERT_SYSTEM_STORE_LOCATION_SHIFT;
  7540. {$EXTERNALSYM CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE}
  7541. //+-------------------------------------------------------------------------
  7542. // Group Policy Store Defines
  7543. //--------------------------------------------------------------------------
  7544. // Registry path to the Group Policy system stores
  7545. CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH = 'Software\Policies\Microsoft\SystemCertificates';
  7546. {$EXTERNALSYM CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH}
  7547. //+-------------------------------------------------------------------------
  7548. // EFS Defines
  7549. //--------------------------------------------------------------------------
  7550. // Registry path to the EFS EFSBlob SubKey - Value type is REG_BINARY
  7551. CERT_EFSBLOB_REGPATH = CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH + '\EFS';
  7552. {$EXTERNALSYM CERT_EFSBLOB_REGPATH}
  7553. CERT_EFSBLOB_VALUE_NAME = 'EFSBlob';
  7554. {$EXTERNALSYM CERT_EFSBLOB_VALUE_NAME}
  7555. //+-------------------------------------------------------------------------
  7556. // Protected Root Defines
  7557. //--------------------------------------------------------------------------
  7558. // Registry path to the Protected Roots Flags SubKey
  7559. CERT_PROT_ROOT_FLAGS_REGPATH = CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH + '\Root\ProtectedRoots';
  7560. {$EXTERNALSYM CERT_PROT_ROOT_FLAGS_REGPATH}
  7561. CERT_PROT_ROOT_FLAGS_VALUE_NAME = 'Flags';
  7562. {$EXTERNALSYM CERT_PROT_ROOT_FLAGS_VALUE_NAME}
  7563. // Set the following flag to inhibit the opening of the CurrentUser's
  7564. // .Default physical store when opening the CurrentUser's "Root" system store.
  7565. // The .Default physical store open's the CurrentUser SystemRegistry "Root"
  7566. // store.
  7567. CERT_PROT_ROOT_DISABLE_CURRENT_USER_FLAG = $1;
  7568. {$EXTERNALSYM CERT_PROT_ROOT_DISABLE_CURRENT_USER_FLAG}
  7569. // Set the following flag to inhibit the adding of roots from the
  7570. // CurrentUser SystemRegistry "Root" store to the protected root list
  7571. // when the "Root" store is initially protected.
  7572. CERT_PROT_ROOT_INHIBIT_ADD_AT_INIT_FLAG = $2;
  7573. {$EXTERNALSYM CERT_PROT_ROOT_INHIBIT_ADD_AT_INIT_FLAG}
  7574. // Set the following flag to inhibit the purging of protected roots from the
  7575. // CurrentUser SystemRegistry "Root" store that are
  7576. // also in the LocalMachine SystemRegistry "Root" store. Note, when not
  7577. // disabled, the purging is done silently without UI.
  7578. CERT_PROT_ROOT_INHIBIT_PURGE_LM_FLAG = $4;
  7579. {$EXTERNALSYM CERT_PROT_ROOT_INHIBIT_PURGE_LM_FLAG}
  7580. // Set the following flag to only open the .LocalMachineGroupPolicy
  7581. // physical store when opening the CurrentUser's "Root" system store.
  7582. CERT_PROT_ROOT_ONLY_LM_GPT_FLAG = $8;
  7583. {$EXTERNALSYM CERT_PROT_ROOT_ONLY_LM_GPT_FLAG}
  7584. //+-------------------------------------------------------------------------
  7585. // Certificate Registry Store Flag Values (CERT_STORE_REG)
  7586. //--------------------------------------------------------------------------
  7587. // Set this flag if the HKEY passed in pvPara points to a remote computer
  7588. // registry key.
  7589. CERT_REGISTRY_STORE_REMOTE_FLAG = $10000;
  7590. {$EXTERNALSYM CERT_REGISTRY_STORE_REMOTE_FLAG}
  7591. // Set this flag if the contexts are to be persisted as a single serialized
  7592. // store in the registry. Mainly used for stores downloaded from the GPT.
  7593. // Such as the CurrentUserGroupPolicy or LocalMachineGroupPolicy stores.
  7594. CERT_REGISTRY_STORE_SERIALIZED_FLAG = $20000;
  7595. {$EXTERNALSYM CERT_REGISTRY_STORE_SERIALIZED_FLAG}
  7596. // The following flags are for internal use. When set, the
  7597. // pvPara parameter passed to CertOpenStore is a pointer to the following
  7598. // data structure and not the HKEY. The above CERT_REGISTRY_STORE_REMOTE_FLAG
  7599. // is also set if hKeyBase was obtained via RegConnectRegistry().
  7600. CERT_REGISTRY_STORE_CLIENT_GPT_FLAG = DWORD($80000000);
  7601. {$EXTERNALSYM CERT_REGISTRY_STORE_CLIENT_GPT_FLAG}
  7602. CERT_REGISTRY_STORE_LM_GPT_FLAG = $01000000;
  7603. {$EXTERNALSYM CERT_REGISTRY_STORE_LM_GPT_FLAG}
  7604. type
  7605. PCERT_REGISTRY_STORE_CLIENT_GPT_PARA = ^CERT_REGISTRY_STORE_CLIENT_GPT_PARA;
  7606. {$EXTERNALSYM PCERT_REGISTRY_STORE_CLIENT_GPT_PARA}
  7607. _CERT_REGISTRY_STORE_CLIENT_GPT_PARA = record
  7608. hKeyBase: HKEY;
  7609. pwszRegPath: LPWSTR;
  7610. end;
  7611. {$EXTERNALSYM _CERT_REGISTRY_STORE_CLIENT_GPT_PARA}
  7612. CERT_REGISTRY_STORE_CLIENT_GPT_PARA = _CERT_REGISTRY_STORE_CLIENT_GPT_PARA;
  7613. {$EXTERNALSYM CERT_REGISTRY_STORE_CLIENT_GPT_PARA}
  7614. TCertRegistryStoreClientGptPara = CERT_REGISTRY_STORE_CLIENT_GPT_PARA;
  7615. PCertRegistryStoreClientGptPara = PCERT_REGISTRY_STORE_CLIENT_GPT_PARA;
  7616. // The following flag is for internal use. When set, the contexts are
  7617. // persisted into roaming files instead of the registry. Such as, the
  7618. // CurrentUser "My" store. When this flag is set, the following data structure
  7619. // is passed to CertOpenStore instead of HKEY.
  7620. const
  7621. CERT_REGISTRY_STORE_ROAMING_FLAG = $40000;
  7622. {$EXTERNALSYM CERT_REGISTRY_STORE_ROAMING_FLAG}
  7623. // hKey may be NULL or non-NULL. When non-NULL, existing contexts are
  7624. // moved from the registry to roaming files.
  7625. type
  7626. PCERT_REGISTRY_STORE_ROAMING_PARA = ^CERT_REGISTRY_STORE_ROAMING_PARA;
  7627. {$EXTERNALSYM PCERT_REGISTRY_STORE_ROAMING_PARA}
  7628. _CERT_REGISTRY_STORE_ROAMING_PARA = record
  7629. hKey: HKEY;
  7630. pwszStoreDirectory: LPWSTR;
  7631. end;
  7632. {$EXTERNALSYM _CERT_REGISTRY_STORE_ROAMING_PARA}
  7633. CERT_REGISTRY_STORE_ROAMING_PARA = _CERT_REGISTRY_STORE_ROAMING_PARA;
  7634. {$EXTERNALSYM CERT_REGISTRY_STORE_ROAMING_PARA}
  7635. TCertRegistryStoreRoamingPara = CERT_REGISTRY_STORE_ROAMING_PARA;
  7636. PCertRegistryStoreRoamingPara = PCERT_REGISTRY_STORE_ROAMING_PARA;
  7637. // The following flag is for internal use. When set, the "My" DWORD value
  7638. // at HKLM\Software\Microsoft\Cryptography\IEDirtyFlags is set to 0x1
  7639. // whenever a certificate is added to the registry store.
  7640. const
  7641. CERT_REGISTRY_STORE_MY_IE_DIRTY_FLAG = $80000;
  7642. {$EXTERNALSYM CERT_REGISTRY_STORE_MY_IE_DIRTY_FLAG}
  7643. // Registry path to the subkey containing the "My" DWORD value to be set
  7644. CERT_IE_DIRTY_FLAGS_REGPATH = 'Software\Microsoft\Cryptography\IEDirtyFlags';
  7645. {$EXTERNALSYM CERT_IE_DIRTY_FLAGS_REGPATH}
  7646. //+-------------------------------------------------------------------------
  7647. // Certificate File Store Flag Values for the providers:
  7648. // CERT_STORE_PROV_FILE
  7649. // CERT_STORE_PROV_FILENAME
  7650. // CERT_STORE_PROV_FILENAME_A
  7651. // CERT_STORE_PROV_FILENAME_W
  7652. // sz_CERT_STORE_PROV_FILENAME_W
  7653. //--------------------------------------------------------------------------
  7654. // Set this flag if any store changes are to be committed to the file.
  7655. // The changes are committed at CertCloseStore or by calling
  7656. // CertControlStore(CERT_STORE_CTRL_COMMIT).
  7657. //
  7658. // The open fails with E_INVALIDARG if both CERT_FILE_STORE_COMMIT_ENABLE_FLAG
  7659. // and CERT_STORE_READONLY_FLAG are set in dwFlags.
  7660. //
  7661. // For the FILENAME providers: if the file contains an X509 encoded
  7662. // certificate, the open fails with ERROR_ACCESS_DENIED.
  7663. //
  7664. // For the FILENAME providers: if CERT_STORE_CREATE_NEW_FLAG is set, the
  7665. // CreateFile uses CREATE_NEW. If CERT_STORE_OPEN_EXISTING is set, uses
  7666. // OPEN_EXISTING. Otherwise, defaults to OPEN_ALWAYS.
  7667. //
  7668. // For the FILENAME providers: the file is committed as either a PKCS7 or
  7669. // serialized store depending on the type read at open. However, if the
  7670. // file is empty then, if the filename has either a ".p7c" or ".spc"
  7671. // extension its committed as a PKCS7. Otherwise, its committed as a
  7672. // serialized store.
  7673. //
  7674. // For CERT_STORE_PROV_FILE, the file handle is duplicated. Its always
  7675. // committed as a serialized store.
  7676. //
  7677. CERT_FILE_STORE_COMMIT_ENABLE_FLAG = $10000;
  7678. {$EXTERNALSYM CERT_FILE_STORE_COMMIT_ENABLE_FLAG}
  7679. //+-------------------------------------------------------------------------
  7680. // Open the cert store using the specified store provider.
  7681. //
  7682. // If CERT_STORE_DELETE_FLAG is set, then, the store is deleted. NULL is
  7683. // returned for both success and failure. However, GetLastError() returns 0
  7684. // for success and nonzero for failure.
  7685. //
  7686. // If CERT_STORE_SET_LOCALIZED_NAME_FLAG is set, then, if supported, the
  7687. // provider sets the store's CERT_STORE_LOCALIZED_NAME_PROP_ID property.
  7688. // The store's localized name can be retrieved by calling
  7689. // CertSetStoreProperty(dwPropID = CERT_STORE_LOCALIZED_NAME_PROP_ID).
  7690. // This flag is supported by the following providers (and their sz_
  7691. // equivalent):
  7692. // CERT_STORE_PROV_FILENAME_A
  7693. // CERT_STORE_PROV_FILENAME_W
  7694. // CERT_STORE_PROV_SYSTEM_A
  7695. // CERT_STORE_PROV_SYSTEM_W
  7696. // CERT_STORE_PROV_SYSTEM_REGISTRY_A
  7697. // CERT_STORE_PROV_SYSTEM_REGISTRY_W
  7698. // CERT_STORE_PROV_PHYSICAL_W
  7699. //
  7700. // If CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG is set, then, the
  7701. // closing of the store's provider is deferred until all certificate,
  7702. // CRL and CTL contexts obtained from the store are freed. Also,
  7703. // if a non NULL HCRYPTPROV was passed, then, it will continue to be used.
  7704. // By default, the store's provider is closed on the final CertCloseStore.
  7705. // If this flag isn't set, then, any property changes made to previously
  7706. // duplicated contexts after the final CertCloseStore will not be persisted.
  7707. // By setting this flag, property changes made
  7708. // after the CertCloseStore will be persisted. Note, setting this flag
  7709. // causes extra overhead in doing context duplicates and frees.
  7710. // If CertCloseStore is called with CERT_CLOSE_STORE_FORCE_FLAG, then,
  7711. // the CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG flag is ignored.
  7712. //
  7713. // CERT_STORE_MANIFOLD_FLAG can be set to check for certificates having the
  7714. // manifold extension and archive the "older" certificates with the same
  7715. // manifold extension value. A certificate is archived by setting the
  7716. // CERT_ARCHIVED_PROP_ID.
  7717. //
  7718. // By default, contexts having the CERT_ARCHIVED_PROP_ID, are skipped
  7719. // during enumeration. CERT_STORE_ENUM_ARCHIVED_FLAG can be set to include
  7720. // archived contexts when enumerating. Note, contexts having the
  7721. // CERT_ARCHIVED_PROP_ID are still found for explicit finds, such as,
  7722. // finding a context with a specific hash or finding a certificate having
  7723. // a specific issuer and serial number.
  7724. //
  7725. // CERT_STORE_UPDATE_KEYID_FLAG can be set to also update the Key Identifier's
  7726. // CERT_KEY_PROV_INFO_PROP_ID property whenever a certificate's
  7727. // CERT_KEY_IDENTIFIER_PROP_ID or CERT_KEY_PROV_INFO_PROP_ID property is set
  7728. // and the other property already exists. If the Key Identifier's
  7729. // CERT_KEY_PROV_INFO_PROP_ID already exists, it isn't updated. Any
  7730. // errors encountered are silently ignored.
  7731. //
  7732. // By default, this flag is implicitly set for the "My\.Default" CurrentUser
  7733. // and LocalMachine physical stores.
  7734. //
  7735. // CERT_STORE_READONLY_FLAG can be set to open the store as read only.
  7736. // Otherwise, the store is opened as read/write.
  7737. //
  7738. // CERT_STORE_OPEN_EXISTING_FLAG can be set to only open an existing
  7739. // store. CERT_STORE_CREATE_NEW_FLAG can be set to create a new store and
  7740. // fail if the store already exists. Otherwise, the default is to open
  7741. // an existing store or create a new store if it doesn't already exist.
  7742. //
  7743. // hCryptProv specifies the crypto provider to use to create the hash
  7744. // properties or verify the signature of a subject certificate or CRL.
  7745. // The store doesn't need to use a private
  7746. // key. If the CERT_STORE_NO_CRYPT_RELEASE_FLAG isn't set, hCryptProv is
  7747. // CryptReleaseContext'ed on the final CertCloseStore.
  7748. //
  7749. // Note, if the open fails, hCryptProv is released if it would have been
  7750. // released when the store was closed.
  7751. //
  7752. // If hCryptProv is zero, then, the default provider and container for the
  7753. // PROV_RSA_FULL provider type is CryptAcquireContext'ed with
  7754. // CRYPT_VERIFYCONTEXT access. The CryptAcquireContext is deferred until
  7755. // the first create hash or verify signature. In addition, once acquired,
  7756. // the default provider isn't released until process exit when crypt32.dll
  7757. // is unloaded. The acquired default provider is shared across all stores
  7758. // and threads.
  7759. //
  7760. // After initializing the store's data structures and optionally acquiring a
  7761. // default crypt provider, CertOpenStore calls CryptGetOIDFunctionAddress to
  7762. // get the address of the CRYPT_OID_OPEN_STORE_PROV_FUNC specified by
  7763. // lpszStoreProvider. Since a store can contain certificates with different
  7764. // encoding types, CryptGetOIDFunctionAddress is called with dwEncodingType
  7765. // set to 0 and not the dwEncodingType passed to CertOpenStore.
  7766. // PFN_CERT_DLL_OPEN_STORE_FUNC specifies the signature of the provider's
  7767. // open function. This provider open function is called to load the
  7768. // store's certificates and CRLs. Optionally, the provider may return an
  7769. // array of functions called before a certificate or CRL is added or deleted
  7770. // or has a property that is set.
  7771. //
  7772. // Use of the dwEncodingType parameter is provider dependent. The type
  7773. // definition for pvPara also depends on the provider.
  7774. //
  7775. // Store providers are installed or registered via
  7776. // CryptInstallOIDFunctionAddress or CryptRegisterOIDFunction, where,
  7777. // dwEncodingType is 0 and pszFuncName is CRYPT_OID_OPEN_STORE_PROV_FUNC.
  7778. //
  7779. // Here's a list of the predefined provider types (implemented in crypt32.dll):
  7780. //
  7781. // CERT_STORE_PROV_MSG:
  7782. // Gets the certificates and CRLs from the specified cryptographic message.
  7783. // dwEncodingType contains the message and certificate encoding types.
  7784. // The message's handle is passed in pvPara. Given,
  7785. // HCRYPTMSG hCryptMsg; pvPara = (const void *) hCryptMsg;
  7786. //
  7787. // CERT_STORE_PROV_MEMORY
  7788. // sz_CERT_STORE_PROV_MEMORY:
  7789. // Opens a store without any initial certificates or CRLs. pvPara
  7790. // isn't used.
  7791. //
  7792. // CERT_STORE_PROV_FILE:
  7793. // Reads the certificates and CRLs from the specified file. The file's
  7794. // handle is passed in pvPara. Given,
  7795. // HANDLE hFile; pvPara = (const void *) hFile;
  7796. //
  7797. // For a successful open, the file pointer is advanced past
  7798. // the certificates and CRLs and their properties read from the file.
  7799. // Note, only expects a serialized store and not a file containing
  7800. // either a PKCS #7 signed message or a single encoded certificate.
  7801. //
  7802. // The hFile isn't closed.
  7803. //
  7804. // CERT_STORE_PROV_REG:
  7805. // Reads the certificates and CRLs from the registry. The registry's
  7806. // key handle is passed in pvPara. Given,
  7807. // HKEY hKey; pvPara = (const void *) hKey;
  7808. //
  7809. // The input hKey isn't closed by the provider. Before returning, the
  7810. // provider opens it own copy of the hKey.
  7811. //
  7812. // If CERT_STORE_READONLY_FLAG is set, then, the registry subkeys are
  7813. // RegOpenKey'ed with KEY_READ_ACCESS. Otherwise, the registry subkeys
  7814. // are RegCreateKey'ed with KEY_ALL_ACCESS.
  7815. //
  7816. // This provider returns the array of functions for reading, writing,
  7817. // deleting and property setting certificates and CRLs.
  7818. // Any changes to the opened store are immediately pushed through to
  7819. // the registry. However, if CERT_STORE_READONLY_FLAG is set, then,
  7820. // writing, deleting or property setting results in a
  7821. // SetLastError(E_ACCESSDENIED).
  7822. //
  7823. // Note, all the certificates and CRLs are read from the registry
  7824. // when the store is opened. The opened store serves as a write through
  7825. // cache.
  7826. //
  7827. // If CERT_REGISTRY_STORE_SERIALIZED_FLAG is set, then, the
  7828. // contexts are persisted as a single serialized store subkey in the
  7829. // registry.
  7830. //
  7831. // CERT_STORE_PROV_PKCS7:
  7832. // sz_CERT_STORE_PROV_PKCS7:
  7833. // Gets the certificates and CRLs from the encoded PKCS #7 signed message.
  7834. // dwEncodingType specifies the message and certificate encoding types.
  7835. // The pointer to the encoded message's blob is passed in pvPara. Given,
  7836. // CRYPT_DATA_BLOB EncodedMsg; pvPara = (const void *) &EncodedMsg;
  7837. //
  7838. // Note, also supports the IE3.0 special version of a
  7839. // PKCS #7 signed message referred to as a "SPC" formatted message.
  7840. //
  7841. // CERT_STORE_PROV_SERIALIZED:
  7842. // sz_CERT_STORE_PROV_SERIALIZED:
  7843. // Gets the certificates and CRLs from memory containing a serialized
  7844. // store. The pointer to the serialized memory blob is passed in pvPara.
  7845. // Given,
  7846. // CRYPT_DATA_BLOB Serialized; pvPara = (const void *) &Serialized;
  7847. //
  7848. // CERT_STORE_PROV_FILENAME_A:
  7849. // CERT_STORE_PROV_FILENAME_W:
  7850. // CERT_STORE_PROV_FILENAME:
  7851. // sz_CERT_STORE_PROV_FILENAME_W:
  7852. // sz_CERT_STORE_PROV_FILENAME:
  7853. // Opens the file and first attempts to read as a serialized store. Then,
  7854. // as a PKCS #7 signed message. Finally, as a single encoded certificate.
  7855. // The filename is passed in pvPara. The filename is UNICODE for the
  7856. // "_W" provider and ASCII for the "_A" provider. For "_W": given,
  7857. // LPCWSTR pwszFilename; pvPara = (const void *) pwszFilename;
  7858. // For "_A": given,
  7859. // LPCSTR pszFilename; pvPara = (const void *) pszFilename;
  7860. //
  7861. // Note, the default (without "_A" or "_W") is unicode.
  7862. //
  7863. // Note, also supports the reading of the IE3.0 special version of a
  7864. // PKCS #7 signed message file referred to as a "SPC" formatted file.
  7865. //
  7866. // CERT_STORE_PROV_SYSTEM_A:
  7867. // CERT_STORE_PROV_SYSTEM_W:
  7868. // CERT_STORE_PROV_SYSTEM:
  7869. // sz_CERT_STORE_PROV_SYSTEM_W:
  7870. // sz_CERT_STORE_PROV_SYSTEM:
  7871. // Opens the specified logical "System" store. The upper word of the
  7872. // dwFlags parameter is used to specify the location of the system store.
  7873. //
  7874. // A "System" store is a collection consisting of one or more "Physical"
  7875. // stores. A "Physical" store is registered via the
  7876. // CertRegisterPhysicalStore API. Each of the registered physical stores
  7877. // is CertStoreOpen'ed and added to the collection via
  7878. // CertAddStoreToCollection.
  7879. //
  7880. // The CERT_SYSTEM_STORE_CURRENT_USER, CERT_SYSTEM_STORE_LOCAL_MACHINE,
  7881. // CERT_SYSTEM_STORE_CURRENT_SERVICE, CERT_SYSTEM_STORE_SERVICES,
  7882. // CERT_SYSTEM_STORE_USERS, CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY,
  7883. // CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY and
  7884. // CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRSE
  7885. // system stores by default have a "SystemRegistry" store that is
  7886. // opened and added to the collection.
  7887. //
  7888. // The system store name is passed in pvPara. The name is UNICODE for the
  7889. // "_W" provider and ASCII for the "_A" provider. For "_W": given,
  7890. // LPCWSTR pwszSystemName; pvPara = (const void *) pwszSystemName;
  7891. // For "_A": given,
  7892. // LPCSTR pszSystemName; pvPara = (const void *) pszSystemName;
  7893. //
  7894. // Note, the default (without "_A" or "_W") is UNICODE.
  7895. //
  7896. // The system store name can't contain any backslashes.
  7897. //
  7898. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvPara
  7899. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure instead
  7900. // of pointing to a null terminated UNICODE or ASCII string.
  7901. // Sibling physical stores are also opened as relocated using
  7902. // pvPara's hKeyBase.
  7903. //
  7904. // The CERT_SYSTEM_STORE_SERVICES or CERT_SYSTEM_STORE_USERS system
  7905. // store name must be prefixed with the ServiceName or UserName.
  7906. // For example, "ServiceName\Trust".
  7907. //
  7908. // Stores on remote computers can be accessed for the
  7909. // CERT_SYSTEM_STORE_LOCAL_MACHINE, CERT_SYSTEM_STORE_SERVICES,
  7910. // CERT_SYSTEM_STORE_USERS, CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
  7911. // or CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
  7912. // locations by prepending the computer name. For example, a remote
  7913. // local machine store is accessed via "\\ComputerName\Trust" or
  7914. // "ComputerName\Trust". A remote service store is accessed via
  7915. // "\\ComputerName\ServiceName\Trust". The leading "\\" backslashes are
  7916. // optional in the ComputerName.
  7917. //
  7918. // If CERT_STORE_READONLY_FLAG is set, then, the registry is
  7919. // RegOpenKey'ed with KEY_READ_ACCESS. Otherwise, the registry is
  7920. // RegCreateKey'ed with KEY_ALL_ACCESS.
  7921. //
  7922. // The "root" store is treated differently from the other system
  7923. // stores. Before a certificate is added to or deleted from the "root"
  7924. // store, a pop up message box is displayed. The certificate's subject,
  7925. // issuer, serial number, time validity, sha1 and md5 thumbprints are
  7926. // displayed. The user is given the option to do the add or delete.
  7927. // If they don't allow the operation, LastError is set to E_ACCESSDENIED.
  7928. //
  7929. // CERT_STORE_PROV_SYSTEM_REGISTRY_A
  7930. // CERT_STORE_PROV_SYSTEM_REGISTRY_W
  7931. // CERT_STORE_PROV_SYSTEM_REGISTRY
  7932. // sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W
  7933. // sz_CERT_STORE_PROV_SYSTEM_REGISTRY
  7934. // Opens the "System" store's default "Physical" store residing in the
  7935. // registry. The upper word of the dwFlags
  7936. // parameter is used to specify the location of the system store.
  7937. //
  7938. // After opening the registry key associated with the system name,
  7939. // the CERT_STORE_PROV_REG provider is called to complete the open.
  7940. //
  7941. // The system store name is passed in pvPara. The name is UNICODE for the
  7942. // "_W" provider and ASCII for the "_A" provider. For "_W": given,
  7943. // LPCWSTR pwszSystemName; pvPara = (const void *) pwszSystemName;
  7944. // For "_A": given,
  7945. // LPCSTR pszSystemName; pvPara = (const void *) pszSystemName;
  7946. //
  7947. // Note, the default (without "_A" or "_W") is UNICODE.
  7948. //
  7949. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvPara
  7950. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure instead
  7951. // of pointing to a null terminated UNICODE or ASCII string.
  7952. //
  7953. // See above for details on prepending a ServiceName and/or ComputerName
  7954. // to the store name.
  7955. //
  7956. // If CERT_STORE_READONLY_FLAG is set, then, the registry is
  7957. // RegOpenKey'ed with KEY_READ_ACCESS. Otherwise, the registry is
  7958. // RegCreateKey'ed with KEY_ALL_ACCESS.
  7959. //
  7960. // The "root" store is treated differently from the other system
  7961. // stores. Before a certificate is added to or deleted from the "root"
  7962. // store, a pop up message box is displayed. The certificate's subject,
  7963. // issuer, serial number, time validity, sha1 and md5 thumbprints are
  7964. // displayed. The user is given the option to do the add or delete.
  7965. // If they don't allow the operation, LastError is set to E_ACCESSDENIED.
  7966. //
  7967. // CERT_STORE_PROV_PHYSICAL_W
  7968. // CERT_STORE_PROV_PHYSICAL
  7969. // sz_CERT_STORE_PROV_PHYSICAL_W
  7970. // sz_CERT_STORE_PROV_PHYSICAL
  7971. // Opens the specified "Physical" store in the "System" store.
  7972. //
  7973. // Both the system store and physical names are passed in pvPara. The
  7974. // names are separated with an intervening "\". For example,
  7975. // "Root\.Default". The string is UNICODE.
  7976. //
  7977. // The system and physical store names can't contain any backslashes.
  7978. //
  7979. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvPara
  7980. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure instead
  7981. // of pointing to a null terminated UNICODE string.
  7982. // The specified physical store is opened as relocated using pvPara's
  7983. // hKeyBase.
  7984. //
  7985. // For CERT_SYSTEM_STORE_SERVICES or CERT_SYSTEM_STORE_USERS,
  7986. // the system and physical store names
  7987. // must be prefixed with the ServiceName or UserName. For example,
  7988. // "ServiceName\Root\.Default".
  7989. //
  7990. // Physical stores on remote computers can be accessed for the
  7991. // CERT_SYSTEM_STORE_LOCAL_MACHINE, CERT_SYSTEM_STORE_SERVICES,
  7992. // CERT_SYSTEM_STORE_USERS, CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
  7993. // or CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
  7994. // locations by prepending the computer name. For example, a remote
  7995. // local machine store is accessed via "\\ComputerName\Root\.Default"
  7996. // or "ComputerName\Root\.Default". A remote service store is
  7997. // accessed via "\\ComputerName\ServiceName\Root\.Default". The
  7998. // leading "\\" backslashes are optional in the ComputerName.
  7999. //
  8000. // CERT_STORE_PROV_COLLECTION
  8001. // sz_CERT_STORE_PROV_COLLECTION
  8002. // Opens a store that is a collection of other stores. Stores are
  8003. // added or removed to/from the collection via the CertAddStoreToCollection
  8004. // and CertRemoveStoreFromCollection APIs.
  8005. //
  8006. // CERT_STORE_PROV_SMART_CARD_W
  8007. // CERT_STORE_PROV_SMART_CARD
  8008. // sz_CERT_STORE_PROV_SMART_CARD_W
  8009. // sz_CERT_STORE_PROV_SMART_CARD
  8010. // Opens a store instantiated over a particular smart card storage. pvPara
  8011. // identifies where on the card the store is located and is of the
  8012. // following format:
  8013. //
  8014. // Card Name\Provider Name\Provider Type[\Container Name]
  8015. //
  8016. // Container Name is optional and if NOT specified the Card Name is used
  8017. // as the Container Name. Future versions of the provider will support
  8018. // instantiating the store over the entire card in which case just
  8019. // Card Name ( or id ) will be sufficient.
  8020. //
  8021. // Here's a list of the predefined provider types (implemented in
  8022. // cryptnet.dll):
  8023. //
  8024. // CERT_STORE_PROV_LDAP_W
  8025. // CERT_STORE_PROV_LDAP
  8026. // sz_CERT_STORE_PROV_LDAP_W
  8027. // sz_CERT_STORE_PROV_LDAP
  8028. // Opens a store over the results of the query specified by and LDAP
  8029. // URL which is passed in via pvPara. In order to do writes to the
  8030. // store the URL must specify a BASE query, no filter and a single
  8031. // attribute.
  8032. //
  8033. //--------------------------------------------------------------------------
  8034. function CertOpenStore(lpszStoreProvider: LPCSTR; dwEncodingType: DWORD;
  8035. hCryptProv: HCRYPTPROV; dwFlags: DWORD; pvPara: Pointer): HCERTSTORE; stdcall;
  8036. {$EXTERNALSYM CertOpenStore}
  8037. //+-------------------------------------------------------------------------
  8038. // OID Installable Certificate Store Provider Data Structures
  8039. //--------------------------------------------------------------------------
  8040. // Handle returned by the store provider when opened.
  8041. type
  8042. HCERTSTOREPROV = Pointer;
  8043. {$EXTERNALSYM HCERTSTOREPROV}
  8044. // Store Provider OID function's pszFuncName.
  8045. const
  8046. CRYPT_OID_OPEN_STORE_PROV_FUNC = 'CertDllOpenStoreProv';
  8047. {$EXTERNALSYM CRYPT_OID_OPEN_STORE_PROV_FUNC}
  8048. // Note, the Store Provider OID function's dwEncodingType is always 0.
  8049. // The following information is returned by the provider when opened. Its
  8050. // zeroed with cbSize set before the provider is called. If the provider
  8051. // doesn't need to be called again after the open it doesn't need to
  8052. // make any updates to the CERT_STORE_PROV_INFO.
  8053. type
  8054. PCERT_STORE_PROV_INFO = ^CERT_STORE_PROV_INFO;
  8055. {$EXTERNALSYM PCERT_STORE_PROV_INFO}
  8056. _CERT_STORE_PROV_INFO = record
  8057. cbSize: DWORD;
  8058. cStoreProvFunc: DWORD;
  8059. rgpvStoreProvFunc: Pointer;
  8060. hStoreProv: HCERTSTOREPROV;
  8061. dwStoreProvFlags: DWORD;
  8062. hStoreProvFuncAddr2: HCRYPTOIDFUNCADDR;
  8063. end;
  8064. {$EXTERNALSYM _CERT_STORE_PROV_INFO}
  8065. CERT_STORE_PROV_INFO = _CERT_STORE_PROV_INFO;
  8066. {$EXTERNALSYM CERT_STORE_PROV_INFO}
  8067. TCertStoreProvInfo = CERT_STORE_PROV_INFO;
  8068. PCertStoreProvInfo = PCERT_STORE_PROV_INFO;
  8069. // Definition of the store provider's open function.
  8070. //
  8071. // *pStoreProvInfo has been zeroed before the call.
  8072. //
  8073. // Note, pStoreProvInfo->cStoreProvFunc should be set last. Once set,
  8074. // all subsequent store calls, such as CertAddSerializedElementToStore will
  8075. // call the appropriate provider callback function.
  8076. type
  8077. PFN_CERT_DLL_OPEN_STORE_PROV_FUNC = function(
  8078. lpszStoreProvider: LPCSTR;
  8079. dwEncodingType: DWORD;
  8080. hCryptProv: HCRYPTPROV;
  8081. dwFlags: DWORD;
  8082. pvPara: Pointer;
  8083. hCertStore: HCERTSTORE;
  8084. var pStoreProvInfo: PCERT_STORE_PROV_INFO): BOOL; stdcall;
  8085. {$EXTERNALSYM PFN_CERT_DLL_OPEN_STORE_PROV_FUNC}
  8086. PFnCertDllOpenStoreProvFunc = PFN_CERT_DLL_OPEN_STORE_PROV_FUNC;
  8087. // The open callback sets the following flag, if it maintains its
  8088. // contexts externally and not in the cached store.
  8089. const
  8090. CERT_STORE_PROV_EXTERNAL_FLAG = $1;
  8091. {$EXTERNALSYM CERT_STORE_PROV_EXTERNAL_FLAG}
  8092. // The open callback sets the following flag for a successful delete.
  8093. // When set, the close callback isn't called.
  8094. CERT_STORE_PROV_DELETED_FLAG = $2;
  8095. {$EXTERNALSYM CERT_STORE_PROV_DELETED_FLAG}
  8096. // The open callback sets the following flag if it doesn't persist store
  8097. // changes.
  8098. CERT_STORE_PROV_NO_PERSIST_FLAG = $4;
  8099. {$EXTERNALSYM CERT_STORE_PROV_NO_PERSIST_FLAG}
  8100. // The open callback sets the following flag if the contexts are persisted
  8101. // to a system store.
  8102. CERT_STORE_PROV_SYSTEM_STORE_FLAG = $8;
  8103. {$EXTERNALSYM CERT_STORE_PROV_SYSTEM_STORE_FLAG}
  8104. // Indices into the store provider's array of callback functions.
  8105. //
  8106. // The provider can implement any subset of the following functions. It
  8107. // sets pStoreProvInfo->cStoreProvFunc to the last index + 1 and any
  8108. // preceding not implemented functions to NULL.
  8109. CERT_STORE_PROV_CLOSE_FUNC = 0;
  8110. {$EXTERNALSYM CERT_STORE_PROV_CLOSE_FUNC}
  8111. CERT_STORE_PROV_READ_CERT_FUNC = 1;
  8112. {$EXTERNALSYM CERT_STORE_PROV_READ_CERT_FUNC}
  8113. CERT_STORE_PROV_WRITE_CERT_FUNC = 2;
  8114. {$EXTERNALSYM CERT_STORE_PROV_WRITE_CERT_FUNC}
  8115. CERT_STORE_PROV_DELETE_CERT_FUNC = 3;
  8116. {$EXTERNALSYM CERT_STORE_PROV_DELETE_CERT_FUNC}
  8117. CERT_STORE_PROV_SET_CERT_PROPERTY_FUNC = 4;
  8118. {$EXTERNALSYM CERT_STORE_PROV_SET_CERT_PROPERTY_FUNC}
  8119. CERT_STORE_PROV_READ_CRL_FUNC = 5;
  8120. {$EXTERNALSYM CERT_STORE_PROV_READ_CRL_FUNC}
  8121. CERT_STORE_PROV_WRITE_CRL_FUNC = 6;
  8122. {$EXTERNALSYM CERT_STORE_PROV_WRITE_CRL_FUNC}
  8123. CERT_STORE_PROV_DELETE_CRL_FUNC = 7;
  8124. {$EXTERNALSYM CERT_STORE_PROV_DELETE_CRL_FUNC}
  8125. CERT_STORE_PROV_SET_CRL_PROPERTY_FUNC = 8;
  8126. {$EXTERNALSYM CERT_STORE_PROV_SET_CRL_PROPERTY_FUNC}
  8127. CERT_STORE_PROV_READ_CTL_FUNC = 9;
  8128. {$EXTERNALSYM CERT_STORE_PROV_READ_CTL_FUNC}
  8129. CERT_STORE_PROV_WRITE_CTL_FUNC = 10;
  8130. {$EXTERNALSYM CERT_STORE_PROV_WRITE_CTL_FUNC}
  8131. CERT_STORE_PROV_DELETE_CTL_FUNC = 11;
  8132. {$EXTERNALSYM CERT_STORE_PROV_DELETE_CTL_FUNC}
  8133. CERT_STORE_PROV_SET_CTL_PROPERTY_FUNC = 12;
  8134. {$EXTERNALSYM CERT_STORE_PROV_SET_CTL_PROPERTY_FUNC}
  8135. CERT_STORE_PROV_CONTROL_FUNC = 13;
  8136. {$EXTERNALSYM CERT_STORE_PROV_CONTROL_FUNC}
  8137. CERT_STORE_PROV_FIND_CERT_FUNC = 14;
  8138. {$EXTERNALSYM CERT_STORE_PROV_FIND_CERT_FUNC}
  8139. CERT_STORE_PROV_FREE_FIND_CERT_FUNC = 15;
  8140. {$EXTERNALSYM CERT_STORE_PROV_FREE_FIND_CERT_FUNC}
  8141. CERT_STORE_PROV_GET_CERT_PROPERTY_FUNC = 16;
  8142. {$EXTERNALSYM CERT_STORE_PROV_GET_CERT_PROPERTY_FUNC}
  8143. CERT_STORE_PROV_FIND_CRL_FUNC = 17;
  8144. {$EXTERNALSYM CERT_STORE_PROV_FIND_CRL_FUNC}
  8145. CERT_STORE_PROV_FREE_FIND_CRL_FUNC = 18;
  8146. {$EXTERNALSYM CERT_STORE_PROV_FREE_FIND_CRL_FUNC}
  8147. CERT_STORE_PROV_GET_CRL_PROPERTY_FUNC = 19;
  8148. {$EXTERNALSYM CERT_STORE_PROV_GET_CRL_PROPERTY_FUNC}
  8149. CERT_STORE_PROV_FIND_CTL_FUNC = 20;
  8150. {$EXTERNALSYM CERT_STORE_PROV_FIND_CTL_FUNC}
  8151. CERT_STORE_PROV_FREE_FIND_CTL_FUNC = 21;
  8152. {$EXTERNALSYM CERT_STORE_PROV_FREE_FIND_CTL_FUNC}
  8153. CERT_STORE_PROV_GET_CTL_PROPERTY_FUNC = 22;
  8154. {$EXTERNALSYM CERT_STORE_PROV_GET_CTL_PROPERTY_FUNC}
  8155. // Called by CertCloseStore when the store's reference count is
  8156. // decremented to 0.
  8157. type
  8158. PFN_CERT_STORE_PROV_CLOSE = procedure(hStoreProv: HCERTSTOREPROV; dwFlags: DWORD); stdcall;
  8159. {$EXTERNALSYM PFN_CERT_STORE_PROV_CLOSE}
  8160. PFnCertStoreProvClose = PFN_CERT_STORE_PROV_CLOSE;
  8161. // Currently not called directly by the store APIs. However, may be exported
  8162. // to support other providers based on it.
  8163. //
  8164. // Reads the provider's copy of the certificate context. If it exists,
  8165. // creates a new certificate context.
  8166. PFN_CERT_STORE_PROV_READ_CERT = function(hStoreProv: HCERTSTOREPROV;
  8167. pStoreCertContext: PCCERT_CONTEXT; dwFlags: DWORD;
  8168. var ppProvCertContext: PCCERT_CONTEXT): BOOL; stdcall;
  8169. {$EXTERNALSYM PFN_CERT_STORE_PROV_READ_CERT}
  8170. PfnCertStoreProvReadCert = PFN_CERT_STORE_PROV_READ_CERT;
  8171. const
  8172. CERT_STORE_PROV_WRITE_ADD_FLAG = $1;
  8173. {$EXTERNALSYM CERT_STORE_PROV_WRITE_ADD_FLAG}
  8174. // Called by CertAddEncodedCertificateToStore,
  8175. // CertAddCertificateContextToStore or CertAddSerializedElementToStore before
  8176. // adding to the store. The CERT_STORE_PROV_WRITE_ADD_FLAG is set. In
  8177. // addition to the encoded certificate, the added pCertContext might also
  8178. // have properties.
  8179. //
  8180. // Returns TRUE if its OK to update the the store.
  8181. type
  8182. PFN_CERT_STORE_PROV_WRITE_CERT = function(hStoreProv: HCERTSTOREPROV;
  8183. pCertContext: PCCERT_CONTEXT; dwFlags: DWORD): BOOL; stdcall;
  8184. {$EXTERNALSYM PFN_CERT_STORE_PROV_WRITE_CERT}
  8185. PfnCertStoreProvWriteCert = PFN_CERT_STORE_PROV_WRITE_CERT;
  8186. // Called by CertDeleteCertificateFromStore before deleting from the
  8187. // store.
  8188. //
  8189. // Returns TRUE if its OK to delete from the store.
  8190. PFN_CERT_STORE_PROV_DELETE_CERT = function(hStoreProv: HCERTSTOREPROV;
  8191. pCertContext: PCCERT_CONTEXT; dwFlags: DWORD): BOOL; stdcall;
  8192. {$EXTERNALSYM PFN_CERT_STORE_PROV_DELETE_CERT}
  8193. PfnCertStoreProvDeleteCert = PFN_CERT_STORE_PROV_DELETE_CERT;
  8194. // Called by CertSetCertificateContextProperty before setting the
  8195. // certificate's property. Also called by CertGetCertificateContextProperty,
  8196. // when getting a hash property that needs to be created and then persisted
  8197. // via the set.
  8198. //
  8199. // Upon input, the property hasn't been set for the pCertContext parameter.
  8200. //
  8201. // Returns TRUE if its OK to set the property.
  8202. type
  8203. PFN_CERT_STORE_PROV_SET_CERT_PROPERTY = function(hStoreProv: HCERTSTOREPROV;
  8204. pCertContext: PCCERT_CONTEXT; dwPropId: DWORD; dwFlags: DWORD;
  8205. pvData: Pointer): BOOL; stdcall;
  8206. {$EXTERNALSYM PFN_CERT_STORE_PROV_SET_CERT_PROPERTY}
  8207. PfnCertStoreProvSetCertProperty = PFN_CERT_STORE_PROV_SET_CERT_PROPERTY;
  8208. // Currently not called directly by the store APIs. However, may be exported
  8209. // to support other providers based on it.
  8210. //
  8211. // Reads the provider's copy of the CRL context. If it exists,
  8212. // creates a new CRL context.
  8213. PFN_CERT_STORE_PROV_READ_CRL = function(hStoreProv: HCERTSTOREPROV;
  8214. pStoreCrlContext: PCCRL_CONTEXT; dwFlags: DWORD;
  8215. var ppProvCrlContext: PCCRL_CONTEXT): BOOL; stdcall;
  8216. {$EXTERNALSYM PFN_CERT_STORE_PROV_READ_CRL}
  8217. PfnCertStoreProvReadCrl = PFN_CERT_STORE_PROV_READ_CRL;
  8218. // Called by CertAddEncodedCRLToStore,
  8219. // CertAddCRLContextToStore or CertAddSerializedElementToStore before
  8220. // adding to the store. The CERT_STORE_PROV_WRITE_ADD_FLAG is set. In
  8221. // addition to the encoded CRL, the added pCertContext might also
  8222. // have properties.
  8223. //
  8224. // Returns TRUE if its OK to update the the store.
  8225. PFN_CERT_STORE_PROV_WRITE_CRL = function(hStoreProv: HCERTSTOREPROV;
  8226. pCrlContext: PCCRL_CONTEXT; dwFlags: DWORD): BOOL; stdcall;
  8227. {$EXTERNALSYM PFN_CERT_STORE_PROV_WRITE_CRL}
  8228. PfnCertStoreProvWriteCrl = PFN_CERT_STORE_PROV_WRITE_CRL;
  8229. // Called by CertDeleteCRLFromStore before deleting from the store.
  8230. //
  8231. // Returns TRUE if its OK to delete from the store.
  8232. PFN_CERT_STORE_PROV_DELETE_CRL = function(hStoreProv: HCERTSTOREPROV;
  8233. pCrlContext: PCCRL_CONTEXT; dwFlags: DWORD): BOOL; stdcall;
  8234. {$EXTERNALSYM PFN_CERT_STORE_PROV_DELETE_CRL}
  8235. PfnCertStoreProvDeleteCrl = PFN_CERT_STORE_PROV_DELETE_CRL;
  8236. // Called by CertSetCRLContextProperty before setting the
  8237. // CRL's property. Also called by CertGetCRLContextProperty,
  8238. // when getting a hash property that needs to be created and then persisted
  8239. // via the set.
  8240. //
  8241. // Upon input, the property hasn't been set for the pCrlContext parameter.
  8242. //
  8243. // Returns TRUE if its OK to set the property.
  8244. PFN_CERT_STORE_PROV_SET_CRL_PROPERTY = function(hStoreProv: HCERTSTOREPROV;
  8245. pCrlContext: PCCRL_CONTEXT; dwPropId: DWORD; dwFlags: DWORD;
  8246. pvData: Pointer): BOOL; stdcall;
  8247. {$EXTERNALSYM PFN_CERT_STORE_PROV_SET_CRL_PROPERTY}
  8248. PfnCertStoreProvSetCrlProperty = PFN_CERT_STORE_PROV_SET_CRL_PROPERTY;
  8249. // Currently not called directly by the store APIs. However, may be exported
  8250. // to support other providers based on it.
  8251. //
  8252. // Reads the provider's copy of the CTL context. If it exists,
  8253. // creates a new CTL context.
  8254. PFN_CERT_STORE_PROV_READ_CTL = function(hStoreProv: HCERTSTOREPROV;
  8255. pStoreCtlContext: PCCTL_CONTEXT; dwFlags: DWORD;
  8256. var ppProvCtlContext: PCCTL_CONTEXT): BOOL; stdcall;
  8257. {$EXTERNALSYM PFN_CERT_STORE_PROV_READ_CTL}
  8258. PfnCertStoreProvReadCtl = PFN_CERT_STORE_PROV_READ_CTL;
  8259. // Called by CertAddEncodedCTLToStore,
  8260. // CertAddCTLContextToStore or CertAddSerializedElementToStore before
  8261. // adding to the store. The CERT_STORE_PROV_WRITE_ADD_FLAG is set. In
  8262. // addition to the encoded CTL, the added pCertContext might also
  8263. // have properties.
  8264. //
  8265. // Returns TRUE if its OK to update the the store.
  8266. PFN_CERT_STORE_PROV_WRITE_CTL = function(hStoreProv: HCERTSTOREPROV;
  8267. pCtlContext: PCCTL_CONTEXT; dwFlags: DWORD): BOOL; stdcall;
  8268. {$EXTERNALSYM PFN_CERT_STORE_PROV_WRITE_CTL}
  8269. PfnCertStoreProvWriteCtl = PFN_CERT_STORE_PROV_WRITE_CTL;
  8270. // Called by CertDeleteCTLFromStore before deleting from the store.
  8271. //
  8272. // Returns TRUE if its OK to delete from the store.
  8273. PFN_CERT_STORE_PROV_DELETE_CTL = function(hStoreProv: HCERTSTOREPROV;
  8274. pCtlContext: PCCTL_CONTEXT; dwFlags: DWORD): BOOL; stdcall;
  8275. {$EXTERNALSYM PFN_CERT_STORE_PROV_DELETE_CTL}
  8276. PfnCertStoreProvDeleteCtl = PFN_CERT_STORE_PROV_DELETE_CTL;
  8277. // Called by CertSetCTLContextProperty before setting the
  8278. // CTL's property. Also called by CertGetCTLContextProperty,
  8279. // when getting a hash property that needs to be created and then persisted
  8280. // via the set.
  8281. //
  8282. // Upon input, the property hasn't been set for the pCtlContext parameter.
  8283. //
  8284. // Returns TRUE if its OK to set the property.
  8285. PFN_CERT_STORE_PROV_SET_CTL_PROPERTY = function(hStoreProv: HCERTSTOREPROV;
  8286. pCtlContext: PCCTL_CONTEXT; dwPropId, dwFlags: DWORD; pvData: Pointer): BOOL; stdcall;
  8287. {$EXTERNALSYM PFN_CERT_STORE_PROV_SET_CTL_PROPERTY}
  8288. PfnCertStoreProvSetCtlProperty = PFN_CERT_STORE_PROV_SET_CTL_PROPERTY;
  8289. PFN_CERT_STORE_PROV_CONTROL = function(hStoreProv: HCERTSTOREPROV;
  8290. dwFlags: DWORD; dwCtrlType: DWORD; pvCtrlPara: Pointer): BOOL; stdcall;
  8291. {$EXTERNALSYM PFN_CERT_STORE_PROV_CONTROL}
  8292. PfnCertStoreProvControl = PFN_CERT_STORE_PROV_CONTROL;
  8293. PCERT_STORE_PROV_FIND_INFO = ^CERT_STORE_PROV_FIND_INFO;
  8294. {$EXTERNALSYM PCERT_STORE_PROV_FIND_INFO}
  8295. _CERT_STORE_PROV_FIND_INFO = record
  8296. cbSize: DWORD;
  8297. dwMsgAndCertEncodingType: DWORD;
  8298. dwFindFlags: DWORD;
  8299. dwFindType: DWORD;
  8300. pvFindPara: Pointer;
  8301. end;
  8302. {$EXTERNALSYM _CERT_STORE_PROV_FIND_INFO}
  8303. CERT_STORE_PROV_FIND_INFO = _CERT_STORE_PROV_FIND_INFO;
  8304. {$EXTERNALSYM CERT_STORE_PROV_FIND_INFO}
  8305. TCertStoreProvFindInfo = CERT_STORE_PROV_FIND_INFO;
  8306. PCertStoreProvFindInfo = PCERT_STORE_PROV_FIND_INFO;
  8307. CCERT_STORE_PROV_FIND_INFO = CERT_STORE_PROV_FIND_INFO;
  8308. {$EXTERNALSYM CCERT_STORE_PROV_FIND_INFO}
  8309. PCCERT_STORE_PROV_FIND_INFO = PCERT_STORE_PROV_FIND_INFO;
  8310. {$EXTERNALSYM PCCERT_STORE_PROV_FIND_INFO}
  8311. PFN_CERT_STORE_PROV_FIND_CERT = function(hStoreProv: HCERTSTOREPROV;
  8312. pFindInfo: PCCERT_STORE_PROV_FIND_INFO; pPrevCertContext: PCCERT_CONTEXT;
  8313. dwFlags: DWORD; var ppvStoreProvFindInfo: Pointer;
  8314. var ppProvCertContext: PCCERT_CONTEXT): BOOL; stdcall;
  8315. {$EXTERNALSYM PFN_CERT_STORE_PROV_FIND_CERT}
  8316. PfnCertStoreProvFindCert = PFN_CERT_STORE_PROV_FIND_CERT;
  8317. PFN_CERT_STORE_PROV_FREE_FIND_CERT = function(hStoreProv: HCERTSTOREPROV;
  8318. pCertContext: PCCERT_CONTEXT; pvStoreProvFindInfo: Pointer; dwFlags: DWORD): BOOL; stdcall;
  8319. {$EXTERNALSYM PFN_CERT_STORE_PROV_FREE_FIND_CERT}
  8320. PfnCertStoreProvFreeFindCert = PFN_CERT_STORE_PROV_FREE_FIND_CERT;
  8321. PFN_CERT_STORE_PROV_GET_CERT_PROPERTY = function(hStoreProv: HCERTSTOREPROV;
  8322. pCertContext: PCCERT_CONTEXT; dwPropId: DWORD; dwFlags: DWORD; pvData: Pointer;
  8323. var pcbData: DWORD): BOOL; stdcall;
  8324. {$EXTERNALSYM PFN_CERT_STORE_PROV_GET_CERT_PROPERTY}
  8325. PfnCertStoreProvGetCertProperty = PFN_CERT_STORE_PROV_GET_CERT_PROPERTY;
  8326. PFN_CERT_STORE_PROV_FIND_CRL = function(hStoreProv: HCERTSTOREPROV;
  8327. pFindInfo: PCCERT_STORE_PROV_FIND_INFO; pPrevCrlContext: PCCRL_CONTEXT;
  8328. dwFlags: DWORD; var ppvStoreProvFindInfo: Pointer;
  8329. var ppProvCrlContext: PCCRL_CONTEXT): BOOL; stdcall;
  8330. {$EXTERNALSYM PFN_CERT_STORE_PROV_FIND_CRL}
  8331. PfnCertStoreProvFindCrl = PFN_CERT_STORE_PROV_FIND_CRL;
  8332. PFN_CERT_STORE_PROV_FREE_FIND_CRL = function(hStoreProv: HCERTSTOREPROV;
  8333. pCrlContext: PCCRL_CONTEXT; pvStoreProvFindInfo: Pointer; dwFlags: DWORD): BOOL; stdcall;
  8334. {$EXTERNALSYM PFN_CERT_STORE_PROV_FREE_FIND_CRL}
  8335. PfnCertStoreProvFreeFindCrl = PFN_CERT_STORE_PROV_FREE_FIND_CRL;
  8336. PFN_CERT_STORE_PROV_GET_CRL_PROPERTY = function(hStoreProv: HCERTSTOREPROV;
  8337. pCrlContext: PCCRL_CONTEXT; dwPropId: DWORD; dwFlags: DWORD; pvData: Pointer;
  8338. var pcbData: DWORD): BOOL; stdcall;
  8339. {$EXTERNALSYM PFN_CERT_STORE_PROV_GET_CRL_PROPERTY}
  8340. PfnCertStoreProvGetCrlProperty = PFN_CERT_STORE_PROV_GET_CRL_PROPERTY;
  8341. PFN_CERT_STORE_PROV_FIND_CTL = function(hStoreProv: HCERTSTOREPROV;
  8342. pFindInfo: PCCERT_STORE_PROV_FIND_INFO; pPrevCtlContext: PCCTL_CONTEXT;
  8343. dwFlags: DWORD; var ppvStoreProvFindInfo: Pointer;
  8344. var ppProvCtlContext: PCCTL_CONTEXT): BOOL; stdcall;
  8345. {$EXTERNALSYM PFN_CERT_STORE_PROV_FIND_CTL}
  8346. PfnCertStoreProvFindCtl = PFN_CERT_STORE_PROV_FIND_CTL;
  8347. PFN_CERT_STORE_PROV_FREE_FIND_CTL = function(hStoreProv: HCERTSTOREPROV;
  8348. pCtlContext: PCCTL_CONTEXT; pvStoreProvFindInfo: Pointer; dwFlags: DWORD): BOOL; stdcall;
  8349. {$EXTERNALSYM PFN_CERT_STORE_PROV_FREE_FIND_CTL}
  8350. PfnCertStoreProvFreeFindCtl = PFN_CERT_STORE_PROV_FREE_FIND_CTL;
  8351. PFN_CERT_STORE_PROV_GET_CTL_PROPERTY = function(hStoreProv: HCERTSTOREPROV;
  8352. pCtlContext: PCCTL_CONTEXT; dwPropId: DWORD; dwFlags: DWORD; pvData: Pointer;
  8353. var pcbData: DWORD): BOOL; stdcall;
  8354. {$EXTERNALSYM PFN_CERT_STORE_PROV_GET_CTL_PROPERTY}
  8355. PfnCertStoreProvGetCtlProperty = PFN_CERT_STORE_PROV_GET_CTL_PROPERTY;
  8356. //+-------------------------------------------------------------------------
  8357. // Duplicate a cert store handle
  8358. //--------------------------------------------------------------------------
  8359. function CertDuplicateStore(hCertStore: HCERTSTORE): HCERTSTORE; stdcall;
  8360. {$EXTERNALSYM CertDuplicateStore}
  8361. const
  8362. CERT_STORE_SAVE_AS_STORE = 1;
  8363. {$EXTERNALSYM CERT_STORE_SAVE_AS_STORE}
  8364. CERT_STORE_SAVE_AS_PKCS7 = 2;
  8365. {$EXTERNALSYM CERT_STORE_SAVE_AS_PKCS7}
  8366. CERT_STORE_SAVE_TO_FILE = 1;
  8367. {$EXTERNALSYM CERT_STORE_SAVE_TO_FILE}
  8368. CERT_STORE_SAVE_TO_MEMORY = 2;
  8369. {$EXTERNALSYM CERT_STORE_SAVE_TO_MEMORY}
  8370. CERT_STORE_SAVE_TO_FILENAME_A = 3;
  8371. {$EXTERNALSYM CERT_STORE_SAVE_TO_FILENAME_A}
  8372. CERT_STORE_SAVE_TO_FILENAME_W = 4;
  8373. {$EXTERNALSYM CERT_STORE_SAVE_TO_FILENAME_W}
  8374. CERT_STORE_SAVE_TO_FILENAME = CERT_STORE_SAVE_TO_FILENAME_W;
  8375. {$EXTERNALSYM CERT_STORE_SAVE_TO_FILENAME}
  8376. //+-------------------------------------------------------------------------
  8377. // Save the cert store. Extended version with lots of options.
  8378. //
  8379. // According to the dwSaveAs parameter, the store can be saved as a
  8380. // serialized store (CERT_STORE_SAVE_AS_STORE) containing properties in
  8381. // addition to encoded certificates, CRLs and CTLs or the store can be saved
  8382. // as a PKCS #7 signed message (CERT_STORE_SAVE_AS_PKCS7) which doesn't
  8383. // include the properties or CTLs.
  8384. //
  8385. // Note, the CERT_KEY_CONTEXT_PROP_ID property (and its
  8386. // CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_SPEC_PROP_ID) isn't saved into
  8387. // a serialized store.
  8388. //
  8389. // For CERT_STORE_SAVE_AS_PKCS7, the dwEncodingType specifies the message
  8390. // encoding type. The dwEncodingType parameter isn't used for
  8391. // CERT_STORE_SAVE_AS_STORE.
  8392. //
  8393. // The dwFlags parameter currently isn't used and should be set to 0.
  8394. //
  8395. // The dwSaveTo and pvSaveToPara parameters specify where to save the
  8396. // store as follows:
  8397. // CERT_STORE_SAVE_TO_FILE:
  8398. // Saves to the specified file. The file's handle is passed in
  8399. // pvSaveToPara. Given,
  8400. // HANDLE hFile; pvSaveToPara = (void *) hFile;
  8401. //
  8402. // For a successful save, the file pointer is positioned after the
  8403. // last write.
  8404. //
  8405. // CERT_STORE_SAVE_TO_MEMORY:
  8406. // Saves to the specified memory blob. The pointer to
  8407. // the memory blob is passed in pvSaveToPara. Given,
  8408. // CRYPT_DATA_BLOB SaveBlob; pvSaveToPara = (void *) &SaveBlob;
  8409. // Upon entry, the SaveBlob's pbData and cbData need to be initialized.
  8410. // Upon return, cbData is updated with the actual length.
  8411. // For a length only calculation, pbData should be set to NULL. If
  8412. // pbData is non-NULL and cbData isn't large enough, FALSE is returned
  8413. // with a last error of ERRROR_MORE_DATA.
  8414. //
  8415. // CERT_STORE_SAVE_TO_FILENAME_A:
  8416. // CERT_STORE_SAVE_TO_FILENAME_W:
  8417. // CERT_STORE_SAVE_TO_FILENAME:
  8418. // Opens the file and saves to it. The filename is passed in pvSaveToPara.
  8419. // The filename is UNICODE for the "_W" option and ASCII for the "_A"
  8420. // option. For "_W": given,
  8421. // LPCWSTR pwszFilename; pvSaveToPara = (void *) pwszFilename;
  8422. // For "_A": given,
  8423. // LPCSTR pszFilename; pvSaveToPara = (void *) pszFilename;
  8424. //
  8425. // Note, the default (without "_A" or "_W") is UNICODE.
  8426. //
  8427. //--------------------------------------------------------------------------
  8428. function CertSaveStore(hCertStore: HCERTSTORE; dwEncodingType, dwSaveAs: DWORD;
  8429. dwSaveTo: DWORD; pvSaveToPara: Pointer; dwFlags: DWORD): BOOL; stdcall;
  8430. {$EXTERNALSYM CertSaveStore}
  8431. //+-------------------------------------------------------------------------
  8432. // Certificate Store close flags
  8433. //--------------------------------------------------------------------------
  8434. const
  8435. CERT_CLOSE_STORE_FORCE_FLAG = $00000001;
  8436. {$EXTERNALSYM CERT_CLOSE_STORE_FORCE_FLAG}
  8437. CERT_CLOSE_STORE_CHECK_FLAG = $00000002;
  8438. {$EXTERNALSYM CERT_CLOSE_STORE_CHECK_FLAG}
  8439. //+-------------------------------------------------------------------------
  8440. // Close a cert store handle.
  8441. //
  8442. // There needs to be a corresponding close for each open and duplicate.
  8443. //
  8444. // Even on the final close, the cert store isn't freed until all of its
  8445. // certificate and CRL contexts have also been freed.
  8446. //
  8447. // On the final close, the hCryptProv passed to CertStoreOpen is
  8448. // CryptReleaseContext'ed.
  8449. //
  8450. // To force the closure of the store with all of its memory freed, set the
  8451. // CERT_STORE_CLOSE_FORCE_FLAG. This flag should be set when the caller does
  8452. // its own reference counting and wants everything to vanish.
  8453. //
  8454. // To check if all the store's certificates and CRLs have been freed and that
  8455. // this is the last CertCloseStore, set the CERT_CLOSE_STORE_CHECK_FLAG. If
  8456. // set and certs, CRLs or stores still need to be freed/closed, FALSE is
  8457. // returned with LastError set to CRYPT_E_PENDING_CLOSE. Note, for FALSE,
  8458. // the store is still closed. This is a diagnostic flag.
  8459. //
  8460. // LastError is preserved unless CERT_CLOSE_STORE_CHECK_FLAG is set and FALSE
  8461. // is returned.
  8462. //--------------------------------------------------------------------------
  8463. function CertCloseStore(hCertStore: HCERTSTORE; dwFlags: DWORD): BOOL; stdcall;
  8464. {$EXTERNALSYM CertCloseStore}
  8465. //+-------------------------------------------------------------------------
  8466. // Get the subject certificate context uniquely identified by its Issuer and
  8467. // SerialNumber from the store.
  8468. //
  8469. // If the certificate isn't found, NULL is returned. Otherwise, a pointer to
  8470. // a read only CERT_CONTEXT is returned. CERT_CONTEXT must be freed by calling
  8471. // CertFreeCertificateContext. CertDuplicateCertificateContext can be called to make a
  8472. // duplicate.
  8473. //
  8474. // The returned certificate might not be valid. Normally, it would be
  8475. // verified when getting its issuer certificate (CertGetIssuerCertificateFromStore).
  8476. //--------------------------------------------------------------------------
  8477. function CertGetSubjectCertificateFromStore(hCertStore: HCERTSTORE;
  8478. dwCertEncodingType: DWORD; pCertId: PCERT_INFO): PCCERT_CONTEXT; stdcall;
  8479. {$EXTERNALSYM CertGetSubjectCertificateFromStore}
  8480. //+-------------------------------------------------------------------------
  8481. // Enumerate the certificate contexts in the store.
  8482. //
  8483. // If a certificate isn't found, NULL is returned.
  8484. // Otherwise, a pointer to a read only CERT_CONTEXT is returned. CERT_CONTEXT
  8485. // must be freed by calling CertFreeCertificateContext or is freed when passed as the
  8486. // pPrevCertContext on a subsequent call. CertDuplicateCertificateContext
  8487. // can be called to make a duplicate.
  8488. //
  8489. // pPrevCertContext MUST BE NULL to enumerate the first
  8490. // certificate in the store. Successive certificates are enumerated by setting
  8491. // pPrevCertContext to the CERT_CONTEXT returned by a previous call.
  8492. //
  8493. // NOTE: a NON-NULL pPrevCertContext is always CertFreeCertificateContext'ed by
  8494. // this function, even for an error.
  8495. //--------------------------------------------------------------------------
  8496. function CertEnumCertificatesInStore(hCertStore: HCERTSTORE;
  8497. pPrevCertContext: PCCERT_CONTEXT): PCCERT_CONTEXT; stdcall;
  8498. {$EXTERNALSYM CertEnumCertificatesInStore}
  8499. //+-------------------------------------------------------------------------
  8500. // Find the first or next certificate context in the store.
  8501. //
  8502. // The certificate is found according to the dwFindType and its pvFindPara.
  8503. // See below for a list of the find types and its parameters.
  8504. //
  8505. // Currently dwFindFlags is only used for CERT_FIND_SUBJECT_ATTR,
  8506. // CERT_FIND_ISSUER_ATTR or CERT_FIND_CTL_USAGE. Otherwise, must be set to 0.
  8507. //
  8508. // Usage of dwCertEncodingType depends on the dwFindType.
  8509. //
  8510. // If the first or next certificate isn't found, NULL is returned.
  8511. // Otherwise, a pointer to a read only CERT_CONTEXT is returned. CERT_CONTEXT
  8512. // must be freed by calling CertFreeCertificateContext or is freed when passed as the
  8513. // pPrevCertContext on a subsequent call. CertDuplicateCertificateContext
  8514. // can be called to make a duplicate.
  8515. //
  8516. // pPrevCertContext MUST BE NULL on the first
  8517. // call to find the certificate. To find the next certificate, the
  8518. // pPrevCertContext is set to the CERT_CONTEXT returned by a previous call.
  8519. //
  8520. // NOTE: a NON-NULL pPrevCertContext is always CertFreeCertificateContext'ed by
  8521. // this function, even for an error.
  8522. //--------------------------------------------------------------------------
  8523. function CertFindCertificateInStore(hCertStore: HCERTSTORE;
  8524. dwCertEncodingType, dwFindFlags, dwFindType: DWORD; pvFindPara: Pointer;
  8525. pPrevCertContext: PCCERT_CONTEXT): PCCERT_CONTEXT; stdcall;
  8526. {$EXTERNALSYM CertFindCertificateInStore}
  8527. //+-------------------------------------------------------------------------
  8528. // Certificate comparison functions
  8529. //--------------------------------------------------------------------------
  8530. const
  8531. CERT_COMPARE_MASK = $FFFF;
  8532. {$EXTERNALSYM CERT_COMPARE_MASK}
  8533. CERT_COMPARE_SHIFT = 16;
  8534. {$EXTERNALSYM CERT_COMPARE_SHIFT}
  8535. CERT_COMPARE_ANY = 0;
  8536. {$EXTERNALSYM CERT_COMPARE_ANY}
  8537. CERT_COMPARE_SHA1_HASH = 1;
  8538. {$EXTERNALSYM CERT_COMPARE_SHA1_HASH}
  8539. CERT_COMPARE_NAME = 2;
  8540. {$EXTERNALSYM CERT_COMPARE_NAME}
  8541. CERT_COMPARE_ATTR = 3;
  8542. {$EXTERNALSYM CERT_COMPARE_ATTR}
  8543. CERT_COMPARE_MD5_HASH = 4;
  8544. {$EXTERNALSYM CERT_COMPARE_MD5_HASH}
  8545. CERT_COMPARE_PROPERTY = 5;
  8546. {$EXTERNALSYM CERT_COMPARE_PROPERTY}
  8547. CERT_COMPARE_PUBLIC_KEY = 6;
  8548. {$EXTERNALSYM CERT_COMPARE_PUBLIC_KEY}
  8549. CERT_COMPARE_HASH = CERT_COMPARE_SHA1_HASH;
  8550. {$EXTERNALSYM CERT_COMPARE_HASH}
  8551. CERT_COMPARE_NAME_STR_A = 7;
  8552. {$EXTERNALSYM CERT_COMPARE_NAME_STR_A}
  8553. CERT_COMPARE_NAME_STR_W = 8;
  8554. {$EXTERNALSYM CERT_COMPARE_NAME_STR_W}
  8555. CERT_COMPARE_KEY_SPEC = 9;
  8556. {$EXTERNALSYM CERT_COMPARE_KEY_SPEC}
  8557. CERT_COMPARE_ENHKEY_USAGE = 10;
  8558. {$EXTERNALSYM CERT_COMPARE_ENHKEY_USAGE}
  8559. CERT_COMPARE_CTL_USAGE = CERT_COMPARE_ENHKEY_USAGE;
  8560. {$EXTERNALSYM CERT_COMPARE_CTL_USAGE}
  8561. CERT_COMPARE_SUBJECT_CERT = 11;
  8562. {$EXTERNALSYM CERT_COMPARE_SUBJECT_CERT}
  8563. CERT_COMPARE_ISSUER_OF = 12;
  8564. {$EXTERNALSYM CERT_COMPARE_ISSUER_OF}
  8565. CERT_COMPARE_EXISTING = 13;
  8566. {$EXTERNALSYM CERT_COMPARE_EXISTING}
  8567. CERT_COMPARE_SIGNATURE_HASH = 14;
  8568. {$EXTERNALSYM CERT_COMPARE_SIGNATURE_HASH}
  8569. CERT_COMPARE_KEY_IDENTIFIER = 15;
  8570. {$EXTERNALSYM CERT_COMPARE_KEY_IDENTIFIER}
  8571. CERT_COMPARE_CERT_ID = 16;
  8572. {$EXTERNALSYM CERT_COMPARE_CERT_ID}
  8573. //+-------------------------------------------------------------------------
  8574. // dwFindType
  8575. //
  8576. // The dwFindType definition consists of two components:
  8577. // - comparison function
  8578. // - certificate information flag
  8579. //--------------------------------------------------------------------------
  8580. CERT_FIND_ANY = CERT_COMPARE_ANY shl CERT_COMPARE_SHIFT;
  8581. {$EXTERNALSYM CERT_FIND_ANY}
  8582. CERT_FIND_SHA1_HASH = CERT_COMPARE_SHA1_HASH shl CERT_COMPARE_SHIFT;
  8583. {$EXTERNALSYM CERT_FIND_SHA1_HASH}
  8584. CERT_FIND_MD5_HASH = CERT_COMPARE_MD5_HASH shl CERT_COMPARE_SHIFT;
  8585. {$EXTERNALSYM CERT_FIND_MD5_HASH}
  8586. CERT_FIND_SIGNATURE_HASH = CERT_COMPARE_SIGNATURE_HASH shl CERT_COMPARE_SHIFT;
  8587. {$EXTERNALSYM CERT_FIND_SIGNATURE_HASH}
  8588. CERT_FIND_KEY_IDENTIFIER = CERT_COMPARE_KEY_IDENTIFIER shl CERT_COMPARE_SHIFT;
  8589. {$EXTERNALSYM CERT_FIND_KEY_IDENTIFIER}
  8590. CERT_FIND_HASH = CERT_FIND_SHA1_HASH;
  8591. {$EXTERNALSYM CERT_FIND_HASH}
  8592. CERT_FIND_PROPERTY = CERT_COMPARE_PROPERTY shl CERT_COMPARE_SHIFT;
  8593. {$EXTERNALSYM CERT_FIND_PROPERTY}
  8594. CERT_FIND_PUBLIC_KEY = CERT_COMPARE_PUBLIC_KEY shl CERT_COMPARE_SHIFT;
  8595. {$EXTERNALSYM CERT_FIND_PUBLIC_KEY}
  8596. CERT_FIND_SUBJECT_NAME = CERT_COMPARE_NAME shl CERT_COMPARE_SHIFT or CERT_INFO_SUBJECT_FLAG;
  8597. {$EXTERNALSYM CERT_FIND_SUBJECT_NAME}
  8598. CERT_FIND_SUBJECT_ATTR = CERT_COMPARE_ATTR shl CERT_COMPARE_SHIFT or CERT_INFO_SUBJECT_FLAG;
  8599. {$EXTERNALSYM CERT_FIND_SUBJECT_ATTR}
  8600. CERT_FIND_ISSUER_NAME = CERT_COMPARE_NAME shl CERT_COMPARE_SHIFT or CERT_INFO_ISSUER_FLAG;
  8601. {$EXTERNALSYM CERT_FIND_ISSUER_NAME}
  8602. CERT_FIND_ISSUER_ATTR = CERT_COMPARE_ATTR shl CERT_COMPARE_SHIFT or CERT_INFO_ISSUER_FLAG;
  8603. {$EXTERNALSYM CERT_FIND_ISSUER_ATTR}
  8604. CERT_FIND_SUBJECT_STR_A = CERT_COMPARE_NAME_STR_A shl CERT_COMPARE_SHIFT or CERT_INFO_SUBJECT_FLAG;
  8605. {$EXTERNALSYM CERT_FIND_SUBJECT_STR_A}
  8606. CERT_FIND_SUBJECT_STR_W = CERT_COMPARE_NAME_STR_W shl CERT_COMPARE_SHIFT or CERT_INFO_SUBJECT_FLAG;
  8607. {$EXTERNALSYM CERT_FIND_SUBJECT_STR_W}
  8608. CERT_FIND_SUBJECT_STR = CERT_FIND_SUBJECT_STR_W;
  8609. {$EXTERNALSYM CERT_FIND_SUBJECT_STR}
  8610. CERT_FIND_ISSUER_STR_A = CERT_COMPARE_NAME_STR_A shl CERT_COMPARE_SHIFT or CERT_INFO_ISSUER_FLAG;
  8611. {$EXTERNALSYM CERT_FIND_ISSUER_STR_A}
  8612. CERT_FIND_ISSUER_STR_W = CERT_COMPARE_NAME_STR_W shl CERT_COMPARE_SHIFT or CERT_INFO_ISSUER_FLAG;
  8613. {$EXTERNALSYM CERT_FIND_ISSUER_STR_W}
  8614. CERT_FIND_ISSUER_STR = CERT_FIND_ISSUER_STR_W;
  8615. {$EXTERNALSYM CERT_FIND_ISSUER_STR}
  8616. CERT_FIND_KEY_SPEC = CERT_COMPARE_KEY_SPEC shl CERT_COMPARE_SHIFT;
  8617. {$EXTERNALSYM CERT_FIND_KEY_SPEC}
  8618. CERT_FIND_ENHKEY_USAGE = CERT_COMPARE_ENHKEY_USAGE shl CERT_COMPARE_SHIFT;
  8619. {$EXTERNALSYM CERT_FIND_ENHKEY_USAGE}
  8620. CERT_FIND_CTL_USAGE = CERT_FIND_ENHKEY_USAGE;
  8621. {$EXTERNALSYM CERT_FIND_CTL_USAGE}
  8622. CERT_FIND_SUBJECT_CERT = CERT_COMPARE_SUBJECT_CERT shl CERT_COMPARE_SHIFT;
  8623. {$EXTERNALSYM CERT_FIND_SUBJECT_CERT}
  8624. CERT_FIND_ISSUER_OF = CERT_COMPARE_ISSUER_OF shl CERT_COMPARE_SHIFT;
  8625. {$EXTERNALSYM CERT_FIND_ISSUER_OF}
  8626. CERT_FIND_EXISTING = CERT_COMPARE_EXISTING shl CERT_COMPARE_SHIFT;
  8627. {$EXTERNALSYM CERT_FIND_EXISTING}
  8628. CERT_FIND_CERT_ID = CERT_COMPARE_CERT_ID shl CERT_COMPARE_SHIFT;
  8629. {$EXTERNALSYM CERT_FIND_CERT_ID}
  8630. //+-------------------------------------------------------------------------
  8631. // CERT_FIND_ANY
  8632. //
  8633. // Find any certificate.
  8634. //
  8635. // pvFindPara isn't used.
  8636. //--------------------------------------------------------------------------
  8637. //+-------------------------------------------------------------------------
  8638. // CERT_FIND_HASH
  8639. //
  8640. // Find a certificate with the specified hash.
  8641. //
  8642. // pvFindPara points to a CRYPT_HASH_BLOB.
  8643. //--------------------------------------------------------------------------
  8644. //+-------------------------------------------------------------------------
  8645. // CERT_FIND_KEY_IDENTIFIER
  8646. //
  8647. // Find a certificate with the specified KeyIdentifier. Gets the
  8648. // CERT_KEY_IDENTIFIER_PROP_ID property and compares with the input
  8649. // CRYPT_HASH_BLOB.
  8650. //
  8651. // pvFindPara points to a CRYPT_HASH_BLOB.
  8652. //--------------------------------------------------------------------------
  8653. //+-------------------------------------------------------------------------
  8654. // CERT_FIND_PROPERTY
  8655. //
  8656. // Find a certificate having the specified property.
  8657. //
  8658. // pvFindPara points to a DWORD containing the PROP_ID
  8659. //--------------------------------------------------------------------------
  8660. //+-------------------------------------------------------------------------
  8661. // CERT_FIND_PUBLIC_KEY
  8662. //
  8663. // Find a certificate matching the specified public key.
  8664. //
  8665. // pvFindPara points to a CERT_PUBLIC_KEY_INFO containing the public key
  8666. //--------------------------------------------------------------------------
  8667. //+-------------------------------------------------------------------------
  8668. // CERT_FIND_SUBJECT_NAME
  8669. // CERT_FIND_ISSUER_NAME
  8670. //
  8671. // Find a certificate with the specified subject/issuer name. Does an exact
  8672. // match of the entire name.
  8673. //
  8674. // Restricts search to certificates matching the dwCertEncodingType.
  8675. //
  8676. // pvFindPara points to a CERT_NAME_BLOB.
  8677. //--------------------------------------------------------------------------
  8678. //+-------------------------------------------------------------------------
  8679. // CERT_FIND_SUBJECT_ATTR
  8680. // CERT_FIND_ISSUER_ATTR
  8681. //
  8682. // Find a certificate with the specified subject/issuer attributes.
  8683. //
  8684. // Compares the attributes in the subject/issuer name with the
  8685. // Relative Distinguished Name's (CERT_RDN) array of attributes specified in
  8686. // pvFindPara. The comparison iterates through the CERT_RDN attributes and looks
  8687. // for an attribute match in any of the subject/issuer's RDNs.
  8688. //
  8689. // The CERT_RDN_ATTR fields can have the following special values:
  8690. // pszObjId == NULL - ignore the attribute object identifier
  8691. // dwValueType == RDN_ANY_TYPE - ignore the value type
  8692. // Value.pbData == NULL - match any value
  8693. //
  8694. // CERT_CASE_INSENSITIVE_IS_RDN_ATTRS_FLAG should be set in dwFindFlags to do
  8695. // a case insensitive match. Otherwise, defaults to an exact, case sensitive
  8696. // match.
  8697. //
  8698. // CERT_UNICODE_IS_RDN_ATTRS_FLAG should be set in dwFindFlags if the RDN was
  8699. // initialized with unicode strings as for
  8700. // CryptEncodeObject(X509_UNICODE_NAME).
  8701. //
  8702. // Restricts search to certificates matching the dwCertEncodingType.
  8703. //
  8704. // pvFindPara points to a CERT_RDN (defined in wincert.h).
  8705. //--------------------------------------------------------------------------
  8706. //+-------------------------------------------------------------------------
  8707. // CERT_FIND_SUBJECT_STR_A
  8708. // CERT_FIND_SUBJECT_STR_W | CERT_FIND_SUBJECT_STR
  8709. // CERT_FIND_ISSUER_STR_A
  8710. // CERT_FIND_ISSUER_STR_W | CERT_FIND_ISSUER_STR
  8711. //
  8712. // Find a certificate containing the specified subject/issuer name string.
  8713. //
  8714. // First, the certificate's subject/issuer is converted to a name string
  8715. // via CertNameToStrA/CertNameToStrW(CERT_SIMPLE_NAME_STR). Then, a
  8716. // case insensitive substring within string match is performed.
  8717. //
  8718. // Restricts search to certificates matching the dwCertEncodingType.
  8719. //
  8720. // For *_STR_A, pvFindPara points to a null terminated character string.
  8721. // For *_STR_W, pvFindPara points to a null terminated wide character string.
  8722. //--------------------------------------------------------------------------
  8723. //+-------------------------------------------------------------------------
  8724. // CERT_FIND_KEY_SPEC
  8725. //
  8726. // Find a certificate having a CERT_KEY_SPEC_PROP_ID property matching
  8727. // the specified KeySpec.
  8728. //
  8729. // pvFindPara points to a DWORD containing the KeySpec.
  8730. //--------------------------------------------------------------------------
  8731. //+-------------------------------------------------------------------------
  8732. // CERT_FIND_ENHKEY_USAGE
  8733. //
  8734. // Find a certificate having the szOID_ENHANCED_KEY_USAGE extension or
  8735. // the CERT_ENHKEY_USAGE_PROP_ID and matching the specified pszUsageIdentifers.
  8736. //
  8737. // pvFindPara points to a CERT_ENHKEY_USAGE data structure. If pvFindPara
  8738. // is NULL or CERT_ENHKEY_USAGE's cUsageIdentifier is 0, then, matches any
  8739. // certificate having enhanced key usage.
  8740. //
  8741. // If the CERT_FIND_VALID_ENHKEY_USAGE_FLAG is set, then, only does a match
  8742. // for certificates that are valid for the specified usages. By default,
  8743. // the ceriticate must be valid for all usages. CERT_FIND_OR_ENHKEY_USAGE_FLAG
  8744. // can be set, if the certificate only needs to be valid for one of the
  8745. // specified usages. Note, CertGetValidUsages() is called to get the
  8746. // certificate's list of valid usages. Only the CERT_FIND_OR_ENHKEY_USAGE_FLAG
  8747. // is applicable when this flag is set.
  8748. //
  8749. // The CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG can be set in dwFindFlags to
  8750. // also match a certificate without either the extension or property.
  8751. //
  8752. // If CERT_FIND_NO_ENHKEY_USAGE_FLAG is set in dwFindFlags, finds
  8753. // certificates without the key usage extension or property. Setting this
  8754. // flag takes precedence over pvFindPara being NULL.
  8755. //
  8756. // If the CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG is set, then, only does a match
  8757. // using the extension. If pvFindPara is NULL or cUsageIdentifier is set to
  8758. // 0, finds certificates having the extension. If
  8759. // CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG is set, also matches a certificate
  8760. // without the extension. If CERT_FIND_NO_ENHKEY_USAGE_FLAG is set, finds
  8761. // certificates without the extension.
  8762. //
  8763. // If the CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG is set, then, only does a match
  8764. // using the property. If pvFindPara is NULL or cUsageIdentifier is set to
  8765. // 0, finds certificates having the property. If
  8766. // CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG is set, also matches a certificate
  8767. // without the property. If CERT_FIND_NO_ENHKEY_USAGE_FLAG is set, finds
  8768. // certificates without the property.
  8769. //
  8770. // If CERT_FIND_OR_ENHKEY_USAGE_FLAG is set, does an "OR" match of any of
  8771. // the specified pszUsageIdentifiers. If not set, then, does an "AND" match
  8772. // of all of the specified pszUsageIdentifiers.
  8773. //--------------------------------------------------------------------------
  8774. const
  8775. CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG = $1;
  8776. {$EXTERNALSYM CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG}
  8777. CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG = $2;
  8778. {$EXTERNALSYM CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG}
  8779. CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG = $4;
  8780. {$EXTERNALSYM CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG}
  8781. CERT_FIND_NO_ENHKEY_USAGE_FLAG = $8;
  8782. {$EXTERNALSYM CERT_FIND_NO_ENHKEY_USAGE_FLAG}
  8783. CERT_FIND_OR_ENHKEY_USAGE_FLAG = $10;
  8784. {$EXTERNALSYM CERT_FIND_OR_ENHKEY_USAGE_FLAG}
  8785. CERT_FIND_VALID_ENHKEY_USAGE_FLAG = $20;
  8786. {$EXTERNALSYM CERT_FIND_VALID_ENHKEY_USAGE_FLAG}
  8787. CERT_FIND_OPTIONAL_CTL_USAGE_FLAG = CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG;
  8788. {$EXTERNALSYM CERT_FIND_OPTIONAL_CTL_USAGE_FLAG}
  8789. CERT_FIND_EXT_ONLY_CTL_USAGE_FLAG = CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG;
  8790. {$EXTERNALSYM CERT_FIND_EXT_ONLY_CTL_USAGE_FLAG}
  8791. CERT_FIND_PROP_ONLY_CTL_USAGE_FLAG = CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG;
  8792. {$EXTERNALSYM CERT_FIND_PROP_ONLY_CTL_USAGE_FLAG}
  8793. CERT_FIND_NO_CTL_USAGE_FLAG = CERT_FIND_NO_ENHKEY_USAGE_FLAG;
  8794. {$EXTERNALSYM CERT_FIND_NO_CTL_USAGE_FLAG}
  8795. CERT_FIND_OR_CTL_USAGE_FLAG = CERT_FIND_OR_ENHKEY_USAGE_FLAG;
  8796. {$EXTERNALSYM CERT_FIND_OR_CTL_USAGE_FLAG}
  8797. CERT_FIND_VALID_CTL_USAGE_FLAG = CERT_FIND_VALID_ENHKEY_USAGE_FLAG;
  8798. {$EXTERNALSYM CERT_FIND_VALID_CTL_USAGE_FLAG}
  8799. //+-------------------------------------------------------------------------
  8800. // CERT_FIND_CERT_ID
  8801. //
  8802. // Find a certificate with the specified CERT_ID.
  8803. //
  8804. // pvFindPara points to a CERT_ID.
  8805. //--------------------------------------------------------------------------
  8806. //+-------------------------------------------------------------------------
  8807. // Get the certificate context from the store for the first or next issuer
  8808. // of the specified subject certificate. Perform the enabled
  8809. // verification checks on the subject. (Note, the checks are on the subject
  8810. // using the returned issuer certificate.)
  8811. //
  8812. // If the first or next issuer certificate isn't found, NULL is returned.
  8813. // Otherwise, a pointer to a read only CERT_CONTEXT is returned. CERT_CONTEXT
  8814. // must be freed by calling CertFreeCertificateContext or is freed when passed as the
  8815. // pPrevIssuerContext on a subsequent call. CertDuplicateCertificateContext
  8816. // can be called to make a duplicate.
  8817. //
  8818. // For a self signed subject certificate, NULL is returned with LastError set
  8819. // to CERT_STORE_SELF_SIGNED. The enabled verification checks are still done.
  8820. //
  8821. // The pSubjectContext may have been obtained from this store, another store
  8822. // or created by the caller application. When created by the caller, the
  8823. // CertCreateCertificateContext function must have been called.
  8824. //
  8825. // An issuer may have multiple certificates. This may occur when the validity
  8826. // period is about to change. pPrevIssuerContext MUST BE NULL on the first
  8827. // call to get the issuer. To get the next certificate for the issuer, the
  8828. // pPrevIssuerContext is set to the CERT_CONTEXT returned by a previous call.
  8829. //
  8830. // NOTE: a NON-NULL pPrevIssuerContext is always CertFreeCertificateContext'ed by
  8831. // this function, even for an error.
  8832. //
  8833. // The following flags can be set in *pdwFlags to enable verification checks
  8834. // on the subject certificate context:
  8835. // CERT_STORE_SIGNATURE_FLAG - use the public key in the returned
  8836. // issuer certificate to verify the
  8837. // signature on the subject certificate.
  8838. // Note, if pSubjectContext->hCertStore ==
  8839. // hCertStore, the store provider might
  8840. // be able to eliminate a redo of
  8841. // the signature verify.
  8842. // CERT_STORE_TIME_VALIDITY_FLAG - get the current time and verify that
  8843. // its within the subject certificate's
  8844. // validity period
  8845. // CERT_STORE_REVOCATION_FLAG - check if the subject certificate is on
  8846. // the issuer's revocation list
  8847. //
  8848. // If an enabled verification check fails, then, its flag is set upon return.
  8849. // If CERT_STORE_REVOCATION_FLAG was enabled and the issuer doesn't have a
  8850. // CRL in the store, then, CERT_STORE_NO_CRL_FLAG is set in addition to
  8851. // the CERT_STORE_REVOCATION_FLAG.
  8852. //
  8853. // If CERT_STORE_SIGNATURE_FLAG or CERT_STORE_REVOCATION_FLAG is set, then,
  8854. // CERT_STORE_NO_ISSUER_FLAG is set if it doesn't have an issuer certificate
  8855. // in the store.
  8856. //
  8857. // For a verification check failure, a pointer to the issuer's CERT_CONTEXT
  8858. // is still returned and SetLastError isn't updated.
  8859. //--------------------------------------------------------------------------
  8860. function CertGetIssuerCertificateFromStore(hCertStore: HCERTSTORE;
  8861. pSubjectContext, pPrevIssuerContext: PCCERT_CONTEXT; var pdwFlags: DWORD): PCCERT_CONTEXT; stdcall;
  8862. {$EXTERNALSYM CertGetIssuerCertificateFromStore}
  8863. //+-------------------------------------------------------------------------
  8864. // Perform the enabled verification checks on the subject certificate
  8865. // using the issuer. Same checks and flags definitions as for the above
  8866. // CertGetIssuerCertificateFromStore.
  8867. //
  8868. // If you are only checking CERT_STORE_TIME_VALIDITY_FLAG, then, the
  8869. // issuer can be NULL.
  8870. //
  8871. // For a verification check failure, SUCCESS is still returned.
  8872. //--------------------------------------------------------------------------
  8873. function CertVerifySubjectCertificateContext(pSubject: PCCERT_CONTEXT;
  8874. pIssuer: PCCERT_CONTEXT; var pdwFlags: DWORD): BOOL; stdcall;
  8875. {$EXTERNALSYM CertVerifySubjectCertificateContext}
  8876. //+-------------------------------------------------------------------------
  8877. // Duplicate a certificate context
  8878. //--------------------------------------------------------------------------
  8879. function CertDuplicateCertificateContext(pCertContext: PCCERT_CONTEXT): PCCERT_CONTEXT; stdcall;
  8880. {$EXTERNALSYM CertDuplicateCertificateContext}
  8881. //+-------------------------------------------------------------------------
  8882. // Create a certificate context from the encoded certificate. The created
  8883. // context isn't put in a store.
  8884. //
  8885. // Makes a copy of the encoded certificate in the created context.
  8886. //
  8887. // If unable to decode and create the certificate context, NULL is returned.
  8888. // Otherwise, a pointer to a read only CERT_CONTEXT is returned.
  8889. // CERT_CONTEXT must be freed by calling CertFreeCertificateContext.
  8890. // CertDuplicateCertificateContext can be called to make a duplicate.
  8891. //
  8892. // CertSetCertificateContextProperty and CertGetCertificateContextProperty can be called
  8893. // to store properties for the certificate.
  8894. //--------------------------------------------------------------------------
  8895. function CertCreateCertificateContext(dwCertEncodingType: DWORD;
  8896. pbCertEncoded: LPBYTE; cbCertEncoded: DWORD): PCCERT_CONTEXT; stdcall;
  8897. {$EXTERNALSYM CertCreateCertificateContext}
  8898. //+-------------------------------------------------------------------------
  8899. // Free a certificate context
  8900. //
  8901. // There needs to be a corresponding free for each context obtained by a
  8902. // get, find, duplicate or create.
  8903. //--------------------------------------------------------------------------
  8904. function CertFreeCertificateContext(pCertContext: PCCERT_CONTEXT): BOOL; stdcall;
  8905. {$EXTERNALSYM CertFreeCertificateContext}
  8906. //+-------------------------------------------------------------------------
  8907. // Set the property for the specified certificate context.
  8908. //
  8909. // The type definition for pvData depends on the dwPropId value. There are
  8910. // five predefined types:
  8911. // CERT_KEY_PROV_HANDLE_PROP_ID - a HCRYPTPROV for the certificate's
  8912. // private key is passed in pvData. Updates the hCryptProv field
  8913. // of the CERT_KEY_CONTEXT_PROP_ID. If the CERT_KEY_CONTEXT_PROP_ID
  8914. // doesn't exist, its created with all the other fields zeroed out. If
  8915. // CERT_STORE_NO_CRYPT_RELEASE_FLAG isn't set, HCRYPTPROV is implicitly
  8916. // released when either the property is set to NULL or on the final
  8917. // free of the CertContext.
  8918. //
  8919. // CERT_KEY_PROV_INFO_PROP_ID - a PCRYPT_KEY_PROV_INFO for the certificate's
  8920. // private key is passed in pvData.
  8921. //
  8922. // CERT_SHA1_HASH_PROP_ID -
  8923. // CERT_MD5_HASH_PROP_ID -
  8924. // CERT_SIGNATURE_HASH_PROP_ID - normally, a hash property is implicitly
  8925. // set by doing a CertGetCertificateContextProperty. pvData points to a
  8926. // CRYPT_HASH_BLOB.
  8927. //
  8928. // CERT_KEY_CONTEXT_PROP_ID - a PCERT_KEY_CONTEXT for the certificate's
  8929. // private key is passed in pvData. The CERT_KEY_CONTEXT contains both the
  8930. // hCryptProv and dwKeySpec for the private key.
  8931. // See the CERT_KEY_PROV_HANDLE_PROP_ID for more information about
  8932. // the hCryptProv field and dwFlags settings. Note, more fields may
  8933. // be added for this property. The cbSize field value will be adjusted
  8934. // accordingly.
  8935. //
  8936. // CERT_KEY_SPEC_PROP_ID - the dwKeySpec for the private key. pvData
  8937. // points to a DWORD containing the KeySpec
  8938. //
  8939. // CERT_ENHKEY_USAGE_PROP_ID - enhanced key usage definition for the
  8940. // certificate. pvData points to a CRYPT_DATA_BLOB containing an
  8941. // ASN.1 encoded CERT_ENHKEY_USAGE (encoded via
  8942. // CryptEncodeObject(X509_ENHANCED_KEY_USAGE).
  8943. //
  8944. // CERT_NEXT_UPDATE_LOCATION_PROP_ID - location of the next update.
  8945. // Currently only applicable to CTLs. pvData points to a CRYPT_DATA_BLOB
  8946. // containing an ASN.1 encoded CERT_ALT_NAME_INFO (encoded via
  8947. // CryptEncodeObject(X509_ALTERNATE_NAME)).
  8948. //
  8949. // CERT_FRIENDLY_NAME_PROP_ID - friendly name for the cert, CRL or CTL.
  8950. // pvData points to a CRYPT_DATA_BLOB. pbData is a pointer to a NULL
  8951. // terminated unicode, wide character string.
  8952. // cbData = (wcslen((LPWSTR) pbData) + 1) * sizeof(WCHAR).
  8953. //
  8954. // CERT_DESCRIPTION_PROP_ID - description for the cert, CRL or CTL.
  8955. // pvData points to a CRYPT_DATA_BLOB. pbData is a pointer to a NULL
  8956. // terminated unicode, wide character string.
  8957. // cbData = (wcslen((LPWSTR) pbData) + 1) * sizeof(WCHAR).
  8958. //
  8959. // CERT_ARCHIVED_PROP_ID - when this property is set, the certificate
  8960. // is skipped during enumeration. Note, certificates having this property
  8961. // are still found for explicit finds, such as, finding a certificate
  8962. // with a specific hash or finding a certificate having a specific issuer
  8963. // and serial number. pvData points to a CRYPT_DATA_BLOB. This blob
  8964. // can be NULL (pbData = NULL, cbData = 0).
  8965. //
  8966. // CERT_PUBKEY_ALG_PARA_PROP_ID - for public keys supporting
  8967. // algorithm parameter inheritance. pvData points to a CRYPT_OBJID_BLOB
  8968. // containing the ASN.1 encoded PublicKey Algorithm Parameters. For
  8969. // DSS this would be the parameters encoded via
  8970. // CryptEncodeObject(X509_DSS_PARAMETERS). This property may be set
  8971. // by CryptVerifyCertificateSignatureEx().
  8972. //
  8973. // For all the other PROP_IDs: an encoded PCRYPT_DATA_BLOB is passed in pvData.
  8974. //
  8975. // If the property already exists, then, the old value is deleted and silently
  8976. // replaced. Setting, pvData to NULL, deletes the property.
  8977. //
  8978. // CERT_SET_PROPERTY_IGNORE_PERSIST_ERROR_FLAG can be set to ignore any
  8979. // provider write errors and always update the cached context's property.
  8980. //--------------------------------------------------------------------------
  8981. function CertSetCertificateContextProperty(pCertContext: PCCERT_CONTEXT;
  8982. dwPropId: DWORD; dwFlags: DWORD; pvData: Pointer): BOOL; stdcall;
  8983. {$EXTERNALSYM CertSetCertificateContextProperty}
  8984. // Set this flag to ignore any store provider write errors and always update
  8985. // the cached context's property
  8986. const
  8987. CERT_SET_PROPERTY_IGNORE_PERSIST_ERROR_FLAG = DWORD($80000000);
  8988. {$EXTERNALSYM CERT_SET_PROPERTY_IGNORE_PERSIST_ERROR_FLAG}
  8989. //+-------------------------------------------------------------------------
  8990. // Get the property for the specified certificate context.
  8991. //
  8992. // For CERT_KEY_PROV_HANDLE_PROP_ID, pvData points to a HCRYPTPROV.
  8993. //
  8994. // For CERT_KEY_PROV_INFO_PROP_ID, pvData points to a CRYPT_KEY_PROV_INFO structure.
  8995. // Elements pointed to by fields in the pvData structure follow the
  8996. // structure. Therefore, *pcbData may exceed the size of the structure.
  8997. //
  8998. // For CERT_KEY_CONTEXT_PROP_ID, pvData points to a CERT_KEY_CONTEXT structure.
  8999. //
  9000. // For CERT_KEY_SPEC_PROP_ID, pvData points to a DWORD containing the KeySpec.
  9001. // If the CERT_KEY_CONTEXT_PROP_ID exists, the KeySpec is obtained from there.
  9002. // Otherwise, if the CERT_KEY_PROV_INFO_PROP_ID exists, its the source
  9003. // of the KeySpec.
  9004. //
  9005. // For CERT_SHA1_HASH_PROP_ID or CERT_MD5_HASH_PROP_ID, if the hash
  9006. // doesn't already exist, then, its computed via CryptHashCertificate()
  9007. // and then set. pvData points to the computed hash. Normally, the length
  9008. // is 20 bytes for SHA and 16 for MD5.
  9009. //
  9010. // For CERT_SIGNATURE_HASH_PROP_ID, if the hash
  9011. // doesn't already exist, then, its computed via CryptHashToBeSigned()
  9012. // and then set. pvData points to the computed hash. Normally, the length
  9013. // is 20 bytes for SHA and 16 for MD5.
  9014. //
  9015. // For CERT_ACCESS_STATE_PROP_ID, pvData points to a DWORD containing the
  9016. // access state flags. The appropriate CERT_ACCESS_STATE_*_FLAG's are set
  9017. // in the returned DWORD. See the CERT_ACCESS_STATE_*_FLAG definitions
  9018. // above. Note, this property is read only. It can't be set.
  9019. //
  9020. // For CERT_KEY_IDENTIFIER_PROP_ID, if property doesn't already exist,
  9021. // first searches for the szOID_SUBJECT_KEY_IDENTIFIER extension. Next,
  9022. // does SHA1 hash of the certficate's SubjectPublicKeyInfo. pvData
  9023. // points to the key identifier bytes. Normally, the length is 20 bytes.
  9024. //
  9025. // For CERT_PUBKEY_ALG_PARA_PROP_ID, pvPara points to the ASN.1 encoded
  9026. // PublicKey Algorithm Parameters. This property will only be set
  9027. // for public keys supporting algorithm parameter inheritance and when the
  9028. // parameters have been omitted from the encoded and signed certificate.
  9029. //
  9030. // For all other PROP_IDs, pvData points to an encoded array of bytes.
  9031. //--------------------------------------------------------------------------
  9032. function CertGetCertificateContextProperty(pCertContext: PCCERT_CONTEXT;
  9033. dwPropId: DWORD; pvData: Pointer; var pcbData: DWORD): BOOL; stdcall;
  9034. {$EXTERNALSYM CertGetCertificateContextProperty}
  9035. //+-------------------------------------------------------------------------
  9036. // Enumerate the properties for the specified certificate context.
  9037. //
  9038. // To get the first property, set dwPropId to 0. The ID of the first
  9039. // property is returned. To get the next property, set dwPropId to the
  9040. // ID returned by the last call. To enumerate all the properties continue
  9041. // until 0 is returned.
  9042. //
  9043. // CertGetCertificateContextProperty is called to get the property's data.
  9044. //
  9045. // Note, since, the CERT_KEY_PROV_HANDLE_PROP_ID and CERT_KEY_SPEC_PROP_ID
  9046. // properties are stored as fields in the CERT_KEY_CONTEXT_PROP_ID
  9047. // property, they aren't enumerated individually.
  9048. //--------------------------------------------------------------------------
  9049. function CertEnumCertificateContextProperties(pCertContext: PCCERT_CONTEXT;
  9050. dwPropId: DWORD): DWORD; stdcall;
  9051. {$EXTERNALSYM CertEnumCertificateContextProperties}
  9052. //+-------------------------------------------------------------------------
  9053. // Get the first or next CRL context from the store for the specified
  9054. // issuer certificate. Perform the enabled verification checks on the CRL.
  9055. //
  9056. // If the first or next CRL isn't found, NULL is returned.
  9057. // Otherwise, a pointer to a read only CRL_CONTEXT is returned. CRL_CONTEXT
  9058. // must be freed by calling CertFreeCRLContext. However, the free must be
  9059. // pPrevCrlContext on a subsequent call. CertDuplicateCRLContext
  9060. // can be called to make a duplicate.
  9061. //
  9062. // The pIssuerContext may have been obtained from this store, another store
  9063. // or created by the caller application. When created by the caller, the
  9064. // CertCreateCertificateContext function must have been called.
  9065. //
  9066. // If pIssuerContext == NULL, finds all the CRLs in the store.
  9067. //
  9068. // An issuer may have multiple CRLs. For example, it generates delta CRLs
  9069. // using a X.509 v3 extension. pPrevCrlContext MUST BE NULL on the first
  9070. // call to get the CRL. To get the next CRL for the issuer, the
  9071. // pPrevCrlContext is set to the CRL_CONTEXT returned by a previous call.
  9072. //
  9073. // NOTE: a NON-NULL pPrevCrlContext is always CertFreeCRLContext'ed by
  9074. // this function, even for an error.
  9075. //
  9076. // The following flags can be set in *pdwFlags to enable verification checks
  9077. // on the returned CRL:
  9078. // CERT_STORE_SIGNATURE_FLAG - use the public key in the
  9079. // issuer's certificate to verify the
  9080. // signature on the returned CRL.
  9081. // Note, if pIssuerContext->hCertStore ==
  9082. // hCertStore, the store provider might
  9083. // be able to eliminate a redo of
  9084. // the signature verify.
  9085. // CERT_STORE_TIME_VALIDITY_FLAG - get the current time and verify that
  9086. // its within the CRL's ThisUpdate and
  9087. // NextUpdate validity period.
  9088. //
  9089. // If an enabled verification check fails, then, its flag is set upon return.
  9090. //
  9091. // If pIssuerContext == NULL, then, an enabled CERT_STORE_SIGNATURE_FLAG
  9092. // always fails and the CERT_STORE_NO_ISSUER_FLAG is also set.
  9093. //
  9094. // For a verification check failure, a pointer to the first or next
  9095. // CRL_CONTEXT is still returned and SetLastError isn't updated.
  9096. //--------------------------------------------------------------------------
  9097. function CertGetCRLFromStore(hCertStore: HCERTSTORE; pIssuerContext: PCCERT_CONTEXT;
  9098. pPrevCrlContext: PCCRL_CONTEXT; var pdwFlags: DWORD): PCCRL_CONTEXT; stdcall;
  9099. {$EXTERNALSYM CertGetCRLFromStore}
  9100. //+-------------------------------------------------------------------------
  9101. // Enumerate the CRL contexts in the store.
  9102. //
  9103. // If a CRL isn't found, NULL is returned.
  9104. // Otherwise, a pointer to a read only CRL_CONTEXT is returned. CRL_CONTEXT
  9105. // must be freed by calling CertFreeCRLContext or is freed when passed as the
  9106. // pPrevCrlContext on a subsequent call. CertDuplicateCRLContext
  9107. // can be called to make a duplicate.
  9108. //
  9109. // pPrevCrlContext MUST BE NULL to enumerate the first
  9110. // CRL in the store. Successive CRLs are enumerated by setting
  9111. // pPrevCrlContext to the CRL_CONTEXT returned by a previous call.
  9112. //
  9113. // NOTE: a NON-NULL pPrevCrlContext is always CertFreeCRLContext'ed by
  9114. // this function, even for an error.
  9115. //--------------------------------------------------------------------------
  9116. function CertEnumCRLsInStore(hCertStore: HCERTSTORE;
  9117. pPrevCrlContext: PCCRL_CONTEXT): PCCRL_CONTEXT; stdcall;
  9118. {$EXTERNALSYM CertEnumCRLsInStore}
  9119. //+-------------------------------------------------------------------------
  9120. // Find the first or next CRL context in the store.
  9121. //
  9122. // The CRL is found according to the dwFindType and its pvFindPara.
  9123. // See below for a list of the find types and its parameters.
  9124. //
  9125. // Currently dwFindFlags isn't used and must be set to 0.
  9126. //
  9127. // Usage of dwCertEncodingType depends on the dwFindType.
  9128. //
  9129. // If the first or next CRL isn't found, NULL is returned.
  9130. // Otherwise, a pointer to a read only CRL_CONTEXT is returned. CRL_CONTEXT
  9131. // must be freed by calling CertFreeCRLContext or is freed when passed as the
  9132. // pPrevCrlContext on a subsequent call. CertDuplicateCRLContext
  9133. // can be called to make a duplicate.
  9134. //
  9135. // pPrevCrlContext MUST BE NULL on the first
  9136. // call to find the CRL. To find the next CRL, the
  9137. // pPrevCrlContext is set to the CRL_CONTEXT returned by a previous call.
  9138. //
  9139. // NOTE: a NON-NULL pPrevCrlContext is always CertFreeCRLContext'ed by
  9140. // this function, even for an error.
  9141. //--------------------------------------------------------------------------
  9142. function CertFindCRLInStore(hCertStore: HCERTSTORE; dwCertEncodingType: DWORD;
  9143. dwFindFlags: DWORD; dwFindType: DWORD; pvFindPara: Pointer;
  9144. pPrevCrlContext: PCCRL_CONTEXT): PCCRL_CONTEXT; stdcall;
  9145. {$EXTERNALSYM CertFindCRLInStore}
  9146. const
  9147. CRL_FIND_ANY = 0;
  9148. {$EXTERNALSYM CRL_FIND_ANY}
  9149. CRL_FIND_ISSUED_BY = 1;
  9150. {$EXTERNALSYM CRL_FIND_ISSUED_BY}
  9151. CRL_FIND_EXISTING = 2;
  9152. {$EXTERNALSYM CRL_FIND_EXISTING}
  9153. //+-------------------------------------------------------------------------
  9154. // CRL_FIND_ANY
  9155. //
  9156. // Find any CRL.
  9157. //
  9158. // pvFindPara isn't used.
  9159. //--------------------------------------------------------------------------
  9160. //+-------------------------------------------------------------------------
  9161. // CRL_FIND_ISSUED_BY
  9162. //
  9163. // Find CRL matching the specified issuer.
  9164. //
  9165. // pvFindPara is the PCCERT_CONTEXT of the CRL issuer.
  9166. //
  9167. // By default, only does issuer name matching. The following flags can be
  9168. // set in dwFindFlags to do additional filtering.
  9169. //
  9170. // If CRL_FIND_ISSUED_BY_AKI_FLAG is set in dwFindFlags, then, checks if the
  9171. // CRL has an Authority Key Identifier (AKI) extension. If the CRL has an
  9172. // AKI, then, only returns a CRL whose AKI matches the issuer.
  9173. //
  9174. // Note, the AKI extension has the following OID:
  9175. // szOID_AUTHORITY_KEY_IDENTIFIER2 and its corresponding data structure.
  9176. //
  9177. // If CRL_FIND_ISSUED_BY_SIGNATURE_FLAG is set in dwFindFlags, then,
  9178. // uses the public key in the issuer's certificate to verify the
  9179. // signature on the CRL. Only returns a CRL having a valid signature.
  9180. //--------------------------------------------------------------------------
  9181. const
  9182. CRL_FIND_ISSUED_BY_AKI_FLAG = $1;
  9183. {$EXTERNALSYM CRL_FIND_ISSUED_BY_AKI_FLAG}
  9184. CRL_FIND_ISSUED_BY_SIGNATURE_FLAG = $2;
  9185. {$EXTERNALSYM CRL_FIND_ISSUED_BY_SIGNATURE_FLAG}
  9186. //+-------------------------------------------------------------------------
  9187. // CRL_FIND_EXISTING
  9188. //
  9189. // Find existing CRL in the store.
  9190. //
  9191. // pvFindPara is the PCCRL_CONTEXT of the CRL to check if it already
  9192. // exists in the store.
  9193. //--------------------------------------------------------------------------
  9194. //+-------------------------------------------------------------------------
  9195. // Duplicate a CRL context
  9196. //--------------------------------------------------------------------------
  9197. function CertDuplicateCRLContext(pCrlContext: PCCRL_CONTEXT): PCCRL_CONTEXT; stdcall;
  9198. {$EXTERNALSYM CertDuplicateCRLContext}
  9199. //+-------------------------------------------------------------------------
  9200. // Create a CRL context from the encoded CRL. The created
  9201. // context isn't put in a store.
  9202. //
  9203. // Makes a copy of the encoded CRL in the created context.
  9204. //
  9205. // If unable to decode and create the CRL context, NULL is returned.
  9206. // Otherwise, a pointer to a read only CRL_CONTEXT is returned.
  9207. // CRL_CONTEXT must be freed by calling CertFreeCRLContext.
  9208. // CertDuplicateCRLContext can be called to make a duplicate.
  9209. //
  9210. // CertSetCRLContextProperty and CertGetCRLContextProperty can be called
  9211. // to store properties for the CRL.
  9212. //--------------------------------------------------------------------------
  9213. function CertCreateCRLContext(dwCertEncodingType: DWORD; pbCrlEncoded: LPBYTE;
  9214. cbCrlEncoded: DWORD): PCCRL_CONTEXT; stdcall;
  9215. {$EXTERNALSYM CertCreateCRLContext}
  9216. //+-------------------------------------------------------------------------
  9217. // Free a CRL context
  9218. //
  9219. // There needs to be a corresponding free for each context obtained by a
  9220. // get, duplicate or create.
  9221. //--------------------------------------------------------------------------
  9222. function CertFreeCRLContext(pCrlContext: PCCRL_CONTEXT): BOOL; stdcall;
  9223. {$EXTERNALSYM CertFreeCRLContext}
  9224. //+-------------------------------------------------------------------------
  9225. // Set the property for the specified CRL context.
  9226. //
  9227. // Same Property Ids and semantics as CertSetCertificateContextProperty.
  9228. //--------------------------------------------------------------------------
  9229. function CertSetCRLContextProperty(pCrlContext: PCCRL_CONTEXT; dwPropId: DWORD;
  9230. dwFlags: DWORD; pvData: Pointer): BOOL; stdcall;
  9231. {$EXTERNALSYM CertSetCRLContextProperty}
  9232. //+-------------------------------------------------------------------------
  9233. // Get the property for the specified CRL context.
  9234. //
  9235. // Same Property Ids and semantics as CertGetCertificateContextProperty.
  9236. //
  9237. // CERT_SHA1_HASH_PROP_ID, CERT_MD5_HASH_PROP_ID or
  9238. // CERT_SIGNATURE_HASH_PROP_ID is the predefined property of most interest.
  9239. //--------------------------------------------------------------------------
  9240. function CertGetCRLContextProperty(pCrlContext: PCCRL_CONTEXT; dwPropId: DWORD;
  9241. pvData: Pointer; var pcbData: DWORD): BOOL; stdcall;
  9242. {$EXTERNALSYM CertGetCRLContextProperty}
  9243. //+-------------------------------------------------------------------------
  9244. // Enumerate the properties for the specified CRL context.
  9245. //
  9246. // To get the first property, set dwPropId to 0. The ID of the first
  9247. // property is returned. To get the next property, set dwPropId to the
  9248. // ID returned by the last call. To enumerate all the properties continue
  9249. // until 0 is returned.
  9250. //
  9251. // CertGetCRLContextProperty is called to get the property's data.
  9252. //--------------------------------------------------------------------------
  9253. function CertEnumCRLContextProperties(pCrlContext: PCCRL_CONTEXT;
  9254. dwPropId: DWORD): DWORD; stdcall;
  9255. {$EXTERNALSYM CertEnumCRLContextProperties}
  9256. //+-------------------------------------------------------------------------
  9257. // Search the CRL's list of entries for the specified certificate.
  9258. //
  9259. // TRUE is returned if we were able to search the list. Otherwise, FALSE is
  9260. // returned,
  9261. //
  9262. // For success, if the certificate was found in the list, *ppCrlEntry is
  9263. // updated with a pointer to the entry. Otherwise, *ppCrlEntry is set to NULL.
  9264. // The returned entry isn't allocated and must not be freed.
  9265. //
  9266. // dwFlags and pvReserved currently aren't used and must be set to 0 or NULL.
  9267. //--------------------------------------------------------------------------
  9268. function CertFindCertificateInCRL(pCert: PCCERT_CONTEXT; pCrlContext: PCCRL_CONTEXT;
  9269. dwFlags: DWORD; pvReserved: Pointer; var ppCrlEntry: PCRL_ENTRY): BOOL; stdcall;
  9270. {$EXTERNALSYM CertFindCertificateInCRL}
  9271. //+-------------------------------------------------------------------------
  9272. // Add certificate/CRL, encoded, context or element disposition values.
  9273. //--------------------------------------------------------------------------
  9274. const
  9275. CERT_STORE_ADD_NEW = 1;
  9276. {$EXTERNALSYM CERT_STORE_ADD_NEW}
  9277. CERT_STORE_ADD_USE_EXISTING = 2;
  9278. {$EXTERNALSYM CERT_STORE_ADD_USE_EXISTING}
  9279. CERT_STORE_ADD_REPLACE_EXISTING = 3;
  9280. {$EXTERNALSYM CERT_STORE_ADD_REPLACE_EXISTING}
  9281. CERT_STORE_ADD_ALWAYS = 4;
  9282. {$EXTERNALSYM CERT_STORE_ADD_ALWAYS}
  9283. CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES = 5;
  9284. {$EXTERNALSYM CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES}
  9285. CERT_STORE_ADD_NEWER = 6;
  9286. {$EXTERNALSYM CERT_STORE_ADD_NEWER}
  9287. CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES = 7;
  9288. {$EXTERNALSYM CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES}
  9289. //+-------------------------------------------------------------------------
  9290. // Add the encoded certificate to the store according to the specified
  9291. // disposition action.
  9292. //
  9293. // Makes a copy of the encoded certificate before adding to the store.
  9294. //
  9295. // dwAddDispostion specifies the action to take if the certificate
  9296. // already exists in the store. This parameter must be one of the following
  9297. // values:
  9298. // CERT_STORE_ADD_NEW
  9299. // Fails if the certificate already exists in the store. LastError
  9300. // is set to CRYPT_E_EXISTS.
  9301. // CERT_STORE_ADD_USE_EXISTING
  9302. // If the certifcate already exists, then, its used and if ppCertContext
  9303. // is non-NULL, the existing context is duplicated.
  9304. // CERT_STORE_ADD_REPLACE_EXISTING
  9305. // If the certificate already exists, then, the existing certificate
  9306. // context is deleted before creating and adding the new context.
  9307. // CERT_STORE_ADD_ALWAYS
  9308. // No check is made to see if the certificate already exists. A
  9309. // new certificate context is always created. This may lead to
  9310. // duplicates in the store.
  9311. // CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES
  9312. // If the certificate already exists, then, its used.
  9313. // CERT_STORE_ADD_NEWER
  9314. // Fails if the certificate already exists in the store AND the NotBefore
  9315. // time of the existing certificate is equal to or greater than the
  9316. // NotBefore time of the new certificate being added. LastError
  9317. // is set to CRYPT_E_EXISTS.
  9318. //
  9319. // If an older certificate is replaced, same as
  9320. // CERT_STORE_ADD_REPLACE_EXISTING.
  9321. //
  9322. // For CRLs or CTLs compares the ThisUpdate times.
  9323. //
  9324. // CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES
  9325. // Same as CERT_STORE_ADD_NEWER. However, if an older certificate is
  9326. // replaced, same as CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES.
  9327. //
  9328. // CertGetSubjectCertificateFromStore is called to determine if the
  9329. // certificate already exists in the store.
  9330. //
  9331. // ppCertContext can be NULL, indicating the caller isn't interested
  9332. // in getting the CERT_CONTEXT of the added or existing certificate.
  9333. //--------------------------------------------------------------------------
  9334. function CertAddEncodedCertificateToStore(hCertStore: HCERTSTORE;
  9335. dwCertEncodingType: DWORD; pbCertEncoded: LPBYTE; cbCertEncoded: DWORD;
  9336. dwAddDisposition: DWORD; ppCertContext: PPCCERT_CONTEXT): BOOL; stdcall;
  9337. {$EXTERNALSYM CertAddEncodedCertificateToStore}
  9338. //+-------------------------------------------------------------------------
  9339. // Add the certificate context to the store according to the specified
  9340. // disposition action.
  9341. //
  9342. // In addition to the encoded certificate, the context's properties are
  9343. // also copied. Note, the CERT_KEY_CONTEXT_PROP_ID property (and its
  9344. // CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_SPEC_PROP_ID) isn't copied.
  9345. //
  9346. // Makes a copy of the certificate context before adding to the store.
  9347. //
  9348. // dwAddDispostion specifies the action to take if the certificate
  9349. // already exists in the store. This parameter must be one of the following
  9350. // values:
  9351. // CERT_STORE_ADD_NEW
  9352. // Fails if the certificate already exists in the store. LastError
  9353. // is set to CRYPT_E_EXISTS.
  9354. // CERT_STORE_ADD_USE_EXISTING
  9355. // If the certifcate already exists, then, its used and if ppStoreContext
  9356. // is non-NULL, the existing context is duplicated. Iterates
  9357. // through pCertContext's properties and only copies the properties
  9358. // that don't already exist. The SHA1 and MD5 hash properties aren't
  9359. // copied.
  9360. // CERT_STORE_ADD_REPLACE_EXISTING
  9361. // If the certificate already exists, then, the existing certificate
  9362. // context is deleted before creating and adding a new context.
  9363. // Properties are copied before doing the add.
  9364. // CERT_STORE_ADD_ALWAYS
  9365. // No check is made to see if the certificate already exists. A
  9366. // new certificate context is always created and added. This may lead to
  9367. // duplicates in the store. Properties are
  9368. // copied before doing the add.
  9369. // CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES
  9370. // If the certificate already exists, then, the existing certificate
  9371. // context is used. Properties from the added context are copied and
  9372. // replace existing properties. However, any existing properties not
  9373. // in the added context remain and aren't deleted.
  9374. // CERT_STORE_ADD_NEWER
  9375. // Fails if the certificate already exists in the store AND the NotBefore
  9376. // time of the existing context is equal to or greater than the
  9377. // NotBefore time of the new context being added. LastError
  9378. // is set to CRYPT_E_EXISTS.
  9379. //
  9380. // If an older context is replaced, same as
  9381. // CERT_STORE_ADD_REPLACE_EXISTING.
  9382. //
  9383. // For CRLs or CTLs compares the ThisUpdate times.
  9384. //
  9385. // CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES
  9386. // Same as CERT_STORE_ADD_NEWER. However, if an older context is
  9387. // replaced, same as CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES.
  9388. //
  9389. // CertGetSubjectCertificateFromStore is called to determine if the
  9390. // certificate already exists in the store.
  9391. //
  9392. // ppStoreContext can be NULL, indicating the caller isn't interested
  9393. // in getting the CERT_CONTEXT of the added or existing certificate.
  9394. //--------------------------------------------------------------------------
  9395. function CertAddCertificateContextToStore(hCertStore: HCERTSTORE;
  9396. pCertContext: PCCERT_CONTEXT; dwAddDisposition: DWORD;
  9397. ppStoreContext: PPCCERT_CONTEXT): BOOL; stdcall;
  9398. {$EXTERNALSYM CertAddCertificateContextToStore}
  9399. //+-------------------------------------------------------------------------
  9400. // Certificate Store Context Types
  9401. //--------------------------------------------------------------------------
  9402. const
  9403. CERT_STORE_CERTIFICATE_CONTEXT = 1;
  9404. {$EXTERNALSYM CERT_STORE_CERTIFICATE_CONTEXT}
  9405. CERT_STORE_CRL_CONTEXT = 2;
  9406. {$EXTERNALSYM CERT_STORE_CRL_CONTEXT}
  9407. CERT_STORE_CTL_CONTEXT = 3;
  9408. {$EXTERNALSYM CERT_STORE_CTL_CONTEXT}
  9409. //+-------------------------------------------------------------------------
  9410. // Certificate Store Context Bit Flags
  9411. //--------------------------------------------------------------------------
  9412. CERT_STORE_ALL_CONTEXT_FLAG = not 0;
  9413. {$EXTERNALSYM CERT_STORE_ALL_CONTEXT_FLAG}
  9414. CERT_STORE_CERTIFICATE_CONTEXT_FLAG = 1 shl CERT_STORE_CERTIFICATE_CONTEXT;
  9415. {$EXTERNALSYM CERT_STORE_CERTIFICATE_CONTEXT_FLAG}
  9416. CERT_STORE_CRL_CONTEXT_FLAG = 1 shl CERT_STORE_CRL_CONTEXT;
  9417. {$EXTERNALSYM CERT_STORE_CRL_CONTEXT_FLAG}
  9418. CERT_STORE_CTL_CONTEXT_FLAG = 1 shl CERT_STORE_CTL_CONTEXT;
  9419. {$EXTERNALSYM CERT_STORE_CTL_CONTEXT_FLAG}
  9420. //+-------------------------------------------------------------------------
  9421. // Add the serialized certificate or CRL element to the store.
  9422. //
  9423. // The serialized element contains the encoded certificate, CRL or CTL and
  9424. // its properties, such as, CERT_KEY_PROV_INFO_PROP_ID.
  9425. //
  9426. // If hCertStore is NULL, creates a certificate, CRL or CTL context not
  9427. // residing in any store.
  9428. //
  9429. // dwAddDispostion specifies the action to take if the certificate or CRL
  9430. // already exists in the store. See CertAddCertificateContextToStore for a
  9431. // list of and actions taken.
  9432. //
  9433. // dwFlags currently isn't used and should be set to 0.
  9434. //
  9435. // dwContextTypeFlags specifies the set of allowable contexts. For example, to
  9436. // add either a certificate or CRL, set dwContextTypeFlags to:
  9437. // CERT_STORE_CERTIFICATE_CONTEXT_FLAG | CERT_STORE_CRL_CONTEXT_FLAG
  9438. //
  9439. // *pdwContextType is updated with the type of the context returned in
  9440. // *ppvContxt. pdwContextType or ppvContext can be NULL, indicating the
  9441. // caller isn't interested in getting the output. If *ppvContext is
  9442. // returned it must be freed by calling CertFreeCertificateContext or
  9443. // CertFreeCRLContext.
  9444. //--------------------------------------------------------------------------
  9445. function CertAddSerializedElementToStore(hCertStore: HCERTSTORE; pbElement: LPBYTE;
  9446. cbElement, dwAddDisposition, dwFlags, dwContextTypeFlags: DWORD;
  9447. pdwContextType: LPDWORD; ppvContext: PPointer): BOOL; stdcall;
  9448. {$EXTERNALSYM CertAddSerializedElementToStore}
  9449. //+-------------------------------------------------------------------------
  9450. // Delete the specified certificate from the store.
  9451. //
  9452. // All subsequent gets or finds for the certificate will fail. However,
  9453. // memory allocated for the certificate isn't freed until all of its contexts
  9454. // have also been freed.
  9455. //
  9456. // The pCertContext is obtained from a get, enum, find or duplicate.
  9457. //
  9458. // Some store provider implementations might also delete the issuer's CRLs
  9459. // if this is the last certificate for the issuer in the store.
  9460. //
  9461. // NOTE: the pCertContext is always CertFreeCertificateContext'ed by
  9462. // this function, even for an error.
  9463. //--------------------------------------------------------------------------
  9464. function CertDeleteCertificateFromStore(pCertContext: PCCERT_CONTEXT): BOOL; stdcall;
  9465. {$EXTERNALSYM CertDeleteCertificateFromStore}
  9466. //+-------------------------------------------------------------------------
  9467. // Add the encoded CRL to the store according to the specified
  9468. // disposition option.
  9469. //
  9470. // Makes a copy of the encoded CRL before adding to the store.
  9471. //
  9472. // dwAddDispostion specifies the action to take if the CRL
  9473. // already exists in the store. See CertAddEncodedCertificateToStore for a
  9474. // list of and actions taken.
  9475. //
  9476. // Compares the CRL's Issuer to determine if the CRL already exists in the
  9477. // store.
  9478. //
  9479. // ppCrlContext can be NULL, indicating the caller isn't interested
  9480. // in getting the CRL_CONTEXT of the added or existing CRL.
  9481. //--------------------------------------------------------------------------
  9482. function CertAddEncodedCRLToStore(hCertStore: HCERTSTORE; dwCertEncodingType: DWORD;
  9483. pbCrlEncoded: LPBYTE; cbCrlEncoded, dwAddDisposition: DWORD;
  9484. ppCrlContext: PPCCRL_CONTEXT): BOOL; stdcall;
  9485. {$EXTERNALSYM CertAddEncodedCRLToStore}
  9486. //+-------------------------------------------------------------------------
  9487. // Add the CRL context to the store according to the specified
  9488. // disposition option.
  9489. //
  9490. // In addition to the encoded CRL, the context's properties are
  9491. // also copied. Note, the CERT_KEY_CONTEXT_PROP_ID property (and its
  9492. // CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_SPEC_PROP_ID) isn't copied.
  9493. //
  9494. // Makes a copy of the encoded CRL before adding to the store.
  9495. //
  9496. // dwAddDispostion specifies the action to take if the CRL
  9497. // already exists in the store. See CertAddCertificateContextToStore for a
  9498. // list of and actions taken.
  9499. //
  9500. // Compares the CRL's Issuer, ThisUpdate and NextUpdate to determine
  9501. // if the CRL already exists in the store.
  9502. //
  9503. // ppStoreContext can be NULL, indicating the caller isn't interested
  9504. // in getting the CRL_CONTEXT of the added or existing CRL.
  9505. //--------------------------------------------------------------------------
  9506. function CertAddCRLContextToStore(hCertStore: HCERTSTORE; pCrlContext: PCCRL_CONTEXT;
  9507. dwAddDisposition: DWORD; ppStoreContext: PPCCRL_CONTEXT): BOOL; stdcall;
  9508. {$EXTERNALSYM CertAddCRLContextToStore}
  9509. //+-------------------------------------------------------------------------
  9510. // Delete the specified CRL from the store.
  9511. //
  9512. // All subsequent gets for the CRL will fail. However,
  9513. // memory allocated for the CRL isn't freed until all of its contexts
  9514. // have also been freed.
  9515. //
  9516. // The pCrlContext is obtained from a get or duplicate.
  9517. //
  9518. // NOTE: the pCrlContext is always CertFreeCRLContext'ed by
  9519. // this function, even for an error.
  9520. //--------------------------------------------------------------------------
  9521. function CertDeleteCRLFromStore(pCrlContext: PCCRL_CONTEXT): BOOL; stdcall;
  9522. {$EXTERNALSYM CertDeleteCRLFromStore}
  9523. //+-------------------------------------------------------------------------
  9524. // Serialize the certificate context's encoded certificate and its
  9525. // properties.
  9526. //--------------------------------------------------------------------------
  9527. function CertSerializeCertificateStoreElement(pCertContext: PCCERT_CONTEXT;
  9528. dwFlags: DWORD; pbElement: LPBYTE; var pcbElement: DWORD): BOOL; stdcall;
  9529. {$EXTERNALSYM CertSerializeCertificateStoreElement}
  9530. //+-------------------------------------------------------------------------
  9531. // Serialize the CRL context's encoded CRL and its properties.
  9532. //--------------------------------------------------------------------------
  9533. function CertSerializeCRLStoreElement(pCrlContext: PCCRL_CONTEXT; dwFlags: DWORD;
  9534. pbElement: LPBYTE; var pcbElement: DWORD): BOOL; stdcall;
  9535. {$EXTERNALSYM CertSerializeCRLStoreElement}
  9536. //+=========================================================================
  9537. // Certificate Trust List (CTL) Store Data Structures and APIs
  9538. //==========================================================================
  9539. //+-------------------------------------------------------------------------
  9540. // Duplicate a CTL context
  9541. //--------------------------------------------------------------------------
  9542. function CertDuplicateCTLContext(pCtlContext: PCCTL_CONTEXT): PCCTL_CONTEXT; stdcall;
  9543. {$EXTERNALSYM CertDuplicateCTLContext}
  9544. //+-------------------------------------------------------------------------
  9545. // Create a CTL context from the encoded CTL. The created
  9546. // context isn't put in a store.
  9547. //
  9548. // Makes a copy of the encoded CTL in the created context.
  9549. //
  9550. // If unable to decode and create the CTL context, NULL is returned.
  9551. // Otherwise, a pointer to a read only CTL_CONTEXT is returned.
  9552. // CTL_CONTEXT must be freed by calling CertFreeCTLContext.
  9553. // CertDuplicateCTLContext can be called to make a duplicate.
  9554. //
  9555. // CertSetCTLContextProperty and CertGetCTLContextProperty can be called
  9556. // to store properties for the CTL.
  9557. //--------------------------------------------------------------------------
  9558. function CertCreateCTLContext(dwMsgAndCertEncodingType: DWORD;
  9559. pbCtlEncoded: LPBYTE; cbCtlEncoded: DWORD): PCCTL_CONTEXT; stdcall;
  9560. {$EXTERNALSYM CertCreateCTLContext}
  9561. //+-------------------------------------------------------------------------
  9562. // Free a CTL context
  9563. //
  9564. // There needs to be a corresponding free for each context obtained by a
  9565. // get, duplicate or create.
  9566. //--------------------------------------------------------------------------
  9567. function CertFreeCTLContext(pCtlContext: PCCTL_CONTEXT): BOOL; stdcall;
  9568. {$EXTERNALSYM CertFreeCTLContext}
  9569. //+-------------------------------------------------------------------------
  9570. // Set the property for the specified CTL context.
  9571. //
  9572. // Same Property Ids and semantics as CertSetCertificateContextProperty.
  9573. //--------------------------------------------------------------------------
  9574. function CertSetCTLContextProperty(pCtlContext: PCCTL_CONTEXT; dwPropId: DWORD;
  9575. dwFlags: DWORD; pvData: Pointer): BOOL; stdcall;
  9576. {$EXTERNALSYM CertSetCTLContextProperty}
  9577. //+-------------------------------------------------------------------------
  9578. // Get the property for the specified CTL context.
  9579. //
  9580. // Same Property Ids and semantics as CertGetCertificateContextProperty.
  9581. //
  9582. // CERT_SHA1_HASH_PROP_ID or CERT_NEXT_UPDATE_LOCATION_PROP_ID are the
  9583. // predefined properties of most interest.
  9584. //--------------------------------------------------------------------------
  9585. function CertGetCTLContextProperty(pCtlContext: PCCTL_CONTEXT; dwPropId: DWORD;
  9586. pvData: Pointer; var pcbData: DWORD): BOOL; stdcall;
  9587. {$EXTERNALSYM CertGetCTLContextProperty}
  9588. //+-------------------------------------------------------------------------
  9589. // Enumerate the properties for the specified CTL context.
  9590. //--------------------------------------------------------------------------
  9591. function CertEnumCTLContextProperties(pCtlContext: PCCTL_CONTEXT; dwPropId: DWORD): DWORD; stdcall;
  9592. {$EXTERNALSYM CertEnumCTLContextProperties}
  9593. //+-------------------------------------------------------------------------
  9594. // Enumerate the CTL contexts in the store.
  9595. //
  9596. // If a CTL isn't found, NULL is returned.
  9597. // Otherwise, a pointer to a read only CTL_CONTEXT is returned. CTL_CONTEXT
  9598. // must be freed by calling CertFreeCTLContext or is freed when passed as the
  9599. // pPrevCtlContext on a subsequent call. CertDuplicateCTLContext
  9600. // can be called to make a duplicate.
  9601. //
  9602. // pPrevCtlContext MUST BE NULL to enumerate the first
  9603. // CTL in the store. Successive CTLs are enumerated by setting
  9604. // pPrevCtlContext to the CTL_CONTEXT returned by a previous call.
  9605. //
  9606. // NOTE: a NON-NULL pPrevCtlContext is always CertFreeCTLContext'ed by
  9607. // this function, even for an error.
  9608. //--------------------------------------------------------------------------
  9609. function CertEnumCTLsInStore(hCertStore: HCERTSTORE; pPrevCtlContext: PCCTL_CONTEXT): PCCTL_CONTEXT; stdcall;
  9610. {$EXTERNALSYM CertEnumCTLsInStore}
  9611. //+-------------------------------------------------------------------------
  9612. // Attempt to find the specified subject in the CTL.
  9613. //
  9614. // For CTL_CERT_SUBJECT_TYPE, pvSubject points to a CERT_CONTEXT. The CTL's
  9615. // SubjectAlgorithm is examined to determine the representation of the
  9616. // subject's identity. Initially, only SHA1 or MD5 hash will be supported.
  9617. // The appropriate hash property is obtained from the CERT_CONTEXT.
  9618. //
  9619. // For CTL_ANY_SUBJECT_TYPE, pvSubject points to the CTL_ANY_SUBJECT_INFO
  9620. // structure which contains the SubjectAlgorithm to be matched in the CTL
  9621. // and the SubjectIdentifer to be matched in one of the CTL entries.
  9622. //
  9623. // The certificate's hash or the CTL_ANY_SUBJECT_INFO's SubjectIdentifier
  9624. // is used as the key in searching the subject entries. A binary
  9625. // memory comparison is done between the key and the entry's SubjectIdentifer.
  9626. //
  9627. // dwEncodingType isn't used for either of the above SubjectTypes.
  9628. //--------------------------------------------------------------------------
  9629. function CertFindSubjectInCTL(dwEncodingType: DWORD; dwSubjectType: DWORD;
  9630. pvSubject: Pointer; pCtlContext: PCCTL_CONTEXT; dwFlags: DWORD): PCTL_ENTRY; stdcall;
  9631. {$EXTERNALSYM CertFindSubjectInCTL}
  9632. // Subject Types:
  9633. // CTL_ANY_SUBJECT_TYPE, pvSubject points to following CTL_ANY_SUBJECT_INFO.
  9634. // CTL_CERT_SUBJECT_TYPE, pvSubject points to CERT_CONTEXT.
  9635. const
  9636. CTL_ANY_SUBJECT_TYPE = 1;
  9637. {$EXTERNALSYM CTL_ANY_SUBJECT_TYPE}
  9638. CTL_CERT_SUBJECT_TYPE = 2;
  9639. {$EXTERNALSYM CTL_CERT_SUBJECT_TYPE}
  9640. type
  9641. PCTL_ANY_SUBJECT_INFO = ^CTL_ANY_SUBJECT_INFO;
  9642. {$EXTERNALSYM PCTL_ANY_SUBJECT_INFO}
  9643. _CTL_ANY_SUBJECT_INFO = record
  9644. SubjectAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  9645. SubjectIdentifier: CRYPT_DATA_BLOB;
  9646. end;
  9647. {$EXTERNALSYM _CTL_ANY_SUBJECT_INFO}
  9648. CTL_ANY_SUBJECT_INFO = _CTL_ANY_SUBJECT_INFO;
  9649. {$EXTERNALSYM CTL_ANY_SUBJECT_INFO}
  9650. TCtlAnySubjectInfo = CTL_ANY_SUBJECT_INFO;
  9651. PCtlAnySubjectInfo = PCTL_ANY_SUBJECT_INFO;
  9652. //+-------------------------------------------------------------------------
  9653. // Find the first or next CTL context in the store.
  9654. //
  9655. // The CTL is found according to the dwFindType and its pvFindPara.
  9656. // See below for a list of the find types and its parameters.
  9657. //
  9658. // Currently dwFindFlags isn't used and must be set to 0.
  9659. //
  9660. // Usage of dwMsgAndCertEncodingType depends on the dwFindType.
  9661. //
  9662. // If the first or next CTL isn't found, NULL is returned.
  9663. // Otherwise, a pointer to a read only CTL_CONTEXT is returned. CTL_CONTEXT
  9664. // must be freed by calling CertFreeCTLContext or is freed when passed as the
  9665. // pPrevCtlContext on a subsequent call. CertDuplicateCTLContext
  9666. // can be called to make a duplicate.
  9667. //
  9668. // pPrevCtlContext MUST BE NULL on the first
  9669. // call to find the CTL. To find the next CTL, the
  9670. // pPrevCtlContext is set to the CTL_CONTEXT returned by a previous call.
  9671. //
  9672. // NOTE: a NON-NULL pPrevCtlContext is always CertFreeCTLContext'ed by
  9673. // this function, even for an error.
  9674. //--------------------------------------------------------------------------
  9675. function CertFindCTLInStore(hCertStore: HCERTSTORE; dwMsgAndCertEncodingType,
  9676. dwFindFlags, dwFindType: DWORD; pvFindPara: Pointer;
  9677. pPrevCtlContext: PCCTL_CONTEXT): PCCTL_CONTEXT; stdcall;
  9678. {$EXTERNALSYM CertFindCTLInStore}
  9679. const
  9680. CTL_FIND_ANY = 0;
  9681. {$EXTERNALSYM CTL_FIND_ANY}
  9682. CTL_FIND_SHA1_HASH = 1;
  9683. {$EXTERNALSYM CTL_FIND_SHA1_HASH}
  9684. CTL_FIND_MD5_HASH = 2;
  9685. {$EXTERNALSYM CTL_FIND_MD5_HASH}
  9686. CTL_FIND_USAGE = 3;
  9687. {$EXTERNALSYM CTL_FIND_USAGE}
  9688. CTL_FIND_SUBJECT = 4;
  9689. {$EXTERNALSYM CTL_FIND_SUBJECT}
  9690. CTL_FIND_EXISTING = 5;
  9691. {$EXTERNALSYM CTL_FIND_EXISTING}
  9692. type
  9693. PCTL_FIND_USAGE_PARA = ^CTL_FIND_USAGE_PARA;
  9694. {$EXTERNALSYM PCTL_FIND_USAGE_PARA}
  9695. _CTL_FIND_USAGE_PARA = record
  9696. cbSize: DWORD;
  9697. SubjectUsage: CTL_USAGE; // optional
  9698. ListIdentifier: CRYPT_DATA_BLOB; // optional
  9699. pSigner: PCERT_INFO; // optional
  9700. end;
  9701. {$EXTERNALSYM _CTL_FIND_USAGE_PARA}
  9702. CTL_FIND_USAGE_PARA = _CTL_FIND_USAGE_PARA;
  9703. {$EXTERNALSYM CTL_FIND_USAGE_PARA}
  9704. TCtlFindUsagePara = CTL_FIND_USAGE_PARA;
  9705. PCtlFindUsagePara = PCTL_FIND_USAGE_PARA;
  9706. const
  9707. CTL_FIND_NO_LIST_ID_CBDATA = DWORD($FFFFFFFF);
  9708. {$EXTERNALSYM CTL_FIND_NO_LIST_ID_CBDATA}
  9709. CTL_FIND_NO_SIGNER_PTR = PCERT_INFO(-1);
  9710. {$EXTERNALSYM CTL_FIND_NO_SIGNER_PTR}
  9711. CTL_FIND_SAME_USAGE_FLAG = $1;
  9712. {$EXTERNALSYM CTL_FIND_SAME_USAGE_FLAG}
  9713. type
  9714. PCTL_FIND_SUBJECT_PARA = ^CTL_FIND_SUBJECT_PARA;
  9715. {$EXTERNALSYM PCTL_FIND_SUBJECT_PARA}
  9716. _CTL_FIND_SUBJECT_PARA = record
  9717. cbSize: DWORD;
  9718. pUsagePara: PCTL_FIND_USAGE_PARA; // optional
  9719. dwSubjectType: DWORD;
  9720. pvSubject: Pointer;
  9721. end;
  9722. {$EXTERNALSYM _CTL_FIND_SUBJECT_PARA}
  9723. CTL_FIND_SUBJECT_PARA = _CTL_FIND_SUBJECT_PARA;
  9724. {$EXTERNALSYM CTL_FIND_SUBJECT_PARA}
  9725. TCtlFindSubjectPara = CTL_FIND_SUBJECT_PARA;
  9726. PCtlFindSubjectPara = PCTL_FIND_SUBJECT_PARA;
  9727. //+-------------------------------------------------------------------------
  9728. // CTL_FIND_ANY
  9729. //
  9730. // Find any CTL.
  9731. //
  9732. // pvFindPara isn't used.
  9733. //--------------------------------------------------------------------------
  9734. //+-------------------------------------------------------------------------
  9735. // CTL_FIND_SHA1_HASH
  9736. // CTL_FIND_MD5_HASH
  9737. //
  9738. // Find a CTL with the specified hash.
  9739. //
  9740. // pvFindPara points to a CRYPT_HASH_BLOB.
  9741. //--------------------------------------------------------------------------
  9742. //+-------------------------------------------------------------------------
  9743. // CTL_FIND_USAGE
  9744. //
  9745. // Find a CTL having the specified usage identifiers, list identifier or
  9746. // signer. The CertEncodingType of the signer is obtained from the
  9747. // dwMsgAndCertEncodingType parameter.
  9748. //
  9749. // pvFindPara points to a CTL_FIND_USAGE_PARA data structure. The
  9750. // SubjectUsage.cUsageIdentifer can be 0 to match any usage. The
  9751. // ListIdentifier.cbData can be 0 to match any list identifier. To only match
  9752. // CTLs without a ListIdentifier, cbData must be set to
  9753. // CTL_FIND_NO_LIST_ID_CBDATA. pSigner can be NULL to match any signer. Only
  9754. // the Issuer and SerialNumber fields of the pSigner's PCERT_INFO are used.
  9755. // To only match CTLs without a signer, pSigner must be set to
  9756. // CTL_FIND_NO_SIGNER_PTR.
  9757. //
  9758. // The CTL_FIND_SAME_USAGE_FLAG can be set in dwFindFlags to
  9759. // only match CTLs with the same usage identifiers. CTLs having additional
  9760. // usage identifiers aren't matched. For example, if only "1.2.3" is specified
  9761. // in CTL_FIND_USAGE_PARA, then, for a match, the CTL must only contain
  9762. // "1.2.3" and not any additional usage identifers.
  9763. //--------------------------------------------------------------------------
  9764. //+-------------------------------------------------------------------------
  9765. // CTL_FIND_SUBJECT
  9766. //
  9767. // Find a CTL having the specified subject. CertFindSubjectInCTL can be
  9768. // called to get a pointer to the subject's entry in the CTL. pUsagePara can
  9769. // optionally be set to enable the above CTL_FIND_USAGE matching.
  9770. //
  9771. // pvFindPara points to a CTL_FIND_SUBJECT_PARA data structure.
  9772. //--------------------------------------------------------------------------
  9773. //+-------------------------------------------------------------------------
  9774. // Add the encoded CTL to the store according to the specified
  9775. // disposition option.
  9776. //
  9777. // Makes a copy of the encoded CTL before adding to the store.
  9778. //
  9779. // dwAddDispostion specifies the action to take if the CTL
  9780. // already exists in the store. See CertAddEncodedCertificateToStore for a
  9781. // list of and actions taken.
  9782. //
  9783. // Compares the CTL's SubjectUsage, ListIdentifier and any of its signers
  9784. // to determine if the CTL already exists in the store.
  9785. //
  9786. // ppCtlContext can be NULL, indicating the caller isn't interested
  9787. // in getting the CTL_CONTEXT of the added or existing CTL.
  9788. //--------------------------------------------------------------------------
  9789. function CertAddEncodedCTLToStore(hCertStore: HCERTSTORE;
  9790. dwMsgAndCertEncodingType: DWORD; pbCtlEncoded: LPBYTE; cbCtlEncoded: DWORD;
  9791. dwAddDisposition: DWORD; ppCtlContext: PPCCTL_CONTEXT): BOOL; stdcall;
  9792. {$EXTERNALSYM CertAddEncodedCTLToStore}
  9793. //+-------------------------------------------------------------------------
  9794. // Add the CTL context to the store according to the specified
  9795. // disposition option.
  9796. //
  9797. // In addition to the encoded CTL, the context's properties are
  9798. // also copied. Note, the CERT_KEY_CONTEXT_PROP_ID property (and its
  9799. // CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_SPEC_PROP_ID) isn't copied.
  9800. //
  9801. // Makes a copy of the encoded CTL before adding to the store.
  9802. //
  9803. // dwAddDispostion specifies the action to take if the CTL
  9804. // already exists in the store. See CertAddCertificateContextToStore for a
  9805. // list of and actions taken.
  9806. //
  9807. // Compares the CTL's SubjectUsage, ListIdentifier and any of its signers
  9808. // to determine if the CTL already exists in the store.
  9809. //
  9810. // ppStoreContext can be NULL, indicating the caller isn't interested
  9811. // in getting the CTL_CONTEXT of the added or existing CTL.
  9812. //--------------------------------------------------------------------------
  9813. function CertAddCTLContextToStore(hCertStore: HCERTSTORE; pCtlContext: PCCTL_CONTEXT;
  9814. dwAddDisposition: DWORD; ppStoreContext: PPCCTL_CONTEXT): BOOL; stdcall;
  9815. {$EXTERNALSYM CertAddCTLContextToStore}
  9816. //+-------------------------------------------------------------------------
  9817. // Serialize the CTL context's encoded CTL and its properties.
  9818. //--------------------------------------------------------------------------
  9819. function CertSerializeCTLStoreElement(pCtlContext: PCCTL_CONTEXT; dwFlags: DWORD;
  9820. pbElement: LPBYTE; var pcbElement: DWORD): BOOL; stdcall;
  9821. {$EXTERNALSYM CertSerializeCTLStoreElement}
  9822. //+-------------------------------------------------------------------------
  9823. // Delete the specified CTL from the store.
  9824. //
  9825. // All subsequent gets for the CTL will fail. However,
  9826. // memory allocated for the CTL isn't freed until all of its contexts
  9827. // have also been freed.
  9828. //
  9829. // The pCtlContext is obtained from a get or duplicate.
  9830. //
  9831. // NOTE: the pCtlContext is always CertFreeCTLContext'ed by
  9832. // this function, even for an error.
  9833. //--------------------------------------------------------------------------
  9834. function CertDeleteCTLFromStore(pCtlContext: PCCTL_CONTEXT): BOOL; stdcall;
  9835. {$EXTERNALSYM CertDeleteCTLFromStore}
  9836. function CertAddCertificateLinkToStore(hCertStore: HCERTSTORE;
  9837. pCertContext: PCCERT_CONTEXT; dwAddDisposition: DWORD;
  9838. ppStoreContext: PPCCERT_CONTEXT): BOOL; stdcall;
  9839. {$EXTERNALSYM CertAddCertificateLinkToStore}
  9840. function CertAddCRLLinkToStore(hCertStore: HCERTSTORE; pCrlContext: PCCRL_CONTEXT;
  9841. dwAddDisposition: DWORD; ppStoreContext: PPCCRL_CONTEXT): BOOL; stdcall;
  9842. {$EXTERNALSYM CertAddCRLLinkToStore}
  9843. function CertAddCTLLinkToStore(hCertStore: HCERTSTORE; pCtlContext: PCCTL_CONTEXT;
  9844. dwAddDisposition: DWORD; ppStoreContext: PPCCTL_CONTEXT): BOOL; stdcall;
  9845. {$EXTERNALSYM CertAddCTLLinkToStore}
  9846. function CertAddStoreToCollection(hCollectionStore: HCERTSTORE;
  9847. hSiblingStore: HCERTSTORE; dwUpdateFlags, dwPriority: DWORD): BOOL; stdcall;
  9848. {$EXTERNALSYM CertAddStoreToCollection}
  9849. procedure CertRemoveStoreFromCollection(hCollectionStore, hSiblingStore: HCERTSTORE); stdcall;
  9850. {$EXTERNALSYM CertRemoveStoreFromCollection}
  9851. function CertControlStore(hCertStore: HCERTSTORE; dwFlags, dwCtrlType: DWORD;
  9852. pvCtrlPara: Pointer): BOOL; stdcall;
  9853. {$EXTERNALSYM CertControlStore}
  9854. //+-------------------------------------------------------------------------
  9855. // Certificate Store control types
  9856. //--------------------------------------------------------------------------
  9857. const
  9858. CERT_STORE_CTRL_RESYNC = 1;
  9859. {$EXTERNALSYM CERT_STORE_CTRL_RESYNC}
  9860. CERT_STORE_CTRL_NOTIFY_CHANGE = 2;
  9861. {$EXTERNALSYM CERT_STORE_CTRL_NOTIFY_CHANGE}
  9862. CERT_STORE_CTRL_COMMIT = 3;
  9863. {$EXTERNALSYM CERT_STORE_CTRL_COMMIT}
  9864. CERT_STORE_CTRL_AUTO_RESYNC = 4;
  9865. {$EXTERNALSYM CERT_STORE_CTRL_AUTO_RESYNC}
  9866. //+-------------------------------------------------------------------------
  9867. // CERT_STORE_CTRL_RESYNC
  9868. //
  9869. // Re-synchronize the store.
  9870. //
  9871. // The pvCtrlPara points to the event HANDLE to be signaled on
  9872. // the next store change. Normally, this would be the same
  9873. // event HANDLE passed to CERT_STORE_CTRL_NOTIFY_CHANGE during initialization.
  9874. //
  9875. // If pvCtrlPara is NULL, no events are re-armed.
  9876. //--------------------------------------------------------------------------
  9877. //+-------------------------------------------------------------------------
  9878. // CERT_STORE_CTRL_NOTIFY_CHANGE
  9879. //
  9880. // Signal the event when the underlying store is changed.
  9881. //
  9882. // pvCtrlPara points to the event HANDLE to be signaled.
  9883. //
  9884. // pvCtrlPara can be NULL to inform the store of a subsequent
  9885. // CERT_STORE_CTRL_RESYNC and allow it to optimize by only doing a resync
  9886. // if the store has changed. For the registry based stores, an internal
  9887. // notify change event is created and registered to be signaled.
  9888. //
  9889. // Recommend calling CERT_STORE_CTRL_NOTIFY_CHANGE once for each event to
  9890. // be passed to CERT_STORE_CTRL_RESYNC. This should only happen after
  9891. // the event has been created. Not after each time the event is signaled.
  9892. //--------------------------------------------------------------------------
  9893. //+-------------------------------------------------------------------------
  9894. // CERT_STORE_CTRL_AUTO_RESYNC
  9895. //
  9896. // At the start of every enumeration or find store API call, check if the
  9897. // underlying store has changed. If it has changed, re-synchronize.
  9898. //
  9899. // This check is only done in the enumeration or find APIs when the
  9900. // pPrevContext is NULL.
  9901. //
  9902. // The pvCtrlPara isn't used and must be set to NULL.
  9903. //--------------------------------------------------------------------------
  9904. //+-------------------------------------------------------------------------
  9905. // CERT_STORE_CTRL_COMMIT
  9906. //
  9907. // If any changes have been to the cached store, they are committed to
  9908. // persisted storage. If no changes have been made since the store was
  9909. // opened or the last commit, this call is ignored. May also be ignored by
  9910. // store providers that persist changes immediately.
  9911. //
  9912. // CERT_STORE_CTRL_COMMIT_FORCE_FLAG can be set to force the store
  9913. // to be committed even if it hasn't been touched.
  9914. //
  9915. // CERT_STORE_CTRL_COMMIT_CLEAR_FLAG can be set to inhibit a commit on
  9916. // store close.
  9917. //--------------------------------------------------------------------------
  9918. const
  9919. CERT_STORE_CTRL_COMMIT_FORCE_FLAG = $1;
  9920. {$EXTERNALSYM CERT_STORE_CTRL_COMMIT_FORCE_FLAG}
  9921. CERT_STORE_CTRL_COMMIT_CLEAR_FLAG = $2;
  9922. {$EXTERNALSYM CERT_STORE_CTRL_COMMIT_CLEAR_FLAG}
  9923. //+=========================================================================
  9924. // Cert Store Property Defines and APIs
  9925. //==========================================================================
  9926. //+-------------------------------------------------------------------------
  9927. // Store property IDs. This is a property applicable to the entire store.
  9928. // Its not a property on an individual certificate, CRL or CTL context.
  9929. //
  9930. // Currently, no store properties are persisted. (This differs from
  9931. // most context properties which are persisted.)
  9932. //
  9933. // See CertSetStoreProperty or CertGetStoreProperty for usage information.
  9934. //
  9935. // Note, the range for predefined store properties should be outside
  9936. // the range of predefined context properties. We will start at 4096.
  9937. //--------------------------------------------------------------------------
  9938. CERT_STORE_LOCALIZED_NAME_PROP_ID = $1000;
  9939. {$EXTERNALSYM CERT_STORE_LOCALIZED_NAME_PROP_ID}
  9940. //+-------------------------------------------------------------------------
  9941. // Set a store property.
  9942. //
  9943. // The type definition for pvData depends on the dwPropId value.
  9944. // CERT_STORE_LOCALIZED_NAME_PROP_ID - localized name of the store.
  9945. // pvData points to a CRYPT_DATA_BLOB. pbData is a pointer to a NULL
  9946. // terminated unicode, wide character string.
  9947. // cbData = (wcslen((LPWSTR) pbData) + 1) * sizeof(WCHAR).
  9948. //
  9949. // For all the other PROP_IDs: an encoded PCRYPT_DATA_BLOB is passed in pvData.
  9950. //
  9951. // If the property already exists, then, the old value is deleted and silently
  9952. // replaced. Setting, pvData to NULL, deletes the property.
  9953. //--------------------------------------------------------------------------
  9954. function CertSetStoreProperty(hCertStore: HCERTSTORE; dwPropId, dwFlags: DWORD;
  9955. pvData: Pointer): BOOL; stdcall;
  9956. {$EXTERNALSYM CertSetStoreProperty}
  9957. //+-------------------------------------------------------------------------
  9958. // Get a store property.
  9959. //
  9960. // The type definition for pvData depends on the dwPropId value.
  9961. // CERT_STORE_LOCALIZED_NAME_PROP_ID - localized name of the store.
  9962. // pvData points to a NULL terminated unicode, wide character string.
  9963. // cbData = (wcslen((LPWSTR) pvData) + 1) * sizeof(WCHAR).
  9964. //
  9965. // For all other PROP_IDs, pvData points to an array of bytes.
  9966. //
  9967. // If the property doesn't exist, returns FALSE and sets LastError to
  9968. // CRYPT_E_NOT_FOUND.
  9969. //--------------------------------------------------------------------------
  9970. function CertGetStoreProperty(hCertStore: HCERTSTORE; dwPropId: DWORD;
  9971. pvData: Pointer; var pcbData: DWORD): BOOL; stdcall;
  9972. {$EXTERNALSYM CertGetStoreProperty}
  9973. type
  9974. PCERT_CREATE_CONTEXT_PARA = ^CERT_CREATE_CONTEXT_PARA;
  9975. {$EXTERNALSYM PCERT_CREATE_CONTEXT_PARA}
  9976. _CERT_CREATE_CONTEXT_PARA = record
  9977. cbSize: DWORD;
  9978. pfnFree: PFN_CRYPT_FREE; // OPTIONAL
  9979. pvFree: Pointer; // OPTIONAL
  9980. end;
  9981. {$EXTERNALSYM _CERT_CREATE_CONTEXT_PARA}
  9982. CERT_CREATE_CONTEXT_PARA = _CERT_CREATE_CONTEXT_PARA;
  9983. {$EXTERNALSYM CERT_CREATE_CONTEXT_PARA}
  9984. TCertCreateContextPara = CERT_CREATE_CONTEXT_PARA;
  9985. PCertCreateContextPara = PCERT_CREATE_CONTEXT_PARA;
  9986. //+-------------------------------------------------------------------------
  9987. // Creates the specified context from the encoded bytes. The created
  9988. // context isn't put in a store.
  9989. //
  9990. // dwContextType values:
  9991. // CERT_STORE_CERTIFICATE_CONTEXT
  9992. // CERT_STORE_CRL_CONTEXT
  9993. // CERT_STORE_CTL_CONTEXT
  9994. //
  9995. // If CERT_CREATE_CONTEXT_NOCOPY_FLAG is set, the created context points
  9996. // directly to the pbEncoded instead of an allocated copy. See flag
  9997. // definition for more details.
  9998. //
  9999. // If CERT_CREATE_CONTEXT_SORTED_FLAG is set, the context is created
  10000. // with sorted entries. This flag may only be set for CERT_STORE_CTL_CONTEXT.
  10001. // Setting this flag implicitly sets CERT_CREATE_CONTEXT_NO_HCRYPTMSG_FLAG and
  10002. // CERT_CREATE_CONTEXT_NO_ENTRY_FLAG. See flag definition for
  10003. // more details.
  10004. //
  10005. // If CERT_CREATE_CONTEXT_NO_HCRYPTMSG_FLAG is set, the context is created
  10006. // without creating a HCRYPTMSG handle for the context. This flag may only be
  10007. // set for CERT_STORE_CTL_CONTEXT. See flag definition for more details.
  10008. //
  10009. // If CERT_CREATE_CONTEXT_NO_ENTRY_FLAG is set, the context is created
  10010. // without decoding the entries. This flag may only be set for
  10011. // CERT_STORE_CTL_CONTEXT. See flag definition for more details.
  10012. //
  10013. // If unable to decode and create the context, NULL is returned.
  10014. // Otherwise, a pointer to a read only CERT_CONTEXT, CRL_CONTEXT or
  10015. // CTL_CONTEXT is returned. The context must be freed by the appropriate
  10016. // free context API. The context can be duplicated by calling the
  10017. // appropriate duplicate context API.
  10018. //--------------------------------------------------------------------------
  10019. function CertCreateContext(dwContextType, dwEncodingType: DWORD;
  10020. pbEncoded: LPBYTE; cbEncoded, dwFlags: DWORD;
  10021. pCreatePara: PCERT_CREATE_CONTEXT_PARA): Pointer; stdcall;
  10022. {$EXTERNALSYM CertCreateContext}
  10023. // When the following flag is set, the created context points directly to the
  10024. // pbEncoded instead of an allocated copy. If pCreatePara and
  10025. // pCreatePara->pfnFree are non-NULL, then, pfnFree is called to free
  10026. // the pbEncoded when the context is last freed. Otherwise, no attempt is
  10027. // made to free the pbEncoded. If pCreatePara->pvFree is non-NULL, then its
  10028. // passed to pfnFree instead of pbEncoded.
  10029. //
  10030. // Note, if CertCreateContext fails, pfnFree is still called.
  10031. const
  10032. CERT_CREATE_CONTEXT_NOCOPY_FLAG = $1;
  10033. {$EXTERNALSYM CERT_CREATE_CONTEXT_NOCOPY_FLAG}
  10034. // When the following flag is set, a context with sorted entries is created.
  10035. // Currently only applicable to a CTL context.
  10036. //
  10037. // For CTLs: the cCTLEntry in the returned CTL_INFO is always
  10038. // 0. CertFindSubjectInSortedCTL and CertEnumSubjectInSortedCTL must be called
  10039. // to find or enumerate the CTL entries.
  10040. //
  10041. // The Sorted CTL TrustedSubjects extension isn't returned in the created
  10042. // context's CTL_INFO.
  10043. CERT_CREATE_CONTEXT_SORTED_FLAG = $2;
  10044. {$EXTERNALSYM CERT_CREATE_CONTEXT_SORTED_FLAG}
  10045. // By default when a CTL context is created, a HCRYPTMSG handle to its
  10046. // SignedData message is created. This flag can be set to improve performance
  10047. // by not creating the HCRYPTMSG handle.
  10048. //
  10049. // This flag is only applicable to a CTL context.
  10050. CERT_CREATE_CONTEXT_NO_HCRYPTMSG_FLAG = $4;
  10051. {$EXTERNALSYM CERT_CREATE_CONTEXT_NO_HCRYPTMSG_FLAG}
  10052. // By default when a CTL context is created, its entries are decoded.
  10053. // This flag can be set to improve performance by not decoding the
  10054. // entries.
  10055. //
  10056. // This flag is only applicable to a CTL context.
  10057. CERT_CREATE_CONTEXT_NO_ENTRY_FLAG = $8;
  10058. {$EXTERNALSYM CERT_CREATE_CONTEXT_NO_ENTRY_FLAG}
  10059. //+=========================================================================
  10060. // Certificate System Store Data Structures and APIs
  10061. //==========================================================================
  10062. //+-------------------------------------------------------------------------
  10063. // System Store Information
  10064. //
  10065. // Currently, no system store information is persisted.
  10066. //--------------------------------------------------------------------------
  10067. type
  10068. PCERT_SYSTEM_STORE_INFO = ^CERT_SYSTEM_STORE_INFO;
  10069. {$EXTERNALSYM PCERT_SYSTEM_STORE_INFO}
  10070. _CERT_SYSTEM_STORE_INFO = record
  10071. cbSize: DWORD;
  10072. end;
  10073. {$EXTERNALSYM _CERT_SYSTEM_STORE_INFO}
  10074. CERT_SYSTEM_STORE_INFO = _CERT_SYSTEM_STORE_INFO;
  10075. {$EXTERNALSYM CERT_SYSTEM_STORE_INFO}
  10076. TCertSystemStoreInfo = CERT_SYSTEM_STORE_INFO;
  10077. PCertSystemStoreInfo = PCERT_SYSTEM_STORE_INFO;
  10078. //+-------------------------------------------------------------------------
  10079. // Physical Store Information
  10080. //
  10081. // The Open fields are passed directly to CertOpenStore() to open
  10082. // the physical store.
  10083. //
  10084. // By default all system stores located in the registry have an
  10085. // implicit SystemRegistry physical store that is opened. To disable the
  10086. // opening of this store, the SystemRegistry
  10087. // physical store corresponding to the System store must be registered with
  10088. // CERT_PHYSICAL_STORE_OPEN_DISABLE_FLAG set in dwFlags. Alternatively,
  10089. // a physical store with the name of ".Default" may be registered.
  10090. //
  10091. // Depending on the store location and store name, additional predefined
  10092. // physical stores may be opened. For example, system stores in
  10093. // CURRENT_USER have the predefined physical store, .LocalMachine.
  10094. // To disable the opening of these predefined physical stores, the
  10095. // corresponding physical store must be registered with
  10096. // CERT_PHYSICAL_STORE_OPEN_DISABLE_FLAG set in dwFlags.
  10097. //
  10098. // The CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG must be set in dwFlags
  10099. // to enable the adding of a context to the store.
  10100. //
  10101. // When a system store is opened via the SERVICES or USERS store location,
  10102. // the ServiceName\ is prepended to the OpenParameters
  10103. // for CERT_SYSTEM_STORE_CURRENT_USER or CERT_SYSTEM_STORE_CURRENT_SERVICE
  10104. // physical stores and the dwOpenFlags store location is changed to
  10105. // CERT_SYSTEM_STORE_USERS or CERT_SYSTEM_STORE_SERVICES.
  10106. //
  10107. // By default the SYSTEM, SYSTEM_REGISTRY and PHYSICAL provider
  10108. // stores are also opened remotely when the outer system store is opened.
  10109. // The CERT_PHYSICAL_STORE_REMOTE_OPEN_DISABLE_FLAG may be set in dwFlags
  10110. // to disable remote opens.
  10111. //
  10112. // When opened remotely, the \\ComputerName is implicitly prepended to the
  10113. // OpenParameters for the SYSTEM, SYSTEM_REGISTRY and PHYSICAL provider types.
  10114. // To also prepend the \\ComputerName to other provider types, set the
  10115. // CERT_PHYSICAL_STORE_INSERT_COMPUTER_NAME_ENABLE_FLAG in dwFlags.
  10116. //
  10117. // When the system store is opened, its physical stores are ordered
  10118. // according to the dwPriority. A larger dwPriority indicates higher priority.
  10119. //--------------------------------------------------------------------------
  10120. type
  10121. PCERT_PHYSICAL_STORE_INFO = ^CERT_PHYSICAL_STORE_INFO;
  10122. {$EXTERNALSYM PCERT_PHYSICAL_STORE_INFO}
  10123. _CERT_PHYSICAL_STORE_INFO = record
  10124. cbSize: DWORD;
  10125. pszOpenStoreProvider: LPSTR; // REG_SZ
  10126. dwOpenEncodingType: DWORD; // REG_DWORD
  10127. dwOpenFlags: DWORD; // REG_DWORD
  10128. OpenParameters: CRYPT_DATA_BLOB; // REG_BINARY
  10129. dwFlags: DWORD; // REG_DWORD
  10130. dwPriority: DWORD; // REG_DWORD
  10131. end;
  10132. {$EXTERNALSYM _CERT_PHYSICAL_STORE_INFO}
  10133. CERT_PHYSICAL_STORE_INFO = _CERT_PHYSICAL_STORE_INFO;
  10134. {$EXTERNALSYM CERT_PHYSICAL_STORE_INFO}
  10135. TCertPhysicalStoreInfo = CERT_PHYSICAL_STORE_INFO;
  10136. PCertPhysicalStoreInfo = PCERT_PHYSICAL_STORE_INFO;
  10137. //+-------------------------------------------------------------------------
  10138. // Physical Store Information dwFlags
  10139. //--------------------------------------------------------------------------
  10140. const
  10141. CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG = $1;
  10142. {$EXTERNALSYM CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG}
  10143. CERT_PHYSICAL_STORE_OPEN_DISABLE_FLAG = $2;
  10144. {$EXTERNALSYM CERT_PHYSICAL_STORE_OPEN_DISABLE_FLAG}
  10145. CERT_PHYSICAL_STORE_REMOTE_OPEN_DISABLE_FLAG = $4;
  10146. {$EXTERNALSYM CERT_PHYSICAL_STORE_REMOTE_OPEN_DISABLE_FLAG}
  10147. CERT_PHYSICAL_STORE_INSERT_COMPUTER_NAME_ENABLE_FLAG = $8;
  10148. {$EXTERNALSYM CERT_PHYSICAL_STORE_INSERT_COMPUTER_NAME_ENABLE_FLAG}
  10149. //+-------------------------------------------------------------------------
  10150. // Register a system store.
  10151. //
  10152. // The upper word of the dwFlags parameter is used to specify the location of
  10153. // the system store.
  10154. //
  10155. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvSystemStore
  10156. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure. Otherwise,
  10157. // pvSystemStore points to a null terminated UNICODE string.
  10158. //
  10159. // The CERT_SYSTEM_STORE_SERVICES or CERT_SYSTEM_STORE_USERS system store
  10160. // name must be prefixed with the ServiceName or UserName. For example,
  10161. // "ServiceName\Trust".
  10162. //
  10163. // Stores on remote computers can be registered for the
  10164. // CERT_SYSTEM_STORE_LOCAL_MACHINE, CERT_SYSTEM_STORE_SERVICES,
  10165. // CERT_SYSTEM_STORE_USERS, CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
  10166. // or CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
  10167. // locations by prepending the computer name. For example, a remote
  10168. // local machine store is registered via "\\ComputerName\Trust" or
  10169. // "ComputerName\Trust". A remote service store is registered via
  10170. // "\\ComputerName\ServiceName\Trust". The leading "\\" backslashes are
  10171. // optional in the ComputerName.
  10172. //
  10173. // Set CERT_STORE_CREATE_NEW_FLAG to cause a failure if the system store
  10174. // already exists in the store location.
  10175. //--------------------------------------------------------------------------
  10176. function CertRegisterSystemStore(pvSystemStore: Pointer; dwFlags: DWORD;
  10177. pStoreInfo: PCERT_SYSTEM_STORE_INFO; pvReserved: Pointer): BOOL; stdcall;
  10178. {$EXTERNALSYM CertRegisterSystemStore}
  10179. //+-------------------------------------------------------------------------
  10180. // Register a physical store for the specified system store.
  10181. //
  10182. // The upper word of the dwFlags parameter is used to specify the location of
  10183. // the system store.
  10184. //
  10185. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvSystemStore
  10186. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure. Otherwise,
  10187. // pvSystemStore points to a null terminated UNICODE string.
  10188. //
  10189. // See CertRegisterSystemStore for details on prepending a ServiceName
  10190. // and/or ComputerName to the system store name.
  10191. //
  10192. // Set CERT_STORE_CREATE_NEW_FLAG to cause a failure if the physical store
  10193. // already exists in the system store.
  10194. //--------------------------------------------------------------------------
  10195. function CertRegisterPhysicalStore(pvSystemStore: Pointer; dwFlags: DWORD;
  10196. pwszStoreName: LPCWSTR; pStoreInfo: PCERT_PHYSICAL_STORE_INFO;
  10197. pvReserved: Pointer): BOOL; stdcall;
  10198. {$EXTERNALSYM CertRegisterPhysicalStore}
  10199. //+-------------------------------------------------------------------------
  10200. // Unregister the specified system store.
  10201. //
  10202. // The upper word of the dwFlags parameter is used to specify the location of
  10203. // the system store.
  10204. //
  10205. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvSystemStore
  10206. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure. Otherwise,
  10207. // pvSystemStore points to a null terminated UNICODE string.
  10208. //
  10209. // See CertRegisterSystemStore for details on prepending a ServiceName
  10210. // and/or ComputerName to the system store name.
  10211. //
  10212. // CERT_STORE_DELETE_FLAG can optionally be set in dwFlags.
  10213. //--------------------------------------------------------------------------
  10214. function CertUnregisterSystemStore(pvSystemStore: Pointer; dwFlags: DWORD): BOOL; stdcall;
  10215. {$EXTERNALSYM CertUnregisterSystemStore}
  10216. //+-------------------------------------------------------------------------
  10217. // Unregister the physical store from the specified system store.
  10218. //
  10219. // The upper word of the dwFlags parameter is used to specify the location of
  10220. // the system store.
  10221. //
  10222. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvSystemStore
  10223. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure. Otherwise,
  10224. // pvSystemStore points to a null terminated UNICODE string.
  10225. //
  10226. // See CertRegisterSystemStore for details on prepending a ServiceName
  10227. // and/or ComputerName to the system store name.
  10228. //
  10229. // CERT_STORE_DELETE_FLAG can optionally be set in dwFlags.
  10230. //--------------------------------------------------------------------------
  10231. function CertUnregisterPhysicalStore(pvSystemStore: Pointer; dwFlags: DWORD;
  10232. pwszStoreName: LPCWSTR): BOOL; stdcall;
  10233. {$EXTERNALSYM CertUnregisterPhysicalStore}
  10234. //+-------------------------------------------------------------------------
  10235. // Enum callbacks
  10236. //
  10237. // The CERT_SYSTEM_STORE_LOCATION_MASK bits in the dwFlags parameter
  10238. // specifies the location of the system store
  10239. //
  10240. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvSystemStore
  10241. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure. Otherwise,
  10242. // pvSystemStore points to a null terminated UNICODE string.
  10243. //
  10244. // The callback returns FALSE and sets LAST_ERROR to stop the enumeration.
  10245. // The LAST_ERROR is returned to the caller of the enumeration.
  10246. //
  10247. // The pvSystemStore passed to the callback has leading ComputerName and/or
  10248. // ServiceName prefixes where appropriate.
  10249. //--------------------------------------------------------------------------
  10250. type
  10251. PFN_CERT_ENUM_SYSTEM_STORE_LOCATION = function(pwszStoreLocation: LPCWSTR;
  10252. dwFlags: DWORD; pvReserved: Pointer; pvArg: Pointer): BOOL; stdcall;
  10253. {$EXTERNALSYM PFN_CERT_ENUM_SYSTEM_STORE_LOCATION}
  10254. PfnCertEnumSystemStoreLocation = PFN_CERT_ENUM_SYSTEM_STORE_LOCATION;
  10255. PFN_CERT_ENUM_SYSTEM_STORE = function(pvSystemStore: Pointer;
  10256. dwFlags: DWORD; pStoreInfo: PCERT_SYSTEM_STORE_INFO; pvReserved: Pointer;
  10257. pvArg: Pointer): BOOL; stdcall;
  10258. {$EXTERNALSYM PFN_CERT_ENUM_SYSTEM_STORE}
  10259. PfnCertEnumSystemStore = PFN_CERT_ENUM_SYSTEM_STORE;
  10260. PFN_CERT_ENUM_PHYSICAL_STORE = function(pvSystemStore: Pointer;
  10261. dwFlags: DWORD; pwszStoreName: LPCWSTR; pStoreInfo: PCERT_PHYSICAL_STORE_INFO;
  10262. pvReserved: Pointer; pvArg: Pointer): BOOL; stdcall;
  10263. {$EXTERNALSYM PFN_CERT_ENUM_PHYSICAL_STORE}
  10264. PfnCertEnumPhysicalStore = PFN_CERT_ENUM_PHYSICAL_STORE;
  10265. // In the PFN_CERT_ENUM_PHYSICAL_STORE callback the following flag is
  10266. // set if the physical store wasn't registered and is an implicitly created
  10267. // predefined physical store.
  10268. const
  10269. CERT_PHYSICAL_STORE_PREDEFINED_ENUM_FLAG = $1;
  10270. {$EXTERNALSYM CERT_PHYSICAL_STORE_PREDEFINED_ENUM_FLAG}
  10271. // Names of implicitly created predefined physical stores
  10272. CERT_PHYSICAL_STORE_DEFAULT_NAME = '.Default';
  10273. {$EXTERNALSYM CERT_PHYSICAL_STORE_DEFAULT_NAME}
  10274. CERT_PHYSICAL_STORE_GROUP_POLICY_NAME = '.GroupPolicy';
  10275. {$EXTERNALSYM CERT_PHYSICAL_STORE_GROUP_POLICY_NAME}
  10276. CERT_PHYSICAL_STORE_LOCAL_MACHINE_NAME = '.LocalMachine';
  10277. {$EXTERNALSYM CERT_PHYSICAL_STORE_LOCAL_MACHINE_NAME}
  10278. CERT_PHYSICAL_STORE_DS_USER_CERTIFICATE_NAME = '.UserCertificate';
  10279. {$EXTERNALSYM CERT_PHYSICAL_STORE_DS_USER_CERTIFICATE_NAME}
  10280. CERT_PHYSICAL_STORE_LOCAL_MACHINE_GROUP_POLICY_NAME = '.LocalMachineGroupPolicy';
  10281. {$EXTERNALSYM CERT_PHYSICAL_STORE_LOCAL_MACHINE_GROUP_POLICY_NAME}
  10282. CERT_PHYSICAL_STORE_ENTERPRISE_NAME = '.Enterprise';
  10283. {$EXTERNALSYM CERT_PHYSICAL_STORE_ENTERPRISE_NAME}
  10284. //+-------------------------------------------------------------------------
  10285. // Enumerate the system store locations.
  10286. //--------------------------------------------------------------------------
  10287. function CertEnumSystemStoreLocation(dwFlags: DWORD; pvArg: Pointer;
  10288. pfnEnum: PFN_CERT_ENUM_SYSTEM_STORE_LOCATION): BOOL; stdcall;
  10289. {$EXTERNALSYM CertEnumSystemStoreLocation}
  10290. //+-------------------------------------------------------------------------
  10291. // Enumerate the system stores.
  10292. //
  10293. // The upper word of the dwFlags parameter is used to specify the location of
  10294. // the system store.
  10295. //
  10296. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags,
  10297. // pvSystemStoreLocationPara points to a CERT_SYSTEM_STORE_RELOCATE_PARA
  10298. // data structure. Otherwise, pvSystemStoreLocationPara points to a null
  10299. // terminated UNICODE string.
  10300. //
  10301. // For CERT_SYSTEM_STORE_LOCAL_MACHINE,
  10302. // CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY or
  10303. // CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE, pvSystemStoreLocationPara can
  10304. // optionally be set to a unicode computer name for enumerating local machine
  10305. // stores on a remote computer. For example, "\\ComputerName" or
  10306. // "ComputerName". The leading "\\" backslashes are optional in the
  10307. // ComputerName.
  10308. //
  10309. // For CERT_SYSTEM_STORE_SERVICES or CERT_SYSTEM_STORE_USERS,
  10310. // if pvSystemStoreLocationPara is NULL, then,
  10311. // enumerates both the service/user names and the stores for each service/user
  10312. // name. Otherwise, pvSystemStoreLocationPara is a unicode string specifying a
  10313. // remote computer name and/or service/user name. For example:
  10314. // "ServiceName"
  10315. // "\\ComputerName" or "ComputerName\"
  10316. // "ComputerName\ServiceName"
  10317. // Note, if only the ComputerName is specified, then, it must have either
  10318. // the leading "\\" backslashes or a trailing backslash. Otherwise, its
  10319. // interpretted as the ServiceName or UserName.
  10320. //--------------------------------------------------------------------------
  10321. function CertEnumSystemStore(dwFlags: DWORD; pvSystemStoreLocationPara: Pointer;
  10322. pvArg: Pointer; pfnEnum: PFN_CERT_ENUM_SYSTEM_STORE): BOOL; stdcall;
  10323. {$EXTERNALSYM CertEnumSystemStore}
  10324. //+-------------------------------------------------------------------------
  10325. // Enumerate the physical stores for the specified system store.
  10326. //
  10327. // The upper word of the dwFlags parameter is used to specify the location of
  10328. // the system store.
  10329. //
  10330. // If CERT_SYSTEM_STORE_RELOCATE_FLAG is set in dwFlags, pvSystemStore
  10331. // points to a CERT_SYSTEM_STORE_RELOCATE_PARA data structure. Otherwise,
  10332. // pvSystemStore points to a null terminated UNICODE string.
  10333. //
  10334. // See CertRegisterSystemStore for details on prepending a ServiceName
  10335. // and/or ComputerName to the system store name.
  10336. //
  10337. // If the system store location only supports system stores and doesn't
  10338. // support physical stores, LastError is set to ERROR_CALL_NOT_IMPLEMENTED.
  10339. //--------------------------------------------------------------------------
  10340. function CertEnumPhysicalStore(pvSystemStore: Pointer; dwFlags: DWORD;
  10341. pvArg: Pointer; pfnEnum: PFN_CERT_ENUM_PHYSICAL_STORE): BOOL; stdcall;
  10342. {$EXTERNALSYM CertEnumPhysicalStore}
  10343. //+-------------------------------------------------------------------------
  10344. // Certificate System Store Installable Functions
  10345. //
  10346. // The CERT_SYSTEM_STORE_LOCATION_MASK bits in the dwFlags parameter passed
  10347. // to the CertOpenStore(for "System", "SystemRegistry" or "Physical"
  10348. // Provider), CertRegisterSystemStore,
  10349. // CertUnregisterSystemStore, CertEnumSystemStore, CertRegisterPhysicalStore,
  10350. // CertUnregisterPhysicalStore and CertEnumPhysicalStore APIs is used as the
  10351. // constant pszOID value passed to the OID installable functions.
  10352. // Therefore, the pszOID is restricted to a constant <= (LPCSTR) 0x0FFF.
  10353. //
  10354. // The EncodingType is 0.
  10355. //--------------------------------------------------------------------------
  10356. // Installable System Store Provider OID pszFuncNames.
  10357. const
  10358. CRYPT_OID_OPEN_SYSTEM_STORE_PROV_FUNC = 'CertDllOpenSystemStoreProv';
  10359. {$EXTERNALSYM CRYPT_OID_OPEN_SYSTEM_STORE_PROV_FUNC}
  10360. CRYPT_OID_REGISTER_SYSTEM_STORE_FUNC = 'CertDllRegisterSystemStore';
  10361. {$EXTERNALSYM CRYPT_OID_REGISTER_SYSTEM_STORE_FUNC}
  10362. CRYPT_OID_UNREGISTER_SYSTEM_STORE_FUNC = 'CertDllUnregisterSystemStore';
  10363. {$EXTERNALSYM CRYPT_OID_UNREGISTER_SYSTEM_STORE_FUNC}
  10364. CRYPT_OID_ENUM_SYSTEM_STORE_FUNC = 'CertDllEnumSystemStore';
  10365. {$EXTERNALSYM CRYPT_OID_ENUM_SYSTEM_STORE_FUNC}
  10366. CRYPT_OID_REGISTER_PHYSICAL_STORE_FUNC = 'CertDllRegisterPhysicalStore';
  10367. {$EXTERNALSYM CRYPT_OID_REGISTER_PHYSICAL_STORE_FUNC}
  10368. CRYPT_OID_UNREGISTER_PHYSICAL_STORE_FUNC = 'CertDllUnregisterPhysicalStore';
  10369. {$EXTERNALSYM CRYPT_OID_UNREGISTER_PHYSICAL_STORE_FUNC}
  10370. CRYPT_OID_ENUM_PHYSICAL_STORE_FUNC = 'CertDllEnumPhysicalStore';
  10371. {$EXTERNALSYM CRYPT_OID_ENUM_PHYSICAL_STORE_FUNC}
  10372. // CertDllOpenSystemStoreProv has the same function signature as the
  10373. // installable "CertDllOpenStoreProv" function. See CertOpenStore for
  10374. // more details.
  10375. // CertDllRegisterSystemStore has the same function signature as
  10376. // CertRegisterSystemStore.
  10377. //
  10378. // The "SystemStoreLocation" REG_SZ value must also be set for registered
  10379. // CertDllEnumSystemStore OID functions.
  10380. CRYPT_OID_SYSTEM_STORE_LOCATION_VALUE_NAME = 'SystemStoreLocation';
  10381. {$EXTERNALSYM CRYPT_OID_SYSTEM_STORE_LOCATION_VALUE_NAME}
  10382. // The remaining Register, Enum and Unregister OID installable functions
  10383. // have the same signature as their Cert Store API counterpart.
  10384. //+=========================================================================
  10385. // Enhanced Key Usage Helper Functions
  10386. //==========================================================================
  10387. //+-------------------------------------------------------------------------
  10388. // Get the enhanced key usage extension or property from the certificate
  10389. // and decode.
  10390. //
  10391. // If the CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG is set, then, only get the
  10392. // extension.
  10393. //
  10394. // If the CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG is set, then, only get the
  10395. // property.
  10396. //--------------------------------------------------------------------------
  10397. function CertGetEnhancedKeyUsage(pCertContext: PCCERT_CONTEXT; dwFlags: DWORD;
  10398. pUsage: PCERT_ENHKEY_USAGE; var pcbUsage: DWORD): BOOL; stdcall;
  10399. {$EXTERNALSYM CertGetEnhancedKeyUsage}
  10400. //+-------------------------------------------------------------------------
  10401. // Set the enhanced key usage property for the certificate.
  10402. //--------------------------------------------------------------------------
  10403. function CertSetEnhancedKeyUsage(pCertContext: PCCERT_CONTEXT;
  10404. pUsage: PCERT_ENHKEY_USAGE): BOOL; stdcall;
  10405. {$EXTERNALSYM CertSetEnhancedKeyUsage}
  10406. //+-------------------------------------------------------------------------
  10407. // Add the usage identifier to the certificate's enhanced key usage property.
  10408. //--------------------------------------------------------------------------
  10409. function CertAddEnhancedKeyUsageIdentifier(pCertContext: PCCERT_CONTEXT;
  10410. pszUsageIdentifier: LPCSTR): BOOL; stdcall;
  10411. {$EXTERNALSYM CertAddEnhancedKeyUsageIdentifier}
  10412. //+-------------------------------------------------------------------------
  10413. // Remove the usage identifier from the certificate's enhanced key usage
  10414. // property.
  10415. //--------------------------------------------------------------------------
  10416. function CertRemoveEnhancedKeyUsageIdentifier(pCertContext: PCCERT_CONTEXT;
  10417. pszUsageIdentifier: LPCSTR): BOOL; stdcall;
  10418. {$EXTERNALSYM CertRemoveEnhancedKeyUsageIdentifier}
  10419. //+---------------------------------------------------------------------------
  10420. //
  10421. //
  10422. // Takes an array of certs and returns an array of usages
  10423. // which consists of the intersection of the valid usages for each cert.
  10424. // If each cert is good for all possible usages then the cNumOIDs is set to -1.
  10425. //
  10426. //----------------------------------------------------------------------------
  10427. function CertGetValidUsages(cCerts: DWORD; rghCerts: PCCERT_CONTEXT;
  10428. var cNumOIDs: Integer; rghOIDs: LPLPSTR; var pcbOIDs: DWORD): BOOL; stdcall;
  10429. {$EXTERNALSYM CertGetValidUsages}
  10430. //+=========================================================================
  10431. // Cryptographic Message helper functions for verifying and signing a
  10432. // CTL.
  10433. //==========================================================================
  10434. //+-------------------------------------------------------------------------
  10435. // Get and verify the signer of a cryptographic message.
  10436. //
  10437. // To verify a CTL, the hCryptMsg is obtained from the CTL_CONTEXT's
  10438. // hCryptMsg field.
  10439. //
  10440. // If CMSG_TRUSTED_SIGNER_FLAG is set, then, treat the Signer stores as being
  10441. // trusted and only search them to find the certificate corresponding to the
  10442. // signer's issuer and serial number. Otherwise, the SignerStores are
  10443. // optionally provided to supplement the message's store of certificates.
  10444. // If a signer certificate is found, its public key is used to verify
  10445. // the message signature. The CMSG_SIGNER_ONLY_FLAG can be set to
  10446. // return the signer without doing the signature verify.
  10447. //
  10448. // If CMSG_USE_SIGNER_INDEX_FLAG is set, then, only get the signer specified
  10449. // by *pdwSignerIndex. Otherwise, iterate through all the signers
  10450. // until a signer verifies or no more signers.
  10451. //
  10452. // For a verified signature, *ppSigner is updated with certificate context
  10453. // of the signer and *pdwSignerIndex is updated with the index of the signer.
  10454. // ppSigner and/or pdwSignerIndex can be NULL, indicating the caller isn't
  10455. // interested in getting the CertContext and/or index of the signer.
  10456. //--------------------------------------------------------------------------
  10457. function CryptMsgGetAndVerifySigner(hCryptMsg: HCRYPTMSG; cSignerStore: DWORD;
  10458. rghSignerStore: PHCERTSTORE; dwFlags: DWORD; ppSigner: PPCCERT_CONTEXT;
  10459. pdwSignerIndex: LPDWORD): BOOL; stdcall;
  10460. {$EXTERNALSYM CryptMsgGetAndVerifySigner}
  10461. const
  10462. CMSG_TRUSTED_SIGNER_FLAG = $1;
  10463. {$EXTERNALSYM CMSG_TRUSTED_SIGNER_FLAG}
  10464. CMSG_SIGNER_ONLY_FLAG = $2;
  10465. {$EXTERNALSYM CMSG_SIGNER_ONLY_FLAG}
  10466. CMSG_USE_SIGNER_INDEX_FLAG = $4;
  10467. {$EXTERNALSYM CMSG_USE_SIGNER_INDEX_FLAG}
  10468. //+-------------------------------------------------------------------------
  10469. // Sign an encoded CTL.
  10470. //
  10471. // The pbCtlContent can be obtained via a CTL_CONTEXT's pbCtlContent
  10472. // field or via a CryptEncodeObject(PKCS_CTL or PKCS_SORTED_CTL).
  10473. //
  10474. // CMSG_CMS_ENCAPSULATED_CTL_FLAG can be set to encode a CMS compatible
  10475. // V3 SignedData message.
  10476. //--------------------------------------------------------------------------
  10477. function CryptMsgSignCTL(dwMsgEncodingType: DWORD; pbCtlContent: LPBYTE;
  10478. cbCtlContent: DWORD; pSignInfo: PCMSG_SIGNED_ENCODE_INFO; dwFlags: DWORD;
  10479. pbEncoded: LPBYTE; var pcbEncoded: DWORD): BOOL; stdcall;
  10480. {$EXTERNALSYM CryptMsgSignCTL}
  10481. // When set, CTL inner content is encapsulated within an OCTET STRING
  10482. const
  10483. CMSG_CMS_ENCAPSULATED_CTL_FLAG = $00008000;
  10484. {$EXTERNALSYM CMSG_CMS_ENCAPSULATED_CTL_FLAG}
  10485. //+-------------------------------------------------------------------------
  10486. // Encode the CTL and create a signed message containing the encoded CTL.
  10487. //
  10488. // Set CMSG_ENCODE_SORTED_CTL_FLAG if the CTL entries are to be sorted
  10489. // before encoding. This flag should be set, if the
  10490. // CertFindSubjectInSortedCTL or CertEnumSubjectInSortedCTL APIs will
  10491. // be called. If the identifier for the CTL entries is a hash, such as,
  10492. // MD5 or SHA1, then, CMSG_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG should
  10493. // also be set.
  10494. //
  10495. // CMSG_CMS_ENCAPSULATED_CTL_FLAG can be set to encode a CMS compatible
  10496. // V3 SignedData message.
  10497. //--------------------------------------------------------------------------
  10498. function CryptMsgEncodeAndSignCTL(dwMsgEncodingType: DWORD; pCtlInfo: PCTL_INFO;
  10499. pSignInfo: PCMSG_SIGNED_ENCODE_INFO; dwFlags: DWORD; pbEncoded: LPBYTE;
  10500. var pcbEncoded: DWORD): BOOL; stdcall;
  10501. {$EXTERNALSYM CryptMsgEncodeAndSignCTL}
  10502. // The following flag is set if the CTL is to be encoded with sorted
  10503. // trusted subjects and the szOID_SORTED_CTL extension is inserted containing
  10504. // sorted offsets to the encoded subjects.
  10505. const
  10506. CMSG_ENCODE_SORTED_CTL_FLAG = $1;
  10507. {$EXTERNALSYM CMSG_ENCODE_SORTED_CTL_FLAG}
  10508. // If the above sorted flag is set, then, the following flag should also
  10509. // be set if the identifier for the TrustedSubjects is a hash,
  10510. // such as, MD5 or SHA1.
  10511. CMSG_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG = $2;
  10512. {$EXTERNALSYM CMSG_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG}
  10513. //+-------------------------------------------------------------------------
  10514. // Returns TRUE if the SubjectIdentifier exists in the CTL. Optionally
  10515. // returns a pointer to and byte count of the Subject's encoded attributes.
  10516. //--------------------------------------------------------------------------
  10517. function CertFindSubjectInSortedCTL(pSubjectIdentifier: PCRYPT_DATA_BLOB;
  10518. pCtlContext: PCCTL_CONTEXT; dwFlags: DWORD; pvReserved: Pointer;
  10519. pEncodedAttributes: PCRYPT_DER_BLOB): BOOL; stdcall;
  10520. {$EXTERNALSYM CertFindSubjectInSortedCTL}
  10521. //+-------------------------------------------------------------------------
  10522. // Enumerates through the sequence of TrustedSubjects in a CTL context
  10523. // created with CERT_CREATE_CONTEXT_SORTED_FLAG set.
  10524. //
  10525. // To start the enumeration, *ppvNextSubject must be NULL. Upon return,
  10526. // *ppvNextSubject is updated to point to the next TrustedSubject in
  10527. // the encoded sequence.
  10528. //
  10529. // Returns FALSE for no more subjects or invalid arguments.
  10530. //
  10531. // Note, the returned DER_BLOBs point directly into the encoded
  10532. // bytes (not allocated, and must not be freed).
  10533. //--------------------------------------------------------------------------
  10534. function CertEnumSubjectInSortedCTL(pCtlContext: PCCTL_CONTEXT;
  10535. var ppvNextSubject: Pointer; pSubjectIdentifier: PCRYPT_DER_BLOB;
  10536. pEncodedAttributes: PCRYPT_DER_BLOB): BOOL; stdcall;
  10537. {$EXTERNALSYM CertEnumSubjectInSortedCTL}
  10538. //+=========================================================================
  10539. // Certificate Verify CTL Usage Data Structures and APIs
  10540. //==========================================================================
  10541. type
  10542. PCTL_VERIFY_USAGE_PARA = ^CTL_VERIFY_USAGE_PARA;
  10543. {$EXTERNALSYM PCTL_VERIFY_USAGE_PARA}
  10544. _CTL_VERIFY_USAGE_PARA = record
  10545. cbSize: DWORD;
  10546. ListIdentifier: CRYPT_DATA_BLOB; // OPTIONAL
  10547. cCtlStore: DWORD;
  10548. rghCtlStore: PHCERTSTORE; // OPTIONAL
  10549. cSignerStore: DWORD;
  10550. rghSignerStore: PHCERTSTORE; // OPTIONAL
  10551. end;
  10552. {$EXTERNALSYM _CTL_VERIFY_USAGE_PARA}
  10553. CTL_VERIFY_USAGE_PARA = _CTL_VERIFY_USAGE_PARA;
  10554. {$EXTERNALSYM CTL_VERIFY_USAGE_PARA}
  10555. TCtlVerifyUsagePara = CTL_VERIFY_USAGE_PARA;
  10556. PCtlVerifyUsagePara = PCTL_VERIFY_USAGE_PARA;
  10557. PCTL_VERIFY_USAGE_STATUS = ^CTL_VERIFY_USAGE_STATUS;
  10558. {$EXTERNALSYM PCTL_VERIFY_USAGE_STATUS}
  10559. _CTL_VERIFY_USAGE_STATUS = record
  10560. cbSize: DWORD;
  10561. dwError: DWORD;
  10562. dwFlags: DWORD;
  10563. ppCtl: PPCCTL_CONTEXT; // IN OUT OPTIONAL
  10564. dwCtlEntryIndex: DWORD;
  10565. ppSigner: PPCCERT_CONTEXT; // IN OUT OPTIONAL
  10566. dwSignerIndex: DWORD;
  10567. end;
  10568. {$EXTERNALSYM _CTL_VERIFY_USAGE_STATUS}
  10569. CTL_VERIFY_USAGE_STATUS = _CTL_VERIFY_USAGE_STATUS;
  10570. {$EXTERNALSYM CTL_VERIFY_USAGE_STATUS}
  10571. TCtlVerifyUsageStatus = CTL_VERIFY_USAGE_STATUS;
  10572. PCtlVerifyUsageStatus = PCTL_VERIFY_USAGE_STATUS;
  10573. const
  10574. CERT_VERIFY_INHIBIT_CTL_UPDATE_FLAG = $1;
  10575. {$EXTERNALSYM CERT_VERIFY_INHIBIT_CTL_UPDATE_FLAG}
  10576. CERT_VERIFY_TRUSTED_SIGNERS_FLAG = $2;
  10577. {$EXTERNALSYM CERT_VERIFY_TRUSTED_SIGNERS_FLAG}
  10578. CERT_VERIFY_NO_TIME_CHECK_FLAG = $4;
  10579. {$EXTERNALSYM CERT_VERIFY_NO_TIME_CHECK_FLAG}
  10580. CERT_VERIFY_ALLOW_MORE_USAGE_FLAG = $8;
  10581. {$EXTERNALSYM CERT_VERIFY_ALLOW_MORE_USAGE_FLAG}
  10582. CERT_VERIFY_UPDATED_CTL_FLAG = $1;
  10583. {$EXTERNALSYM CERT_VERIFY_UPDATED_CTL_FLAG}
  10584. //+-------------------------------------------------------------------------
  10585. // Verify that a subject is trusted for the specified usage by finding a
  10586. // signed and time valid CTL with the usage identifiers and containing the
  10587. // the subject. A subject can be identified by either its certificate context
  10588. // or any identifier such as its SHA1 hash.
  10589. //
  10590. // See CertFindSubjectInCTL for definition of dwSubjectType and pvSubject
  10591. // parameters.
  10592. //
  10593. // Via pVerifyUsagePara, the caller can specify the stores to be searched
  10594. // to find the CTL. The caller can also specify the stores containing
  10595. // acceptable CTL signers. By setting the ListIdentifier, the caller
  10596. // can also restrict to a particular signer CTL list.
  10597. //
  10598. // Via pVerifyUsageStatus, the CTL containing the subject, the subject's
  10599. // index into the CTL's array of entries, and the signer of the CTL
  10600. // are returned. If the caller is not interested, ppCtl and ppSigner can be set
  10601. // to NULL. Returned contexts must be freed via the store's free context APIs.
  10602. //
  10603. // If the CERT_VERIFY_INHIBIT_CTL_UPDATE_FLAG isn't set, then, a time
  10604. // invalid CTL in one of the CtlStores may be replaced. When replaced, the
  10605. // CERT_VERIFY_UPDATED_CTL_FLAG is set in pVerifyUsageStatus->dwFlags.
  10606. //
  10607. // If the CERT_VERIFY_TRUSTED_SIGNERS_FLAG is set, then, only the
  10608. // SignerStores specified in pVerifyUsageStatus are searched to find
  10609. // the signer. Otherwise, the SignerStores provide additional sources
  10610. // to find the signer's certificate.
  10611. //
  10612. // If CERT_VERIFY_NO_TIME_CHECK_FLAG is set, then, the CTLs aren't checked
  10613. // for time validity.
  10614. //
  10615. // If CERT_VERIFY_ALLOW_MORE_USAGE_FLAG is set, then, the CTL may contain
  10616. // additional usage identifiers than specified by pSubjectUsage. Otherwise,
  10617. // the found CTL will contain the same usage identifers and no more.
  10618. //
  10619. // CertVerifyCTLUsage will be implemented as a dispatcher to OID installable
  10620. // functions. First, it will try to find an OID function matching the first
  10621. // usage object identifier in the pUsage sequence. Next, it will dispatch
  10622. // to the default CertDllVerifyCTLUsage functions.
  10623. //
  10624. // If the subject is trusted for the specified usage, then, TRUE is
  10625. // returned. Otherwise, FALSE is returned with dwError set to one of the
  10626. // following:
  10627. // CRYPT_E_NO_VERIFY_USAGE_DLL
  10628. // CRYPT_E_NO_VERIFY_USAGE_CHECK
  10629. // CRYPT_E_VERIFY_USAGE_OFFLINE
  10630. // CRYPT_E_NOT_IN_CTL
  10631. // CRYPT_E_NO_TRUSTED_SIGNER
  10632. //--------------------------------------------------------------------------
  10633. function CertVerifyCTLUsage(dwEncodingType: DWORD; dwSubjectType: DWORD;
  10634. pvSubject: Pointer; pSubjectUsage: PCTL_USAGE; dwFlags: DWORD;
  10635. pVerifyUsagePara: PCTL_VERIFY_USAGE_PARA;
  10636. pVerifyUsageStatus: PCTL_VERIFY_USAGE_STATUS): BOOL; stdcall;
  10637. {$EXTERNALSYM CertVerifyCTLUsage}
  10638. //+=========================================================================
  10639. // Certificate Revocation Data Structures and APIs
  10640. //==========================================================================
  10641. //+-------------------------------------------------------------------------
  10642. // The following data structure may be passed to CertVerifyRevocation to
  10643. // assist in finding the issuer of the context to be verified.
  10644. //
  10645. // When pIssuerCert is specified, pIssuerCert is the issuer of
  10646. // rgpvContext[cContext - 1].
  10647. //
  10648. // When cCertStore and rgCertStore are specified, these stores may contain
  10649. // an issuer certificate.
  10650. //
  10651. // When hCrlStore is specified then a handler which uses CRLs can search this
  10652. // store for them
  10653. //
  10654. // When pftTimeToUse is specified then the handler (if possible) must determine
  10655. // revocation status relative to the time given otherwise the answer may be
  10656. // independent of time or relative to current time
  10657. //--------------------------------------------------------------------------
  10658. type
  10659. PCERT_REVOCATION_PARA = ^CERT_REVOCATION_PARA;
  10660. {$EXTERNALSYM PCERT_REVOCATION_PARA}
  10661. _CERT_REVOCATION_PARA = record
  10662. cbSize: DWORD;
  10663. pIssuerCert: PCCERT_CONTEXT;
  10664. cCertStore: DWORD;
  10665. rgCertStore: PHCERTSTORE;
  10666. hCrlStore: HCERTSTORE;
  10667. pftTimeToUse: LPFILETIME;
  10668. end;
  10669. {$EXTERNALSYM _CERT_REVOCATION_PARA}
  10670. CERT_REVOCATION_PARA = _CERT_REVOCATION_PARA;
  10671. {$EXTERNALSYM CERT_REVOCATION_PARA}
  10672. TCertRevocationPara = CERT_REVOCATION_PARA;
  10673. PCertRevocationPara = PCERT_REVOCATION_PARA;
  10674. //+-------------------------------------------------------------------------
  10675. // The following data structure is returned by CertVerifyRevocation to
  10676. // specify the status of the revoked or unchecked context. Review the
  10677. // following CertVerifyRevocation comments for details.
  10678. //
  10679. // Upon input to CertVerifyRevocation, cbSize must be set to a size
  10680. // >= sizeof(CERT_REVOCATION_STATUS). Otherwise, CertVerifyRevocation
  10681. // returns FALSE and sets LastError to E_INVALIDARG.
  10682. //
  10683. // Upon input to the installed or registered CRYPT_OID_VERIFY_REVOCATION_FUNC
  10684. // functions, the dwIndex, dwError and dwReason have been zero'ed.
  10685. //--------------------------------------------------------------------------
  10686. PCERT_REVOCATION_STATUS = ^CERT_REVOCATION_STATUS;
  10687. {$EXTERNALSYM PCERT_REVOCATION_STATUS}
  10688. _CERT_REVOCATION_STATUS = record
  10689. cbSize: DWORD;
  10690. dwIndex: DWORD;
  10691. dwError: DWORD;
  10692. dwReason: DWORD;
  10693. end;
  10694. {$EXTERNALSYM _CERT_REVOCATION_STATUS}
  10695. CERT_REVOCATION_STATUS = _CERT_REVOCATION_STATUS;
  10696. {$EXTERNALSYM CERT_REVOCATION_STATUS}
  10697. TCertRevocationStatus = CERT_REVOCATION_STATUS;
  10698. PCertRevocationStatus = PCERT_REVOCATION_STATUS;
  10699. //+-------------------------------------------------------------------------
  10700. // Verifies the array of contexts for revocation. The dwRevType parameter
  10701. // indicates the type of the context data structure passed in rgpvContext.
  10702. // Currently only the revocation of certificates is defined.
  10703. //
  10704. // If the CERT_VERIFY_REV_CHAIN_FLAG flag is set, then, CertVerifyRevocation
  10705. // is verifying a chain of certs where, rgpvContext[i + 1] is the issuer
  10706. // of rgpvContext[i]. Otherwise, CertVerifyRevocation makes no assumptions
  10707. // about the order of the contexts.
  10708. //
  10709. // To assist in finding the issuer, the pRevPara may optionally be set. See
  10710. // the CERT_REVOCATION_PARA data structure for details.
  10711. //
  10712. // The contexts must contain enough information to allow the
  10713. // installable or registered revocation DLLs to find the revocation server. For
  10714. // certificates, this information would normally be conveyed in an
  10715. // extension such as the IETF's AuthorityInfoAccess extension.
  10716. //
  10717. // CertVerifyRevocation returns TRUE if all of the contexts were successfully
  10718. // checked and none were revoked. Otherwise, returns FALSE and updates the
  10719. // returned pRevStatus data structure as follows:
  10720. // dwIndex
  10721. // Index of the first context that was revoked or unable to
  10722. // be checked for revocation
  10723. // dwError
  10724. // Error status. LastError is also set to this error status.
  10725. // dwError can be set to one of the following error codes defined
  10726. // in winerror.h:
  10727. // ERROR_SUCCESS - good context
  10728. // CRYPT_E_REVOKED - context was revoked. dwReason contains the
  10729. // reason for revocation
  10730. // CRYPT_E_REVOCATION_OFFLINE - unable to connect to the
  10731. // revocation server
  10732. // CRYPT_E_NOT_IN_REVOCATION_DATABASE - the context to be checked
  10733. // was not found in the revocation server's database.
  10734. // CRYPT_E_NO_REVOCATION_CHECK - the called revocation function
  10735. // wasn't able to do a revocation check on the context
  10736. // CRYPT_E_NO_REVOCATION_DLL - no installed or registered Dll was
  10737. // found to verify revocation
  10738. // dwReason
  10739. // The dwReason is currently only set for CRYPT_E_REVOKED and contains
  10740. // the reason why the context was revoked. May be one of the following
  10741. // CRL reasons defined by the CRL Reason Code extension ("2.5.29.21")
  10742. // CRL_REASON_UNSPECIFIED 0
  10743. // CRL_REASON_KEY_COMPROMISE 1
  10744. // CRL_REASON_CA_COMPROMISE 2
  10745. // CRL_REASON_AFFILIATION_CHANGED 3
  10746. // CRL_REASON_SUPERSEDED 4
  10747. // CRL_REASON_CESSATION_OF_OPERATION 5
  10748. // CRL_REASON_CERTIFICATE_HOLD 6
  10749. //
  10750. // For each entry in rgpvContext, CertVerifyRevocation iterates
  10751. // through the CRYPT_OID_VERIFY_REVOCATION_FUNC
  10752. // function set's list of installed DEFAULT functions.
  10753. // CryptGetDefaultOIDFunctionAddress is called with pwszDll = NULL. If no
  10754. // installed functions are found capable of doing the revocation verification,
  10755. // CryptVerifyRevocation iterates through CRYPT_OID_VERIFY_REVOCATION_FUNC's
  10756. // list of registered DEFAULT Dlls. CryptGetDefaultOIDDllList is called to
  10757. // get the list. CryptGetDefaultOIDFunctionAddress is called to load the Dll.
  10758. //
  10759. // The called functions have the same signature as CertVerifyRevocation. A
  10760. // called function returns TRUE if it was able to successfully check all of
  10761. // the contexts and none were revoked. Otherwise, the called function returns
  10762. // FALSE and updates pRevStatus. dwIndex is set to the index of
  10763. // the first context that was found to be revoked or unable to be checked.
  10764. // dwError and LastError are updated. For CRYPT_E_REVOKED, dwReason
  10765. // is updated. Upon input to the called function, dwIndex, dwError and
  10766. // dwReason have been zero'ed. cbSize has been checked to be >=
  10767. // sizeof(CERT_REVOCATION_STATUS).
  10768. //
  10769. // If the called function returns FALSE, and dwError isn't set to
  10770. // CRYPT_E_REVOKED, then, CertVerifyRevocation either continues on to the
  10771. // next DLL in the list for a returned dwIndex of 0 or for a returned
  10772. // dwIndex > 0, restarts the process of finding a verify function by
  10773. // advancing the start of the context array to the returned dwIndex and
  10774. // decrementing the count of remaining contexts.
  10775. //--------------------------------------------------------------------------
  10776. function CertVerifyRevocation(dwEncodingType, dwRevType, cContext: DWORD;
  10777. rgpvContext: PVOID; dwFlags: DWORD; pRevPara: PCERT_REVOCATION_PARA;
  10778. pRevStatus: PCERT_REVOCATION_STATUS): BOOL; stdcall;
  10779. {$EXTERNALSYM CertVerifyRevocation}
  10780. //+-------------------------------------------------------------------------
  10781. // Revocation types
  10782. //--------------------------------------------------------------------------
  10783. const
  10784. CERT_CONTEXT_REVOCATION_TYPE = 1;
  10785. {$EXTERNALSYM CERT_CONTEXT_REVOCATION_TYPE}
  10786. //+-------------------------------------------------------------------------
  10787. // When the following flag is set, rgpvContext[] consists of a chain
  10788. // of certificates, where rgpvContext[i + 1] is the issuer of rgpvContext[i].
  10789. //--------------------------------------------------------------------------
  10790. CERT_VERIFY_REV_CHAIN_FLAG = $00000001;
  10791. {$EXTERNALSYM CERT_VERIFY_REV_CHAIN_FLAG}
  10792. //+-------------------------------------------------------------------------
  10793. // CERT_VERIFY_CACHE_ONLY_BASED_REVOCATION prevents the revocation handler from
  10794. // accessing any network based resources for revocation checking
  10795. //--------------------------------------------------------------------------
  10796. CERT_VERIFY_CACHE_ONLY_BASED_REVOCATION = $00000002;
  10797. {$EXTERNALSYM CERT_VERIFY_CACHE_ONLY_BASED_REVOCATION}
  10798. //+-------------------------------------------------------------------------
  10799. // CERT_CONTEXT_REVOCATION_TYPE
  10800. //
  10801. // pvContext points to a const CERT_CONTEXT.
  10802. //--------------------------------------------------------------------------
  10803. //+=========================================================================
  10804. // Certificate Helper APIs
  10805. //==========================================================================
  10806. //+-------------------------------------------------------------------------
  10807. // Compare two multiple byte integer blobs to see if they are identical.
  10808. //
  10809. // Before doing the comparison, leading zero bytes are removed from a
  10810. // positive number and leading 0xFF bytes are removed from a negative
  10811. // number.
  10812. //
  10813. // The multiple byte integers are treated as Little Endian. pbData[0] is the
  10814. // least significant byte and pbData[cbData - 1] is the most significant
  10815. // byte.
  10816. //
  10817. // Returns TRUE if the integer blobs are identical after removing leading
  10818. // 0 or 0xFF bytes.
  10819. //--------------------------------------------------------------------------
  10820. function CertCompareIntegerBlob(pInt1, pInt2: PCRYPT_INTEGER_BLOB): BOOL; stdcall;
  10821. {$EXTERNALSYM CertCompareIntegerBlob}
  10822. //+-------------------------------------------------------------------------
  10823. // Compare two certificates to see if they are identical.
  10824. //
  10825. // Since a certificate is uniquely identified by its Issuer and SerialNumber,
  10826. // these are the only fields needing to be compared.
  10827. //
  10828. // Returns TRUE if the certificates are identical.
  10829. //--------------------------------------------------------------------------
  10830. function CertCompareCertificate(dwCertEncodingType: DWORD; pCertId1, pCertId2: PCERT_INFO): BOOL; stdcall;
  10831. {$EXTERNALSYM CertCompareCertificate}
  10832. //+-------------------------------------------------------------------------
  10833. // Compare two certificate names to see if they are identical.
  10834. //
  10835. // Returns TRUE if the names are identical.
  10836. //--------------------------------------------------------------------------
  10837. function CertCompareCertificateName(dwCertEncodingType: DWORD;
  10838. pCertName1: PCERT_NAME_BLOB; pCertName2: PCERT_NAME_BLOB): BOOL; stdcall;
  10839. {$EXTERNALSYM CertCompareCertificateName}
  10840. //+-------------------------------------------------------------------------
  10841. // Compare the attributes in the certificate name with the specified
  10842. // Relative Distinguished Name's (CERT_RDN) array of attributes.
  10843. // The comparison iterates through the CERT_RDN attributes and looks for an
  10844. // attribute match in any of the certificate name's RDNs.
  10845. // Returns TRUE if all the attributes are found and match.
  10846. //
  10847. // The CERT_RDN_ATTR fields can have the following special values:
  10848. // pszObjId == NULL - ignore the attribute object identifier
  10849. // dwValueType == RDN_ANY_TYPE - ignore the value type
  10850. //
  10851. // CERT_CASE_INSENSITIVE_IS_RDN_ATTRS_FLAG should be set to do
  10852. // a case insensitive match. Otherwise, defaults to an exact, case sensitive
  10853. // match.
  10854. //
  10855. // CERT_UNICODE_IS_RDN_ATTRS_FLAG should be set if the pRDN was initialized
  10856. // with unicode strings as for CryptEncodeObject(X509_UNICODE_NAME).
  10857. //--------------------------------------------------------------------------
  10858. function CertIsRDNAttrsInCertificateName(dwCertEncodingType, dwFlags: DWORD;
  10859. pCertName: PCERT_NAME_BLOB; pRDN: PCERT_RDN): BOOL; stdcall;
  10860. {$EXTERNALSYM CertIsRDNAttrsInCertificateName}
  10861. const
  10862. CERT_UNICODE_IS_RDN_ATTRS_FLAG = $1;
  10863. {$EXTERNALSYM CERT_UNICODE_IS_RDN_ATTRS_FLAG}
  10864. CERT_CASE_INSENSITIVE_IS_RDN_ATTRS_FLAG = $2;
  10865. {$EXTERNALSYM CERT_CASE_INSENSITIVE_IS_RDN_ATTRS_FLAG}
  10866. //+-------------------------------------------------------------------------
  10867. // Compare two public keys to see if they are identical.
  10868. //
  10869. // Returns TRUE if the keys are identical.
  10870. //--------------------------------------------------------------------------
  10871. function CertComparePublicKeyInfo(dwCertEncodingType: DWORD;
  10872. pPublicKey1, pPublicKey2: PCERT_PUBLIC_KEY_INFO): BOOL; stdcall;
  10873. {$EXTERNALSYM CertComparePublicKeyInfo}
  10874. //+-------------------------------------------------------------------------
  10875. // Get the public/private key's bit length.
  10876. //
  10877. // Returns 0 if unable to determine the key's length.
  10878. //--------------------------------------------------------------------------
  10879. function CertGetPublicKeyLength(dwCertEncodingType: DWORD;
  10880. pPublicKey: PCERT_PUBLIC_KEY_INFO): DWORD; stdcall;
  10881. {$EXTERNALSYM CertGetPublicKeyLength}
  10882. //+-------------------------------------------------------------------------
  10883. // Verify the signature of a subject certificate or a CRL using the
  10884. // public key info
  10885. //
  10886. // Returns TRUE for a valid signature.
  10887. //
  10888. // hCryptProv specifies the crypto provider to use to verify the signature.
  10889. // It doesn't need to use a private key.
  10890. //--------------------------------------------------------------------------
  10891. function CryptVerifyCertificateSignature(hCryptProv: HCRYPTPROV;
  10892. dwCertEncodingType: DWORD; pbEncoded: LPBYTE; cbEncoded: DWORD;
  10893. pPublicKey: PCERT_PUBLIC_KEY_INFO): BOOL; stdcall;
  10894. {$EXTERNALSYM CryptVerifyCertificateSignature}
  10895. //+-------------------------------------------------------------------------
  10896. // Verify the signature of a subject certificate, CRL, certificate request
  10897. // or keygen request using the issuer's public key.
  10898. //
  10899. // Returns TRUE for a valid signature.
  10900. //
  10901. // The subject can be an encoded blob or a context for a certificate or CRL.
  10902. // For a subject certificate context, if the certificate is missing
  10903. // inheritable PublicKey Algorithm Parameters, the context's
  10904. // CERT_PUBKEY_ALG_PARA_PROP_ID is updated with the issuer's public key
  10905. // algorithm parameters for a valid signature.
  10906. //
  10907. // The issuer can be a pointer to a CERT_PUBLIC_KEY_INFO, certificate
  10908. // context or a chain context.
  10909. //
  10910. // hCryptProv specifies the crypto provider to use to verify the signature.
  10911. // Its private key isn't used. If hCryptProv is NULL, a default
  10912. // provider is picked according to the PublicKey Algorithm OID.
  10913. //--------------------------------------------------------------------------
  10914. function CryptVerifyCertificateSignatureEx(hCryptProv: HCRYPTPROV;
  10915. dwCertEncodingType, dwSubjectType: DWORD; pvSubject: Pointer;
  10916. dwIssuerType: DWORD; pvIssuer: Pointer; dwFlags: DWORD; pvReserved: Pointer): BOOL; stdcall;
  10917. {$EXTERNALSYM CryptVerifyCertificateSignatureEx}
  10918. // Subject Types
  10919. const
  10920. CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB = 1;
  10921. {$EXTERNALSYM CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB}
  10922. // pvSubject :: PCRYPT_DATA_BLOB
  10923. CRYPT_VERIFY_CERT_SIGN_SUBJECT_CERT = 2;
  10924. {$EXTERNALSYM CRYPT_VERIFY_CERT_SIGN_SUBJECT_CERT}
  10925. // pvSubject :: PCCERT_CONTEXT
  10926. CRYPT_VERIFY_CERT_SIGN_SUBJECT_CRL = 3;
  10927. {$EXTERNALSYM CRYPT_VERIFY_CERT_SIGN_SUBJECT_CRL}
  10928. // pvSubject :: PCCRL_CONTEXT
  10929. // Issuer Types
  10930. CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY = 1;
  10931. {$EXTERNALSYM CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY}
  10932. // pvIssuer :: PCERT_PUBLIC_KEY_INFO
  10933. CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT = 2;
  10934. {$EXTERNALSYM CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT}
  10935. // pvIssuer :: PCCERT_CONTEXT
  10936. CRYPT_VERIFY_CERT_SIGN_ISSUER_CHAIN = 3;
  10937. {$EXTERNALSYM CRYPT_VERIFY_CERT_SIGN_ISSUER_CHAIN}
  10938. // pvIssuer :: PCCERT_CHAIN_CONTEXT
  10939. //+-------------------------------------------------------------------------
  10940. // Compute the hash of the "to be signed" information in the encoded
  10941. // signed content (CERT_SIGNED_CONTENT_INFO).
  10942. //
  10943. // hCryptProv specifies the crypto provider to use to compute the hash.
  10944. // It doesn't need to use a private key.
  10945. //--------------------------------------------------------------------------
  10946. function CryptHashToBeSigned(hCryptProv: HCRYPTPROV; dwCertEncodingType: DWORD;
  10947. pbEncoded: LPBYTE; cbEncoded: DWORD; pbComputedHash: LPBYTE;
  10948. var pcbComputedHash: DWORD): BOOL; stdcall;
  10949. {$EXTERNALSYM CryptHashToBeSigned}
  10950. //+-------------------------------------------------------------------------
  10951. // Hash the encoded content.
  10952. //
  10953. // hCryptProv specifies the crypto provider to use to compute the hash.
  10954. // It doesn't need to use a private key.
  10955. //
  10956. // Algid specifies the CAPI hash algorithm to use. If Algid is 0, then, the
  10957. // default hash algorithm (currently SHA1) is used.
  10958. //--------------------------------------------------------------------------
  10959. function CryptHashCertificate(hCryptProv: HCRYPTPROV; Algid: ALG_ID;
  10960. dwFlags: DWORD; pbEncoded: LPBYTE; cbEncoded: DWORD; pbComputedHash: LPBYTE;
  10961. var pcbComputedHash: DWORD): BOOL; stdcall;
  10962. {$EXTERNALSYM CryptHashCertificate}
  10963. //+-------------------------------------------------------------------------
  10964. // Sign the "to be signed" information in the encoded signed content.
  10965. //
  10966. // hCryptProv specifies the crypto provider to use to do the signature.
  10967. // It uses the specified private key.
  10968. //--------------------------------------------------------------------------
  10969. function CryptSignCertificate(hCryptProv: HCRYPTPROV; dwKeySpec: DWORD;
  10970. dwCertEncodingType: DWORD; pbEncodedToBeSigned: LPBYTE; cbEncodedToBeSigned: DWORD;
  10971. pSignatureAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER; pvHashAuxInfo: Pointer;
  10972. pbSignature: LPBYTE; var pcbSignature: DWORD): BOOL; stdcall;
  10973. {$EXTERNALSYM CryptSignCertificate}
  10974. //+-------------------------------------------------------------------------
  10975. // Encode the "to be signed" information. Sign the encoded "to be signed".
  10976. // Encode the "to be signed" and the signature.
  10977. //
  10978. // hCryptProv specifies the crypto provider to use to do the signature.
  10979. // It uses the specified private key.
  10980. //--------------------------------------------------------------------------
  10981. function CryptSignAndEncodeCertificate(hCryptProv: HCRYPTPROV; dwKeySpec: DWORD;
  10982. dwCertEncodingType: DWORD; lpszStructType: LPCSTR; pvStructInfo: Pointer;
  10983. pSignatureAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER; pvHashAuxInfo: Pointer;
  10984. pbEncoded: PBYTE; var pcbEncoded: DWORD): BOOL; stdcall;
  10985. {$EXTERNALSYM CryptSignAndEncodeCertificate}
  10986. //+-------------------------------------------------------------------------
  10987. // Verify the time validity of a certificate.
  10988. //
  10989. // Returns -1 if before NotBefore, +1 if after NotAfter and otherwise 0 for
  10990. // a valid certificate
  10991. //
  10992. // If pTimeToVerify is NULL, uses the current time.
  10993. //--------------------------------------------------------------------------
  10994. function CertVerifyTimeValidity(pTimeToVerify: LPFILETIME; pCertInfo: PCERT_INFO): LONG; stdcall;
  10995. {$EXTERNALSYM CertVerifyTimeValidity}
  10996. //+-------------------------------------------------------------------------
  10997. // Verify the time validity of a CRL.
  10998. //
  10999. // Returns -1 if before ThisUpdate, +1 if after NextUpdate and otherwise 0 for
  11000. // a valid CRL
  11001. //
  11002. // If pTimeToVerify is NULL, uses the current time.
  11003. //--------------------------------------------------------------------------
  11004. function CertVerifyCRLTimeValidity(pTimeToVerify: LPFILETIME; pCrlInfo: PCRL_INFO): LONG; stdcall;
  11005. {$EXTERNALSYM CertVerifyCRLTimeValidity}
  11006. //+-------------------------------------------------------------------------
  11007. // Verify that the subject's time validity nests within the issuer's time
  11008. // validity.
  11009. //
  11010. // Returns TRUE if it nests. Otherwise, returns FALSE.
  11011. //--------------------------------------------------------------------------
  11012. function CertVerifyValidityNesting(pSubjectInfo, pIssuerInfo: PCERT_INFO): BOOL; stdcall;
  11013. {$EXTERNALSYM CertVerifyValidityNesting}
  11014. //+-------------------------------------------------------------------------
  11015. // Verify that the subject certificate isn't on its issuer CRL.
  11016. //
  11017. // Returns true if the certificate isn't on the CRL.
  11018. //--------------------------------------------------------------------------
  11019. function CertVerifyCRLRevocation(dwCertEncodingType: DWORD; pCertId: PCERT_INFO;
  11020. cCrlInfo: DWORD; rgpCrlInfo: PCRL_INFO): BOOL; stdcall;
  11021. {$EXTERNALSYM CertVerifyCRLRevocation}
  11022. //+-------------------------------------------------------------------------
  11023. // Convert the CAPI AlgId to the ASN.1 Object Identifier string
  11024. //
  11025. // Returns NULL if there isn't an ObjId corresponding to the AlgId.
  11026. //--------------------------------------------------------------------------
  11027. function CertAlgIdToOID(dwAlgId: DWORD): LPCSTR; stdcall;
  11028. {$EXTERNALSYM CertAlgIdToOID}
  11029. //+-------------------------------------------------------------------------
  11030. // Convert the ASN.1 Object Identifier string to the CAPI AlgId.
  11031. //
  11032. // Returns 0 if there isn't an AlgId corresponding to the ObjId.
  11033. //--------------------------------------------------------------------------
  11034. function CertOIDToAlgId(pszObjId: LPCSTR): DWORD; stdcall;
  11035. {$EXTERNALSYM CertOIDToAlgId}
  11036. //+-------------------------------------------------------------------------
  11037. // Find an extension identified by its Object Identifier.
  11038. //
  11039. // If found, returns pointer to the extension. Otherwise, returns NULL.
  11040. //--------------------------------------------------------------------------
  11041. function CertFindExtension(pszObjId: LPCSTR; cExtensions: DWORD;
  11042. rgExtensions: PCERT_EXTENSION): PCERT_EXTENSION; stdcall;
  11043. {$EXTERNALSYM CertFindExtension}
  11044. //+-------------------------------------------------------------------------
  11045. // Find the first attribute identified by its Object Identifier.
  11046. //
  11047. // If found, returns pointer to the attribute. Otherwise, returns NULL.
  11048. //--------------------------------------------------------------------------
  11049. function CertFindAttribute(pszObjId: LPCSTR; cAttr: DWORD;
  11050. rgAttr: PCRYPT_ATTRIBUTE): PCRYPT_ATTRIBUTE; stdcall;
  11051. {$EXTERNALSYM CertFindAttribute}
  11052. //+-------------------------------------------------------------------------
  11053. // Find the first CERT_RDN attribute identified by its Object Identifier in
  11054. // the name's list of Relative Distinguished Names.
  11055. //
  11056. // If found, returns pointer to the attribute. Otherwise, returns NULL.
  11057. //--------------------------------------------------------------------------
  11058. function CertFindRDNAttr(pszObjId: LPCSTR; pName: PCERT_NAME_INFO): PCERT_RDN_ATTR; stdcall;
  11059. {$EXTERNALSYM CertFindRDNAttr}
  11060. //+-------------------------------------------------------------------------
  11061. // Get the intended key usage bytes from the certificate.
  11062. //
  11063. // If the certificate doesn't have any intended key usage bytes, returns FALSE
  11064. // and *pbKeyUsage is zeroed. Otherwise, returns TRUE and up through
  11065. // cbKeyUsage bytes are copied into *pbKeyUsage. Any remaining uncopied
  11066. // bytes are zeroed.
  11067. //--------------------------------------------------------------------------
  11068. function CertGetIntendedKeyUsage(dwCertEncodingType: DWORD; pCertInfo: PCERT_INFO;
  11069. pbKeyUsage: LPBYTE; cbKeyUsage: DWORD): BOOL; stdcall;
  11070. {$EXTERNALSYM CertGetIntendedKeyUsage}
  11071. type
  11072. HCRYPTDEFAULTCONTEXT = Pointer;
  11073. {$EXTERNALSYM HCRYPTDEFAULTCONTEXT}
  11074. //+-------------------------------------------------------------------------
  11075. // Install a previously CryptAcquiredContext'ed HCRYPTPROV to be used as
  11076. // a default context.
  11077. //
  11078. // dwDefaultType and pvDefaultPara specify where the default context is used.
  11079. // For example, install the HCRYPTPROV to be used to verify certificate's
  11080. // having szOID_OIWSEC_md5RSA signatures.
  11081. //
  11082. // By default, the installed HCRYPTPROV is only applicable to the current
  11083. // thread. Set CRYPT_DEFAULT_CONTEXT_PROCESS_FLAG to allow the HCRYPTPROV
  11084. // to be used by all threads in the current process.
  11085. //
  11086. // For a successful install, TRUE is returned and *phDefaultContext is
  11087. // updated with the HANDLE to be passed to CryptUninstallDefaultContext.
  11088. //
  11089. // The installed HCRYPTPROVs are stack ordered (the last installed
  11090. // HCRYPTPROV is checked first). All thread installed HCRYPTPROVs are
  11091. // checked before any process HCRYPTPROVs.
  11092. //
  11093. // The installed HCRYPTPROV remains available for default usage until
  11094. // CryptUninstallDefaultContext is called or the thread or process exits.
  11095. //
  11096. // If CRYPT_DEFAULT_CONTEXT_AUTO_RELEASE_FLAG is set, then, the HCRYPTPROV
  11097. // is CryptReleaseContext'ed at thread or process exit. However,
  11098. // not CryptReleaseContext'ed if CryptUninstallDefaultContext is
  11099. // called.
  11100. //--------------------------------------------------------------------------
  11101. function CryptInstallDefaultContext(hCryptProv: HCRYPTPROV; dwDefaultType: DWORD;
  11102. pvDefaultPara: Pointer; dwFlags: DWORD; pvReserved: Pointer;
  11103. var phDefaultContext: HCRYPTDEFAULTCONTEXT): BOOL; stdcall;
  11104. {$EXTERNALSYM CryptInstallDefaultContext}
  11105. // dwFlags
  11106. const
  11107. CRYPT_DEFAULT_CONTEXT_AUTO_RELEASE_FLAG = $00000001;
  11108. {$EXTERNALSYM CRYPT_DEFAULT_CONTEXT_AUTO_RELEASE_FLAG}
  11109. CRYPT_DEFAULT_CONTEXT_PROCESS_FLAG = $00000002;
  11110. {$EXTERNALSYM CRYPT_DEFAULT_CONTEXT_PROCESS_FLAG}
  11111. // List of dwDefaultType's
  11112. CRYPT_DEFAULT_CONTEXT_CERT_SIGN_OID = 1;
  11113. {$EXTERNALSYM CRYPT_DEFAULT_CONTEXT_CERT_SIGN_OID}
  11114. CRYPT_DEFAULT_CONTEXT_MULTI_CERT_SIGN_OID = 2;
  11115. {$EXTERNALSYM CRYPT_DEFAULT_CONTEXT_MULTI_CERT_SIGN_OID}
  11116. //+-------------------------------------------------------------------------
  11117. // CRYPT_DEFAULT_CONTEXT_CERT_SIGN_OID
  11118. //
  11119. // Install a default HCRYPTPROV used to verify a certificate
  11120. // signature. pvDefaultPara points to the szOID of the certificate
  11121. // signature algorithm, for example, szOID_OIWSEC_md5RSA. If
  11122. // pvDefaultPara is NULL, then, the HCRYPTPROV is used to verify all
  11123. // certificate signatures. Note, pvDefaultPara can't be NULL when
  11124. // CRYPT_DEFAULT_CONTEXT_PROCESS_FLAG is set.
  11125. //--------------------------------------------------------------------------
  11126. //+-------------------------------------------------------------------------
  11127. // CRYPT_DEFAULT_CONTEXT_MULTI_CERT_SIGN_OID
  11128. //
  11129. // Same as CRYPT_DEFAULT_CONTEXT_CERT_SIGN_OID. However, the default
  11130. // HCRYPTPROV is to be used for multiple signature szOIDs. pvDefaultPara
  11131. // points to a CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA structure containing
  11132. // an array of szOID pointers.
  11133. //--------------------------------------------------------------------------
  11134. type
  11135. PCRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA = ^CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA;
  11136. {$EXTERNALSYM PCRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA}
  11137. _CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA = record
  11138. cOID: DWORD;
  11139. rgpszOID: LPLPSTR;
  11140. end;
  11141. {$EXTERNALSYM _CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA}
  11142. CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA = _CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA;
  11143. {$EXTERNALSYM CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA}
  11144. TCryptDefaultContextMultiOidPara = CRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA;
  11145. PCryptDefaultContextMultiOidPara = PCRYPT_DEFAULT_CONTEXT_MULTI_OID_PARA;
  11146. //+-------------------------------------------------------------------------
  11147. // Uninstall a default context previously installed by
  11148. // CryptInstallDefaultContext.
  11149. //
  11150. // For a default context installed with CRYPT_DEFAULT_CONTEXT_PROCESS_FLAG
  11151. // set, if any other threads are currently using this context,
  11152. // this function will block until they finish.
  11153. //--------------------------------------------------------------------------
  11154. function CryptUninstallDefaultContext(hDefaultContext: HCRYPTDEFAULTCONTEXT;
  11155. dwFlags: DWORD; pvReserved: Pointer): BOOL; stdcall;
  11156. {$EXTERNALSYM CryptUninstallDefaultContext}
  11157. //+-------------------------------------------------------------------------
  11158. // Export the public key info associated with the provider's corresponding
  11159. // private key.
  11160. //
  11161. // Calls CryptExportPublicKeyInfo with pszPublicKeyObjId = szOID_RSA_RSA,
  11162. // dwFlags = 0 and pvAuxInfo = NULL.
  11163. //--------------------------------------------------------------------------
  11164. function CryptExportPublicKeyInfo(hCryptProv: HCRYPTPROV; dwKeySpec: DWORD;
  11165. dwCertEncodingType: DWORD; pInfo: PCERT_PUBLIC_KEY_INFO; var pcbInfo: DWORD): BOOL; stdcall;
  11166. {$EXTERNALSYM CryptExportPublicKeyInfo}
  11167. //+-------------------------------------------------------------------------
  11168. // Export the public key info associated with the provider's corresponding
  11169. // private key.
  11170. //
  11171. // Uses the dwCertEncodingType and pszPublicKeyObjId to call the
  11172. // installable CRYPT_OID_EXPORT_PUBLIC_KEY_INFO_FUNC. The called function
  11173. // has the same signature as CryptExportPublicKeyInfoEx.
  11174. //
  11175. // If unable to find an installable OID function for the pszPublicKeyObjId,
  11176. // attempts to export as a RSA Public Key (szOID_RSA_RSA).
  11177. //
  11178. // The dwFlags and pvAuxInfo aren't used for szOID_RSA_RSA.
  11179. //--------------------------------------------------------------------------
  11180. const
  11181. CRYPT_OID_EXPORT_PUBLIC_KEY_INFO_FUNC = 'CryptDllExportPublicKeyInfoEx';
  11182. {$EXTERNALSYM CRYPT_OID_EXPORT_PUBLIC_KEY_INFO_FUNC}
  11183. function CryptExportPublicKeyInfoEx(hCryptProv: HCRYPTPROV; dwKeySpec: DWORD;
  11184. dwCertEncodingType: DWORD; pszPublicKeyObjId: LPSTR; dwFlags: DWORD;
  11185. pvAuxInfo: Pointer; pInfo: PCERT_PUBLIC_KEY_INFO; var pcbInfo: DWORD): BOOL; stdcall;
  11186. {$EXTERNALSYM CryptExportPublicKeyInfoEx}
  11187. //+-------------------------------------------------------------------------
  11188. // Convert and import the public key info into the provider and return a
  11189. // handle to the public key.
  11190. //
  11191. // Calls CryptImportPublicKeyInfoEx with aiKeyAlg = 0, dwFlags = 0 and
  11192. // pvAuxInfo = NULL.
  11193. //--------------------------------------------------------------------------
  11194. function CryptImportPublicKeyInfo(hCryptProv: HCRYPTPROV; dwCertEncodingType: DWORD;
  11195. pInfo: PCERT_PUBLIC_KEY_INFO; var phKey: HCRYPTKEY): BOOL; stdcall;
  11196. {$EXTERNALSYM CryptImportPublicKeyInfo}
  11197. //+-------------------------------------------------------------------------
  11198. // Convert and import the public key info into the provider and return a
  11199. // handle to the public key.
  11200. //
  11201. // Uses the dwCertEncodingType and pInfo->Algorithm.pszObjId to call the
  11202. // installable CRYPT_OID_IMPORT_PUBLIC_KEY_INFO_FUNC. The called function
  11203. // has the same signature as CryptImportPublicKeyInfoEx.
  11204. //
  11205. // If unable to find an installable OID function for the pszObjId,
  11206. // attempts to import as a RSA Public Key (szOID_RSA_RSA).
  11207. //
  11208. // For szOID_RSA_RSA: aiKeyAlg may be set to CALG_RSA_SIGN or CALG_RSA_KEYX.
  11209. // Defaults to CALG_RSA_KEYX. The dwFlags and pvAuxInfo aren't used.
  11210. //--------------------------------------------------------------------------
  11211. const
  11212. CRYPT_OID_IMPORT_PUBLIC_KEY_INFO_FUNC = 'CryptDllImportPublicKeyInfoEx';
  11213. {$EXTERNALSYM CRYPT_OID_IMPORT_PUBLIC_KEY_INFO_FUNC}
  11214. function CryptImportPublicKeyInfoEx(hCryptProv: HCRYPTPROV; dwCertEncodingType: DWORD;
  11215. pInfo: PCERT_PUBLIC_KEY_INFO; aiKeyAlg: ALG_ID; dwFlags: DWORD; pvAuxInfo: Pointer;
  11216. var phKey: HCRYPTKEY): BOOL; stdcall;
  11217. {$EXTERNALSYM CryptImportPublicKeyInfoEx}
  11218. //+-------------------------------------------------------------------------
  11219. // Acquire a HCRYPTPROV handle and dwKeySpec for the specified certificate
  11220. // context. Uses the certificate's CERT_KEY_PROV_INFO_PROP_ID property.
  11221. // The returned HCRYPTPROV handle may optionally be cached using the
  11222. // certificate's CERT_KEY_CONTEXT_PROP_ID property.
  11223. //
  11224. // If CRYPT_ACQUIRE_CACHE_FLAG is set, then, if an already acquired and
  11225. // cached HCRYPTPROV exists for the certificate, its returned. Otherwise,
  11226. // a HCRYPTPROV is acquired and then cached via the certificate's
  11227. // CERT_KEY_CONTEXT_PROP_ID.
  11228. //
  11229. // The CRYPT_ACQUIRE_USE_PROV_INFO_FLAG can be set to use the dwFlags field of
  11230. // the certificate's CERT_KEY_PROV_INFO_PROP_ID property's CRYPT_KEY_PROV_INFO
  11231. // data structure to determine if the returned HCRYPTPROV should be cached.
  11232. // HCRYPTPROV caching is enabled if the CERT_SET_KEY_CONTEXT_PROP_ID flag was
  11233. // set.
  11234. //
  11235. // If CRYPT_ACQUIRE_COMPARE_KEY_FLAG is set, then,
  11236. // the public key in the certificate is compared with the public
  11237. // key returned by the cryptographic provider. If the keys don't match, the
  11238. // acquire fails and LastError is set to NTE_BAD_PUBLIC_KEY. Note, if
  11239. // a cached HCRYPTPROV is returned, the comparison isn't done. We assume the
  11240. // comparison was done on the initial acquire.
  11241. //
  11242. // *pfCallerFreeProv is returned set to FALSE for:
  11243. // - Acquire or public key comparison fails.
  11244. // - CRYPT_ACQUIRE_CACHE_FLAG is set.
  11245. // - CRYPT_ACQUIRE_USE_PROV_INFO_FLAG is set AND
  11246. // CERT_SET_KEY_CONTEXT_PROP_ID flag is set in the dwFlags field of the
  11247. // certificate's CERT_KEY_PROV_INFO_PROP_ID property's
  11248. // CRYPT_KEY_PROV_INFO data structure.
  11249. // When *pfCallerFreeProv is FALSE, the caller must not release. The
  11250. // returned HCRYPTPROV will be released on the last free of the certificate
  11251. // context.
  11252. //
  11253. // Otherwise, *pfCallerFreeProv is TRUE and the returned HCRYPTPROV must
  11254. // be released by the caller by calling CryptReleaseContext.
  11255. //--------------------------------------------------------------------------
  11256. function CryptAcquireCertificatePrivateKey(pCert: PCCERT_CONTEXT; dwFlags: DWORD;
  11257. pvReserved: Pointer; var phCryptProv: HCRYPTPROV; pdwKeySpec: LPDWORD;
  11258. pfCallerFreeProv: PBOOL): BOOL; stdcall;
  11259. {$EXTERNALSYM CryptAcquireCertificatePrivateKey}
  11260. const
  11261. CRYPT_ACQUIRE_CACHE_FLAG = $1;
  11262. {$EXTERNALSYM CRYPT_ACQUIRE_CACHE_FLAG}
  11263. CRYPT_ACQUIRE_USE_PROV_INFO_FLAG = $2;
  11264. {$EXTERNALSYM CRYPT_ACQUIRE_USE_PROV_INFO_FLAG}
  11265. CRYPT_ACQUIRE_COMPARE_KEY_FLAG = $4;
  11266. {$EXTERNALSYM CRYPT_ACQUIRE_COMPARE_KEY_FLAG}
  11267. //+-------------------------------------------------------------------------
  11268. // Enumerates the cryptographic providers and their containers to find the
  11269. // private key corresponding to the certificate's public key. For a match,
  11270. // the certificate's CERT_KEY_PROV_INFO_PROP_ID property is updated.
  11271. //
  11272. // If the CERT_KEY_PROV_INFO_PROP_ID is already set, then, its checked to
  11273. // see if it matches the provider's public key. For a match, the above
  11274. // enumeration is skipped.
  11275. //
  11276. // By default both the user and machine key containers are searched.
  11277. // The CRYPT_FIND_USER_KEYSET_FLAG or CRYPT_FIND_MACHINE_KEYSET_FLAG
  11278. // can be set in dwFlags to restrict the search to either of the containers.
  11279. //
  11280. // If a container isn't found, returns FALSE with LastError set to
  11281. // NTE_NO_KEY.
  11282. //--------------------------------------------------------------------------
  11283. function CryptFindCertificateKeyProvInfo(pCert: PCCERT_CONTEXT; dwFlags: DWORD;
  11284. pvReserved: Pointer): BOOL; stdcall;
  11285. {$EXTERNALSYM CryptFindCertificateKeyProvInfo}
  11286. const
  11287. CRYPT_FIND_USER_KEYSET_FLAG = $1;
  11288. {$EXTERNALSYM CRYPT_FIND_USER_KEYSET_FLAG}
  11289. CRYPT_FIND_MACHINE_KEYSET_FLAG = $2;
  11290. {$EXTERNALSYM CRYPT_FIND_MACHINE_KEYSET_FLAG}
  11291. //+-------------------------------------------------------------------------
  11292. // This is the prototype for the installable function which is called to
  11293. // actually import a key into a CSP. an installable of this type is called
  11294. // from CryptImportPKCS8. the algorithm OID of the private key is used
  11295. // to look up the proper installable function to call.
  11296. //
  11297. // hCryptProv - the provider to import the key to
  11298. // pPrivateKeyInfo - describes the key to be imported
  11299. // dwFlags - The available flags are:
  11300. // CRYPT_EXPORTABLE
  11301. // this flag is used when importing private keys, for a full
  11302. // explanation please see the documentation for CryptImportKey.
  11303. // pvAuxInfo - reserved for future, must be NULL
  11304. //--------------------------------------------------------------------------
  11305. type
  11306. PFN_IMPORT_PRIV_KEY_FUNC = function(hCryptProv: HCRYPTPROV;
  11307. pPrivateKeyInfo: PCRYPT_PRIVATE_KEY_INFO; dwFlags: DWORD;
  11308. pvAuxInfo: Pointer): BOOL; stdcall;
  11309. {$EXTERNALSYM PFN_IMPORT_PRIV_KEY_FUNC}
  11310. PFnImportPrivKeyFunc = PFN_IMPORT_PRIV_KEY_FUNC;
  11311. const
  11312. CRYPT_OID_IMPORT_PRIVATE_KEY_INFO_FUNC = 'CryptDllImportPrivateKeyInfoEx';
  11313. {$EXTERNALSYM CRYPT_OID_IMPORT_PRIVATE_KEY_INFO_FUNC}
  11314. //+-------------------------------------------------------------------------
  11315. // Convert (from PKCS8 format) and import the private key into a provider
  11316. // and return a handle to the provider as well as the KeySpec used to import to.
  11317. //
  11318. // This function will call the PRESOLVE_HCRYPTPROV_FUNC in the
  11319. // privateKeyAndParams to obtain a handle of provider to import the key to.
  11320. // if the PRESOLVE_HCRYPTPROV_FUNC is NULL then the default provider will be used.
  11321. //
  11322. // privateKeyAndParams - private key blob and corresponding parameters
  11323. // dwFlags - The available flags are:
  11324. // CRYPT_EXPORTABLE
  11325. // this flag is used when importing private keys, for a full
  11326. // explanation please see the documentation for CryptImportKey.
  11327. // phCryptProv - filled in with the handle of the provider the key was
  11328. // imported to, the caller is responsible for freeing it
  11329. // pvAuxInfo - This parameter is reserved for future use and should be set
  11330. // to NULL in the interim.
  11331. //--------------------------------------------------------------------------
  11332. function CryptImportPKCS8(sImportParams: CRYPT_PKCS8_IMPORT_PARAMS; dwFlags: DWORD;
  11333. phCryptProv: PHCRYPTPROV; pvAuxInfo: Pointer): BOOL; stdcall;
  11334. {$EXTERNALSYM CryptImportPKCS8}
  11335. //+-------------------------------------------------------------------------
  11336. // this is the prototype for installable functions for exporting the private key
  11337. //--------------------------------------------------------------------------
  11338. type
  11339. PFN_EXPORT_PRIV_KEY_FUNC = function(hCryptProv: HCRYPTPROV; dwKeySpec: DWORD;
  11340. pszPrivateKeyObjId: LPSTR; dwFlags: DWORD; pvAuxInfo: Pointer;
  11341. var pPrivateKeyInfo: CRYPT_PRIVATE_KEY_INFO; var pcbPrivateKeyBlob: DWORD): BOOL; stdcall;
  11342. {$EXTERNALSYM PFN_EXPORT_PRIV_KEY_FUNC}
  11343. PfnExportPrivKeyFunc = PFN_EXPORT_PRIV_KEY_FUNC;
  11344. const
  11345. CRYPT_OID_EXPORT_PRIVATE_KEY_INFO_FUNC = 'CryptDllExportPrivateKeyInfoEx';
  11346. {$EXTERNALSYM CRYPT_OID_EXPORT_PRIVATE_KEY_INFO_FUNC}
  11347. CRYPT_DELETE_KEYSET = $0001;
  11348. {$EXTERNALSYM CRYPT_DELETE_KEYSET}
  11349. //+-------------------------------------------------------------------------
  11350. // CryptExportPKCS8 -- superseded by CryptExportPKCS8Ex
  11351. //
  11352. // Export the private key in PKCS8 format
  11353. //--------------------------------------------------------------------------
  11354. function CryptExportPKCS8(hCryptProv: HCRYPTPROV; dwKeySpec: DWORD;
  11355. pszPrivateKeyObjId: LPSTR; dwFlags: DWORD; pvAuxInfo: Pointer;
  11356. pbPrivateKeyBlob: LPBYTE; var pcbPrivateKeyBlob: DWORD): BOOL; stdcall;
  11357. {$EXTERNALSYM CryptExportPKCS8}
  11358. //+-------------------------------------------------------------------------
  11359. // CryptExportPKCS8Ex
  11360. //
  11361. // Export the private key in PKCS8 format
  11362. //
  11363. //
  11364. // Uses the pszPrivateKeyObjId to call the
  11365. // installable CRYPT_OID_EXPORT_PRIVATE_KEY_INFO_FUNC. The called function
  11366. // has the signature defined by PFN_EXPORT_PRIV_KEY_FUNC.
  11367. //
  11368. // If unable to find an installable OID function for the pszPrivateKeyObjId,
  11369. // attempts to export as a RSA Private Key (szOID_RSA_RSA).
  11370. //
  11371. // psExportParams - specifies information about the key to export
  11372. // dwFlags - The flag values. None currently supported
  11373. // pvAuxInfo - This parameter is reserved for future use and should be set to
  11374. // NULL in the interim.
  11375. // pbPrivateKeyBlob - A pointer to the private key blob. It will be encoded
  11376. // as a PKCS8 PrivateKeyInfo.
  11377. // pcbPrivateKeyBlob - A pointer to a DWORD that contains the size, in bytes,
  11378. // of the private key blob being exported.
  11379. //+-------------------------------------------------------------------------
  11380. function CryptExportPKCS8Ex(psExportParams: PCRYPT_PKCS8_EXPORT_PARAMS;
  11381. dwFlags: DWORD; pvAuxInfo: Pointer; pbPrivateKeyBlob: LPBYTE;
  11382. var pcbPrivateKeyBlob: DWORD): BOOL; stdcall;
  11383. {$EXTERNALSYM CryptExportPKCS8Ex}
  11384. //+-------------------------------------------------------------------------
  11385. // Compute the hash of the encoded public key info.
  11386. //
  11387. // The public key info is encoded and then hashed.
  11388. //--------------------------------------------------------------------------
  11389. function CryptHashPublicKeyInfo(hCryptProv: HCRYPTPROV; Algid: ALG_ID;
  11390. dwFlags: DWORD; dwCertEncodingType: DWORD; pInfo: PCERT_PUBLIC_KEY_INFO;
  11391. pbComputedHash: LPBYTE; var pcbComputedHash: DWORD): BOOL; stdcall;
  11392. {$EXTERNALSYM CryptHashPublicKeyInfo}
  11393. //+-------------------------------------------------------------------------
  11394. // Convert a Name Value to a null terminated char string
  11395. //
  11396. // Returns the number of characters converted including the terminating null
  11397. // character. If psz is NULL or csz is 0, returns the required size of the
  11398. // destination string (including the terminating null char).
  11399. //
  11400. // If psz != NULL && csz != 0, returned psz is always NULL terminated.
  11401. //
  11402. // Note: csz includes the NULL char.
  11403. //--------------------------------------------------------------------------
  11404. function CertRDNValueToStrA(dwValueType: DWORD; pValue: PCERT_RDN_VALUE_BLOB;
  11405. psz: LPSTR; csz: DWORD): DWORD; stdcall;
  11406. {$EXTERNALSYM CertRDNValueToStrA}
  11407. //+-------------------------------------------------------------------------
  11408. // Convert a Name Value to a null terminated char string
  11409. //
  11410. // Returns the number of characters converted including the terminating null
  11411. // character. If psz is NULL or csz is 0, returns the required size of the
  11412. // destination string (including the terminating null char).
  11413. //
  11414. // If psz != NULL && csz != 0, returned psz is always NULL terminated.
  11415. //
  11416. // Note: csz includes the NULL char.
  11417. //--------------------------------------------------------------------------
  11418. function CertRDNValueToStrW(dwValueType: DWORD; pValue: PCERT_RDN_VALUE_BLOB;
  11419. psz: LPWSTR; csz: DWORD): DWORD; stdcall;
  11420. {$EXTERNALSYM CertRDNValueToStrW}
  11421. function CertRDNValueToStr(dwValueType: DWORD; pValue: PCERT_RDN_VALUE_BLOB;
  11422. psz: LPTSTR; csz: DWORD): DWORD; stdcall;
  11423. {$EXTERNALSYM CertRDNValueToStr}
  11424. //+-------------------------------------------------------------------------
  11425. // Convert the certificate name blob to a null terminated char string.
  11426. //
  11427. // Follows the string representation of distinguished names specified in
  11428. // RFC 1779. (Note, added double quoting "" for embedded quotes, quote
  11429. // empty strings and don't quote strings containing consecutive spaces).
  11430. // RDN values of type CERT_RDN_ENCODED_BLOB or CERT_RDN_OCTET_STRING are
  11431. // formatted in hexadecimal (e.g. #0A56CF).
  11432. //
  11433. // The name string is formatted according to the dwStrType:
  11434. // CERT_SIMPLE_NAME_STR
  11435. // The object identifiers are discarded. CERT_RDN entries are separated
  11436. // by ", ". Multiple attributes per CERT_RDN are separated by " + ".
  11437. // For example:
  11438. // Microsoft, Joe Cool + Programmer
  11439. // CERT_OID_NAME_STR
  11440. // The object identifiers are included with a "=" separator from their
  11441. // attribute value. CERT_RDN entries are separated by ", ".
  11442. // Multiple attributes per CERT_RDN are separated by " + ". For example:
  11443. // 2.5.4.11=Microsoft, 2.5.4.3=Joe Cool + 2.5.4.12=Programmer
  11444. // CERT_X500_NAME_STR
  11445. // The object identifiers are converted to their X500 key name. Otherwise,
  11446. // same as CERT_OID_NAME_STR. If the object identifier doesn't have
  11447. // a corresponding X500 key name, then, the object identifier is used with
  11448. // a "OID." prefix. For example:
  11449. // OU=Microsoft, CN=Joe Cool + T=Programmer, OID.1.2.3.4.5.6=Unknown
  11450. //
  11451. // We quote the RDN value if it contains leading or trailing whitespace
  11452. // or one of the following characters: ",", "+", "=", """, "\n", "<", ">",
  11453. // "#" or ";". The quoting character is ". If the the RDN Value contains
  11454. // a " it is double quoted (""). For example:
  11455. // OU=" Microsoft", CN="Joe ""Cool""" + T="Programmer, Manager"
  11456. //
  11457. // CERT_NAME_STR_SEMICOLON_FLAG can be or'ed into dwStrType to replace
  11458. // the ", " separator with a "; " separator.
  11459. //
  11460. // CERT_NAME_STR_CRLF_FLAG can be or'ed into dwStrType to replace
  11461. // the ", " separator with a "\r\n" separator.
  11462. //
  11463. // CERT_NAME_STR_NO_PLUS_FLAG can be or'ed into dwStrType to replace the
  11464. // " + " separator with a single space, " ".
  11465. //
  11466. // CERT_NAME_STR_NO_QUOTING_FLAG can be or'ed into dwStrType to inhibit
  11467. // the above quoting.
  11468. //
  11469. // CERT_NAME_STR_REVERSE_FLAG can be or'ed into dwStrType to reverse the
  11470. // order of the RDNs before converting to the string.
  11471. //
  11472. // By default, CERT_RDN_T61_STRING encoded values are initially decoded
  11473. // as UTF8. If the UTF8 decoding fails, then, decoded as 8 bit characters.
  11474. // CERT_NAME_STR_DISABLE_IE4_UTF8_FLAG can be or'ed into dwStrType to
  11475. // skip the initial attempt to decode as UTF8.
  11476. //
  11477. // Returns the number of characters converted including the terminating null
  11478. // character. If psz is NULL or csz is 0, returns the required size of the
  11479. // destination string (including the terminating null char).
  11480. //
  11481. // If psz != NULL && csz != 0, returned psz is always NULL terminated.
  11482. //
  11483. // Note: csz includes the NULL char.
  11484. //--------------------------------------------------------------------------
  11485. //+-------------------------------------------------------------------------
  11486. //--------------------------------------------------------------------------
  11487. function CertNameToStrA(dwCertEncodingType: DWORD; pName: PCERT_NAME_BLOB;
  11488. dwStrType: DWORD; psz: LPSTR; csz: DWORD): DWORD; stdcall;
  11489. {$EXTERNALSYM CertNameToStrA}
  11490. //+-------------------------------------------------------------------------
  11491. //--------------------------------------------------------------------------
  11492. function CertNameToStrW(dwCertEncodingType: DWORD; pName: PCERT_NAME_BLOB;
  11493. dwStrType: DWORD; psz: LPWSTR; csz: DWORD): DWORD; stdcall;
  11494. {$EXTERNALSYM CertNameToStrW}
  11495. function CertNameToStr(dwCertEncodingType: DWORD; pName: PCERT_NAME_BLOB;
  11496. dwStrType: DWORD; psz: LPTSTR; csz: DWORD): DWORD; stdcall;
  11497. {$EXTERNALSYM CertNameToStr}
  11498. //+-------------------------------------------------------------------------
  11499. // Certificate name string types
  11500. //--------------------------------------------------------------------------
  11501. const
  11502. CERT_SIMPLE_NAME_STR = 1;
  11503. {$EXTERNALSYM CERT_SIMPLE_NAME_STR}
  11504. CERT_OID_NAME_STR = 2;
  11505. {$EXTERNALSYM CERT_OID_NAME_STR}
  11506. CERT_X500_NAME_STR = 3;
  11507. {$EXTERNALSYM CERT_X500_NAME_STR}
  11508. //+-------------------------------------------------------------------------
  11509. // Certificate name string type flags OR'ed with the above types
  11510. //--------------------------------------------------------------------------
  11511. CERT_NAME_STR_SEMICOLON_FLAG = $40000000;
  11512. {$EXTERNALSYM CERT_NAME_STR_SEMICOLON_FLAG}
  11513. CERT_NAME_STR_NO_PLUS_FLAG = $20000000;
  11514. {$EXTERNALSYM CERT_NAME_STR_NO_PLUS_FLAG}
  11515. CERT_NAME_STR_NO_QUOTING_FLAG = $10000000;
  11516. {$EXTERNALSYM CERT_NAME_STR_NO_QUOTING_FLAG}
  11517. CERT_NAME_STR_CRLF_FLAG = $08000000;
  11518. {$EXTERNALSYM CERT_NAME_STR_CRLF_FLAG}
  11519. CERT_NAME_STR_COMMA_FLAG = $04000000;
  11520. {$EXTERNALSYM CERT_NAME_STR_COMMA_FLAG}
  11521. CERT_NAME_STR_REVERSE_FLAG = $02000000;
  11522. {$EXTERNALSYM CERT_NAME_STR_REVERSE_FLAG}
  11523. CERT_NAME_STR_DISABLE_IE4_UTF8_FLAG = $00010000;
  11524. {$EXTERNALSYM CERT_NAME_STR_DISABLE_IE4_UTF8_FLAG}
  11525. CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG = $00020000;
  11526. {$EXTERNALSYM CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG}
  11527. CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG = $00040000;
  11528. {$EXTERNALSYM CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG}
  11529. //+-------------------------------------------------------------------------
  11530. // Convert the null terminated X500 string to an encoded certificate name.
  11531. //
  11532. // The input string is expected to be formatted the same as the output
  11533. // from the above CertNameToStr API.
  11534. //
  11535. // The CERT_SIMPLE_NAME_STR type isn't supported. Otherwise, when dwStrType
  11536. // is set to 0, CERT_OID_NAME_STR or CERT_X500_NAME_STR, allow either a
  11537. // case insensitive X500 key (CN=), case insensitive "OID." prefixed
  11538. // object identifier (OID.1.2.3.4.5.6=) or an object identifier (1.2.3.4=).
  11539. //
  11540. // If no flags are OR'ed into dwStrType, then, allow "," or ";" as RDN
  11541. // separators and "+" as the multiple RDN value separator. Quoting is
  11542. // supported. A quote may be included in a quoted value by double quoting,
  11543. // for example (CN="Joe ""Cool"""). A value starting with a "#" is treated
  11544. // as ascii hex and converted to a CERT_RDN_OCTET_STRING. Embedded whitespace
  11545. // is skipped (1.2.3 = # AB CD 01 is the same as 1.2.3=#ABCD01).
  11546. //
  11547. // Whitespace surrounding the keys, object identifers and values is removed.
  11548. //
  11549. // CERT_NAME_STR_COMMA_FLAG can be or'ed into dwStrType to only allow the
  11550. // "," as the RDN separator.
  11551. //
  11552. // CERT_NAME_STR_SEMICOLON_FLAG can be or'ed into dwStrType to only allow the
  11553. // ";" as the RDN separator.
  11554. //
  11555. // CERT_NAME_STR_CRLF_FLAG can be or'ed into dwStrType to only allow
  11556. // "\r" or "\n" as the RDN separator.
  11557. //
  11558. // CERT_NAME_STR_NO_PLUS_FLAG can be or'ed into dwStrType to ignore "+"
  11559. // as a separator and not allow multiple values per RDN.
  11560. //
  11561. // CERT_NAME_STR_NO_QUOTING_FLAG can be or'ed into dwStrType to inhibit
  11562. // quoting.
  11563. //
  11564. // CERT_NAME_STR_REVERSE_FLAG can be or'ed into dwStrType to reverse the
  11565. // order of the RDNs after converting from the string and before encoding.
  11566. //
  11567. // CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG can be or'ed into dwStrType to
  11568. // to select the CERT_RDN_T61_STRING encoded value type instead of
  11569. // CERT_RDN_UNICODE_STRING if all the UNICODE characters are <= 0xFF.
  11570. //
  11571. // CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG can be or'ed into dwStrType to
  11572. // to select the CERT_RDN_UTF8_STRING encoded value type instead of
  11573. // CERT_RDN_UNICODE_STRING.
  11574. //
  11575. // Support the following X500 Keys:
  11576. //
  11577. // Key Object Identifier RDN Value Type(s)
  11578. // --- ----------------- -----------------
  11579. // CN szOID_COMMON_NAME Printable, Unicode
  11580. // L szOID_LOCALITY_NAME Printable, Unicode
  11581. // O szOID_ORGANIZATION_NAME Printable, Unicode
  11582. // OU szOID_ORGANIZATIONAL_UNIT_NAME Printable, Unicode
  11583. // E szOID_RSA_emailAddr Only IA5
  11584. // Email szOID_RSA_emailAddr Only IA5
  11585. // C szOID_COUNTRY_NAME Only Printable
  11586. // S szOID_STATE_OR_PROVINCE_NAME Printable, Unicode
  11587. // ST szOID_STATE_OR_PROVINCE_NAME Printable, Unicode
  11588. // STREET szOID_STREET_ADDRESS Printable, Unicode
  11589. // T szOID_TITLE Printable, Unicode
  11590. // Title szOID_TITLE Printable, Unicode
  11591. // G szOID_GIVEN_NAME Printable, Unicode
  11592. // GivenName szOID_GIVEN_NAME Printable, Unicode
  11593. // I szOID_INITIALS Printable, Unicode
  11594. // Initials szOID_INITIALS Printable, Unicode
  11595. // SN szOID_SUR_NAME Printable, Unicode
  11596. // DC szOID_DOMAIN_COMPONENT IA5, UTF8
  11597. //
  11598. // Note, T61 is selected instead of Unicode if
  11599. // CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG is set and all the unicode
  11600. // characters are <= 0xFF.
  11601. //
  11602. // Note, UTF8 is selected instead of Unicode if
  11603. // CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG is set.
  11604. //
  11605. // Returns TRUE if successfully parsed the input string and encoded
  11606. // the name.
  11607. //
  11608. // If the input string is detected to be invalid, *ppszError is updated
  11609. // to point to the beginning of the invalid character sequence. Otherwise,
  11610. // *ppszError is set to NULL. *ppszError is updated with a non-NULL pointer
  11611. // for the following errors:
  11612. // CRYPT_E_INVALID_X500_STRING
  11613. // CRYPT_E_INVALID_NUMERIC_STRING
  11614. // CRYPT_E_INVALID_PRINTABLE_STRING
  11615. // CRYPT_E_INVALID_IA5_STRING
  11616. //
  11617. // ppszError can be set to NULL if not interested in getting a pointer
  11618. // to the invalid character sequence.
  11619. //--------------------------------------------------------------------------
  11620. //+-------------------------------------------------------------------------
  11621. //--------------------------------------------------------------------------
  11622. function CertStrToNameA(dwCertEncodingType: DWORD; pszX500: LPCSTR;
  11623. dwStrType: DWORD; pvReserved: Pointer; pbEncoded: LPBYTE; var pcbEncoded: DWORD;
  11624. ppszError: LPLPCSTR): BOOL; stdcall;
  11625. {$EXTERNALSYM CertStrToNameA}
  11626. function CertStrToNameW(dwCertEncodingType: DWORD; pszX500: LPCWSTR;
  11627. dwStrType: DWORD; pvReserved: Pointer; pbEncoded: LPBYTE; var pcbEncoded: DWORD;
  11628. ppszError: LPLPCWSTR): BOOL; stdcall;
  11629. {$EXTERNALSYM CertStrToNameW}
  11630. function CertStrToName(dwCertEncodingType: DWORD; pszX500: LPCTSTR;
  11631. dwStrType: DWORD; pvReserved: Pointer; pbEncoded: LPBYTE; var pcbEncoded: DWORD;
  11632. ppszError: LPLPCTSTR): BOOL; stdcall;
  11633. {$EXTERNALSYM CertStrToName}
  11634. //+-------------------------------------------------------------------------
  11635. // Get the subject or issuer name from the certificate and
  11636. // according to the specified format type, convert to a null terminated
  11637. // character string.
  11638. //
  11639. // CERT_NAME_ISSUER_FLAG can be set to get the issuer's name. Otherwise,
  11640. // gets the subject's name.
  11641. //
  11642. // By default, CERT_RDN_T61_STRING encoded values are initially decoded
  11643. // as UTF8. If the UTF8 decoding fails, then, decoded as 8 bit characters.
  11644. // CERT_NAME_DISABLE_IE4_UTF8_FLAG can be set in dwFlags to
  11645. // skip the initial attempt to decode as UTF8.
  11646. //
  11647. // The name string is formatted according to the dwType:
  11648. // CERT_NAME_EMAIL_TYPE
  11649. // If the certificate has a Subject Alternative Name extension (for
  11650. // issuer, Issuer Alternative Name), searches for first rfc822Name choice.
  11651. // If the rfc822Name choice isn't found in the extension, searches the
  11652. // Subject Name field for the Email OID, "1.2.840.113549.1.9.1".
  11653. // If the rfc822Name or Email OID is found, returns the string. Otherwise,
  11654. // returns an empty string (returned character count is 1).
  11655. // CERT_NAME_RDN_TYPE
  11656. // Converts the Subject Name blob by calling CertNameToStr. pvTypePara
  11657. // points to a DWORD containing the dwStrType passed to CertNameToStr.
  11658. // If the Subject Name field is empty and the certificate has a
  11659. // Subject Alternative Name extension, searches for and converts
  11660. // the first directoryName choice.
  11661. // CERT_NAME_ATTR_TYPE
  11662. // pvTypePara points to the Object Identifier specifying the name attribute
  11663. // to be returned. For example, to get the CN,
  11664. // pvTypePara = szOID_COMMON_NAME ("2.5.4.3"). Searches, the Subject Name
  11665. // field for the attribute.
  11666. // If the Subject Name field is empty and the certificate has a
  11667. // Subject Alternative Name extension, checks for
  11668. // the first directoryName choice and searches it.
  11669. //
  11670. // Note, searches the RDNs in reverse order.
  11671. //
  11672. // CERT_NAME_SIMPLE_DISPLAY_TYPE
  11673. // Iterates through the following list of name attributes and searches
  11674. // the Subject Name and then the Subject Alternative Name extension
  11675. // for the first occurrence of:
  11676. // szOID_COMMON_NAME ("2.5.4.3")
  11677. // szOID_ORGANIZATIONAL_UNIT_NAME ("2.5.4.11")
  11678. // szOID_ORGANIZATION_NAME ("2.5.4.10")
  11679. // szOID_RSA_emailAddr ("1.2.840.113549.1.9.1")
  11680. //
  11681. // If none of the above attributes is found, then, searches the
  11682. // Subject Alternative Name extension for a rfc822Name choice.
  11683. //
  11684. // If still no match, then, returns the first attribute.
  11685. //
  11686. // Note, like CERT_NAME_ATTR_TYPE, searches the RDNs in reverse order.
  11687. //
  11688. // CERT_NAME_FRIENDLY_DISPLAY_TYPE
  11689. // First checks if the certificate has a CERT_FRIENDLY_NAME_PROP_ID
  11690. // property. If it does, then, this property is returned. Otherwise,
  11691. // returns the above CERT_NAME_SIMPLE_DISPLAY_TYPE.
  11692. //
  11693. // Returns the number of characters converted including the terminating null
  11694. // character. If pwszNameString is NULL or cchNameString is 0, returns the
  11695. // required size of the destination string (including the terminating null
  11696. // char). If the specified name type isn't found. returns an empty string
  11697. // with a returned character count of 1.
  11698. //
  11699. // If pwszNameString != NULL && cwszNameString != 0, returned pwszNameString
  11700. // is always NULL terminated.
  11701. //
  11702. // Note: cchNameString includes the NULL char.
  11703. //--------------------------------------------------------------------------
  11704. //+-------------------------------------------------------------------------
  11705. //--------------------------------------------------------------------------
  11706. function CertGetNameStringA(pCertContext: PCCERT_CONTEXT; dwType, dwFlags: DWORD;
  11707. pvTypePara: Pointer; pszNameString: LPSTR; cchNameString: DWORD): DWORD; stdcall;
  11708. {$EXTERNALSYM CertGetNameStringA}
  11709. function CertGetNameStringW(pCertContext: PCCERT_CONTEXT; dwType, dwFlags: DWORD;
  11710. pvTypePara: Pointer; pszNameString: LPWSTR; cchNameString: DWORD): DWORD; stdcall;
  11711. {$EXTERNALSYM CertGetNameStringW}
  11712. function CertGetNameString(pCertContext: PCCERT_CONTEXT; dwType, dwFlags: DWORD;
  11713. pvTypePara: Pointer; pszNameString: LPTSTR; cchNameString: DWORD): DWORD; stdcall;
  11714. {$EXTERNALSYM CertGetNameString}
  11715. //+-------------------------------------------------------------------------
  11716. // Certificate name types
  11717. //--------------------------------------------------------------------------
  11718. const
  11719. CERT_NAME_EMAIL_TYPE = 1;
  11720. {$EXTERNALSYM CERT_NAME_EMAIL_TYPE}
  11721. CERT_NAME_RDN_TYPE = 2;
  11722. {$EXTERNALSYM CERT_NAME_RDN_TYPE}
  11723. CERT_NAME_ATTR_TYPE = 3;
  11724. {$EXTERNALSYM CERT_NAME_ATTR_TYPE}
  11725. CERT_NAME_SIMPLE_DISPLAY_TYPE = 4;
  11726. {$EXTERNALSYM CERT_NAME_SIMPLE_DISPLAY_TYPE}
  11727. CERT_NAME_FRIENDLY_DISPLAY_TYPE = 5;
  11728. {$EXTERNALSYM CERT_NAME_FRIENDLY_DISPLAY_TYPE}
  11729. //+-------------------------------------------------------------------------
  11730. // Certificate name flags
  11731. //--------------------------------------------------------------------------
  11732. CERT_NAME_ISSUER_FLAG = $1;
  11733. {$EXTERNALSYM CERT_NAME_ISSUER_FLAG}
  11734. CERT_NAME_DISABLE_IE4_UTF8_FLAG = $00010000;
  11735. {$EXTERNALSYM CERT_NAME_DISABLE_IE4_UTF8_FLAG}
  11736. //+=========================================================================
  11737. // Simplified Cryptographic Message Data Structures and APIs
  11738. //==========================================================================
  11739. //+-------------------------------------------------------------------------
  11740. // Conventions for the *pb and *pcb output parameters:
  11741. //
  11742. // Upon entry to the function:
  11743. // if pcb is OPTIONAL && pcb == NULL, then,
  11744. // No output is returned
  11745. // else if pb == NULL && pcb != NULL, then,
  11746. // Length only determination. No length error is
  11747. // returned.
  11748. // otherwise where (pb != NULL && pcb != NULL && *pcb != 0)
  11749. // Output is returned. If *pcb isn't big enough a
  11750. // length error is returned. In all cases *pcb is updated
  11751. // with the actual length needed/returned.
  11752. //--------------------------------------------------------------------------
  11753. //+-------------------------------------------------------------------------
  11754. // Type definitions of the parameters used for doing the cryptographic
  11755. // operations.
  11756. //--------------------------------------------------------------------------
  11757. //+-------------------------------------------------------------------------
  11758. // Callback to get and verify the signer's certificate.
  11759. //
  11760. // Passed the CertId of the signer (its Issuer and SerialNumber) and a
  11761. // handle to its cryptographic signed message's cert store.
  11762. //
  11763. // For CRYPT_E_NO_SIGNER, called with pSignerId == NULL.
  11764. //
  11765. // For a valid signer certificate, returns a pointer to a read only
  11766. // CERT_CONTEXT. The returned CERT_CONTEXT is either obtained from a
  11767. // cert store or was created via CertCreateCertificateContext. For either case,
  11768. // its freed via CertFreeCertificateContext.
  11769. //
  11770. // If a valid certificate isn't found, this callback returns NULL with
  11771. // LastError set via SetLastError().
  11772. //
  11773. // The NULL implementation tries to get the Signer certificate from the
  11774. // message cert store. It doesn't verify the certificate.
  11775. //
  11776. // Note, if the KEYID choice was selected for a CMS SignerId, then, the
  11777. // SerialNumber is 0 and the Issuer is encoded containing a single RDN with a
  11778. // single Attribute whose OID is szOID_KEYID_RDN, value type is
  11779. // CERT_RDN_OCTET_STRING and value is the KEYID. When the
  11780. // CertGetSubjectCertificateFromStore and
  11781. // CertFindCertificateInStore(CERT_FIND_SUBJECT_CERT) APIs see this
  11782. // special KEYID Issuer and SerialNumber, they do a KEYID match.
  11783. //--------------------------------------------------------------------------
  11784. type
  11785. PFN_CRYPT_GET_SIGNER_CERTIFICATE = function(pvGetArg: Pointer;
  11786. dwCertEncodingType: DWORD; pSignerId: PCERT_INFO;
  11787. hMsgCertStore: HCERTSTORE): PCCERT_CONTEXT; stdcall;
  11788. {$EXTERNALSYM PFN_CRYPT_GET_SIGNER_CERTIFICATE}
  11789. PfnCryptGetSignerCertificate = PFN_CRYPT_GET_SIGNER_CERTIFICATE;
  11790. //+-------------------------------------------------------------------------
  11791. // The CRYPT_SIGN_MESSAGE_PARA are used for signing messages using the
  11792. // specified signing certificate context.
  11793. //
  11794. // Either the CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_PROV_INFO_PROP_ID must
  11795. // be set for each rgpSigningCert[]. Either one specifies the private
  11796. // signature key to use.
  11797. //
  11798. // If any certificates and/or CRLs are to be included in the signed message,
  11799. // then, the MsgCert and MsgCrl parameters need to be updated. If the
  11800. // rgpSigningCerts are to be included, then, they must also be in the
  11801. // rgpMsgCert array.
  11802. //
  11803. // cbSize must be set to the sizeof(CRYPT_SIGN_MESSAGE_PARA) or else
  11804. // LastError will be updated with E_INVALIDARG.
  11805. //
  11806. // pvHashAuxInfo currently isn't used and must be set to NULL.
  11807. //
  11808. // dwFlags normally is set to 0. However, if the encoded output
  11809. // is to be a CMSG_SIGNED inner content of an outer cryptographic message,
  11810. // such as a CMSG_ENVELOPED, then, the CRYPT_MESSAGE_BARE_CONTENT_OUT_FLAG
  11811. // should be set. If not set, then it would be encoded as an inner content
  11812. // type of CMSG_DATA.
  11813. //
  11814. // dwInnerContentType is normally set to 0. It needs to be set if the
  11815. // ToBeSigned input is the encoded output of another cryptographic
  11816. // message, such as, an CMSG_ENVELOPED. When set, it's one of the cryptographic
  11817. // message types, for example, CMSG_ENVELOPED.
  11818. //
  11819. // If the inner content of a nested cryptographic message is data (CMSG_DATA
  11820. // the default), then, neither dwFlags or dwInnerContentType need to be set.
  11821. //
  11822. // For CMS messages, CRYPT_MESSAGE_ENCAPSULATED_CONTENT_OUT_FLAG may be
  11823. // set to encapsulate nonData inner content within an OCTET STRING.
  11824. //
  11825. // For CMS messages, CRYPT_MESSAGE_KEYID_SIGNER_FLAG may be set to identify
  11826. // signers by their Key Identifier and not their Issuer and Serial Number.
  11827. //
  11828. // If HashEncryptionAlgorithm is present and not NULL its used instead of
  11829. // the SigningCert's PublicKeyInfo.Algorithm.
  11830. //
  11831. // Note, for RSA, the hash encryption algorithm is normally the same as
  11832. // the public key algorithm. For DSA, the hash encryption algorithm is
  11833. // normally a DSS signature algorithm.
  11834. //
  11835. // pvHashEncryptionAuxInfo currently isn't used and must be set to NULL if
  11836. // present in the data structure.
  11837. //--------------------------------------------------------------------------
  11838. type
  11839. PCRYPT_SIGN_MESSAGE_PARA = ^CRYPT_SIGN_MESSAGE_PARA;
  11840. {$EXTERNALSYM PCRYPT_SIGN_MESSAGE_PARA}
  11841. _CRYPT_SIGN_MESSAGE_PARA = record
  11842. cbSize: DWORD;
  11843. dwMsgEncodingType: DWORD;
  11844. pSigningCert: PCCERT_CONTEXT;
  11845. HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  11846. pvHashAuxInfo: Pointer;
  11847. cMsgCert: DWORD;
  11848. rgpMsgCert: PPCCERT_CONTEXT;
  11849. cMsgCrl: DWORD;
  11850. rgpMsgCrl: PPCCRL_CONTEXT;
  11851. cAuthAttr: DWORD;
  11852. rgAuthAttr: PCRYPT_ATTRIBUTE;
  11853. cUnauthAttr: DWORD;
  11854. rgUnauthAttr: PCRYPT_ATTRIBUTE;
  11855. dwFlags: DWORD;
  11856. dwInnerContentType: DWORD;
  11857. {$IFDEF CRYPT_SIGN_MESSAGE_PARA_HAS_CMS_FIELDS}
  11858. HashEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  11859. pvHashEncryptionAuxInfo: Pointer;
  11860. {$ENDIF CRYPT_SIGN_MESSAGE_PARA_HAS_CMS_FIELDS}
  11861. end;
  11862. {$EXTERNALSYM _CRYPT_SIGN_MESSAGE_PARA}
  11863. CRYPT_SIGN_MESSAGE_PARA = _CRYPT_SIGN_MESSAGE_PARA;
  11864. {$EXTERNALSYM CRYPT_SIGN_MESSAGE_PARA}
  11865. TCryptSignMessagePara = CRYPT_SIGN_MESSAGE_PARA;
  11866. PCryptSignMessagePara = PCRYPT_SIGN_MESSAGE_PARA;
  11867. const
  11868. CRYPT_MESSAGE_BARE_CONTENT_OUT_FLAG = $1;
  11869. {$EXTERNALSYM CRYPT_MESSAGE_BARE_CONTENT_OUT_FLAG}
  11870. // When set, nonData type inner content is encapsulated within an
  11871. // OCTET STRING
  11872. CRYPT_MESSAGE_ENCAPSULATED_CONTENT_OUT_FLAG = $2;
  11873. {$EXTERNALSYM CRYPT_MESSAGE_ENCAPSULATED_CONTENT_OUT_FLAG}
  11874. // When set, signers are identified by their Key Identifier and not
  11875. // their Issuer and Serial Number.
  11876. CRYPT_MESSAGE_KEYID_SIGNER_FLAG = $4;
  11877. {$EXTERNALSYM CRYPT_MESSAGE_KEYID_SIGNER_FLAG}
  11878. //+-------------------------------------------------------------------------
  11879. // The CRYPT_VERIFY_MESSAGE_PARA are used to verify signed messages.
  11880. //
  11881. // hCryptProv is used to do hashing and signature verification.
  11882. //
  11883. // The dwCertEncodingType specifies the encoding type of the certificates
  11884. // and/or CRLs in the message.
  11885. //
  11886. // pfnGetSignerCertificate is called to get and verify the message signer's
  11887. // certificate.
  11888. //
  11889. // cbSize must be set to the sizeof(CRYPT_VERIFY_MESSAGE_PARA) or else
  11890. // LastError will be updated with E_INVALIDARG.
  11891. //--------------------------------------------------------------------------
  11892. type
  11893. PCRYPT_VERIFY_MESSAGE_PARA = ^CRYPT_VERIFY_MESSAGE_PARA;
  11894. {$EXTERNALSYM PCRYPT_VERIFY_MESSAGE_PARA}
  11895. _CRYPT_VERIFY_MESSAGE_PARA = record
  11896. cbSize: DWORD;
  11897. dwMsgAndCertEncodingType: DWORD;
  11898. hCryptProv: HCRYPTPROV;
  11899. pfnGetSignerCertificate: PFN_CRYPT_GET_SIGNER_CERTIFICATE;
  11900. pvGetArg: Pointer;
  11901. end;
  11902. {$EXTERNALSYM _CRYPT_VERIFY_MESSAGE_PARA}
  11903. CRYPT_VERIFY_MESSAGE_PARA = _CRYPT_VERIFY_MESSAGE_PARA;
  11904. {$EXTERNALSYM CRYPT_VERIFY_MESSAGE_PARA}
  11905. TCryptVerifyMessagePara = CRYPT_VERIFY_MESSAGE_PARA;
  11906. PCryptVerifyMessagePara = PCRYPT_VERIFY_MESSAGE_PARA;
  11907. //+-------------------------------------------------------------------------
  11908. // The CRYPT_ENCRYPT_MESSAGE_PARA are used for encrypting messages.
  11909. //
  11910. // hCryptProv is used to do content encryption, recipient key
  11911. // encryption, and recipient key export. Its private key
  11912. // isn't used.
  11913. //
  11914. // Currently, pvEncryptionAuxInfo is only defined for RC2 or RC4 encryption
  11915. // algorithms. Otherwise, its not used and must be set to NULL.
  11916. // See CMSG_RC2_AUX_INFO for the RC2 encryption algorithms.
  11917. // See CMSG_RC4_AUX_INFO for the RC4 encryption algorithms.
  11918. //
  11919. // To enable SP3 compatible encryption, pvEncryptionAuxInfo should point to
  11920. // a CMSG_SP3_COMPATIBLE_AUX_INFO data structure.
  11921. //
  11922. // cbSize must be set to the sizeof(CRYPT_ENCRYPT_MESSAGE_PARA) or else
  11923. // LastError will be updated with E_INVALIDARG.
  11924. //
  11925. // dwFlags normally is set to 0. However, if the encoded output
  11926. // is to be a CMSG_ENVELOPED inner content of an outer cryptographic message,
  11927. // such as a CMSG_SIGNED, then, the CRYPT_MESSAGE_BARE_CONTENT_OUT_FLAG
  11928. // should be set. If not set, then it would be encoded as an inner content
  11929. // type of CMSG_DATA.
  11930. //
  11931. // dwInnerContentType is normally set to 0. It needs to be set if the
  11932. // ToBeEncrypted input is the encoded output of another cryptographic
  11933. // message, such as, an CMSG_SIGNED. When set, it's one of the cryptographic
  11934. // message types, for example, CMSG_SIGNED.
  11935. //
  11936. // If the inner content of a nested cryptographic message is data (CMSG_DATA
  11937. // the default), then, neither dwFlags or dwInnerContentType need to be set.
  11938. //
  11939. // For CMS messages, CRYPT_MESSAGE_ENCAPSULATED_CONTENT_OUT_FLAG may be
  11940. // set to encapsulate nonData inner content within an OCTET STRING before
  11941. // encrypting.
  11942. //
  11943. // For CMS messages, CRYPT_MESSAGE_KEYID_RECIPIENT_FLAG may be set to identify
  11944. // recipients by their Key Identifier and not their Issuer and Serial Number.
  11945. //--------------------------------------------------------------------------
  11946. type
  11947. PCRYPT_ENCRYPT_MESSAGE_PARA = ^CRYPT_ENCRYPT_MESSAGE_PARA;
  11948. {$EXTERNALSYM PCRYPT_ENCRYPT_MESSAGE_PARA}
  11949. _CRYPT_ENCRYPT_MESSAGE_PARA = record
  11950. cbSize: DWORD;
  11951. dwMsgEncodingType: DWORD;
  11952. hCryptProv: HCRYPTPROV;
  11953. ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  11954. pvEncryptionAuxInfo: Pointer;
  11955. dwFlags: DWORD;
  11956. dwInnerContentType: DWORD;
  11957. end;
  11958. {$EXTERNALSYM _CRYPT_ENCRYPT_MESSAGE_PARA}
  11959. CRYPT_ENCRYPT_MESSAGE_PARA = _CRYPT_ENCRYPT_MESSAGE_PARA;
  11960. {$EXTERNALSYM CRYPT_ENCRYPT_MESSAGE_PARA}
  11961. TCryptEncryptMessagePara = CRYPT_ENCRYPT_MESSAGE_PARA;
  11962. PCryptEncryptMessagePara = PCRYPT_ENCRYPT_MESSAGE_PARA;
  11963. // When set, recipients are identified by their Key Identifier and not
  11964. // their Issuer and Serial Number.
  11965. const
  11966. CRYPT_MESSAGE_KEYID_RECIPIENT_FLAG = $4;
  11967. {$EXTERNALSYM CRYPT_MESSAGE_KEYID_RECIPIENT_FLAG}
  11968. //+-------------------------------------------------------------------------
  11969. // The CRYPT_DECRYPT_MESSAGE_PARA are used for decrypting messages.
  11970. //
  11971. // The CertContext to use for decrypting a message is obtained from one
  11972. // of the specified cert stores. An encrypted message can have one or
  11973. // more recipients. The recipients are identified by their CertId (Issuer
  11974. // and SerialNumber). The cert stores are searched to find the CertContext
  11975. // corresponding to the CertId.
  11976. //
  11977. // For CMS, the recipients may also be identified by their KeyId.
  11978. // CMS also allows Key Agreement (Diffie Hellman) in addition to
  11979. // Key Transport (RSA) recipients.
  11980. //
  11981. // Only CertContexts in the store with either
  11982. // the CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_PROV_INFO_PROP_ID set
  11983. // can be used. Either property specifies the private exchange key to use.
  11984. //
  11985. // cbSize must be set to the sizeof(CRYPT_DECRYPT_MESSAGE_PARA) or else
  11986. // LastError will be updated with E_INVALIDARG.
  11987. //--------------------------------------------------------------------------
  11988. type
  11989. PCRYPT_DECRYPT_MESSAGE_PARA = ^CRYPT_DECRYPT_MESSAGE_PARA;
  11990. {$EXTERNALSYM PCRYPT_DECRYPT_MESSAGE_PARA}
  11991. _CRYPT_DECRYPT_MESSAGE_PARA = record
  11992. cbSize: DWORD;
  11993. dwMsgAndCertEncodingType: DWORD;
  11994. cCertStore: DWORD;
  11995. rghCertStore: PHCERTSTORE;
  11996. end;
  11997. {$EXTERNALSYM _CRYPT_DECRYPT_MESSAGE_PARA}
  11998. CRYPT_DECRYPT_MESSAGE_PARA = _CRYPT_DECRYPT_MESSAGE_PARA;
  11999. {$EXTERNALSYM CRYPT_DECRYPT_MESSAGE_PARA}
  12000. TCryptDecryptMessagePara = CRYPT_DECRYPT_MESSAGE_PARA;
  12001. PCryptDecryptMessagePara = PCRYPT_DECRYPT_MESSAGE_PARA;
  12002. //+-------------------------------------------------------------------------
  12003. // The CRYPT_HASH_MESSAGE_PARA are used for hashing or unhashing
  12004. // messages.
  12005. //
  12006. // hCryptProv is used to compute the hash.
  12007. //
  12008. // pvHashAuxInfo currently isn't used and must be set to NULL.
  12009. //
  12010. // cbSize must be set to the sizeof(CRYPT_HASH_MESSAGE_PARA) or else
  12011. // LastError will be updated with E_INVALIDARG.
  12012. //--------------------------------------------------------------------------
  12013. PCRYPT_HASH_MESSAGE_PARA = ^CRYPT_HASH_MESSAGE_PARA;
  12014. {$EXTERNALSYM PCRYPT_HASH_MESSAGE_PARA}
  12015. _CRYPT_HASH_MESSAGE_PARA = record
  12016. cbSize: DWORD;
  12017. dwMsgEncodingType: DWORD;
  12018. hCryptProv: HCRYPTPROV;
  12019. HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  12020. pvHashAuxInfo: Pointer;
  12021. end;
  12022. {$EXTERNALSYM _CRYPT_HASH_MESSAGE_PARA}
  12023. CRYPT_HASH_MESSAGE_PARA = _CRYPT_HASH_MESSAGE_PARA;
  12024. {$EXTERNALSYM CRYPT_HASH_MESSAGE_PARA}
  12025. TCryptHashMessagePara = CRYPT_HASH_MESSAGE_PARA;
  12026. PCryptHashMessagePara = PCRYPT_HASH_MESSAGE_PARA;
  12027. //+-------------------------------------------------------------------------
  12028. // The CRYPT_KEY_SIGN_MESSAGE_PARA are used for signing messages until a
  12029. // certificate has been created for the signature key.
  12030. //
  12031. // pvHashAuxInfo currently isn't used and must be set to NULL.
  12032. //
  12033. // If PubKeyAlgorithm isn't set, defaults to szOID_RSA_RSA.
  12034. //
  12035. // cbSize must be set to the sizeof(CRYPT_KEY_SIGN_MESSAGE_PARA) or else
  12036. // LastError will be updated with E_INVALIDARG.
  12037. //--------------------------------------------------------------------------
  12038. PCRYPT_KEY_SIGN_MESSAGE_PARA = ^CRYPT_KEY_SIGN_MESSAGE_PARA;
  12039. {$EXTERNALSYM PCRYPT_KEY_SIGN_MESSAGE_PARA}
  12040. _CRYPT_KEY_SIGN_MESSAGE_PARA = record
  12041. cbSize: DWORD;
  12042. dwMsgAndCertEncodingType: DWORD;
  12043. hCryptProv: HCRYPTPROV;
  12044. dwKeySpec: DWORD;
  12045. HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  12046. pvHashAuxInfo: Pointer;
  12047. PubKeyAlgorithm: CRYPT_ALGORITHM_IDENTIFIER;
  12048. end;
  12049. {$EXTERNALSYM _CRYPT_KEY_SIGN_MESSAGE_PARA}
  12050. CRYPT_KEY_SIGN_MESSAGE_PARA = _CRYPT_KEY_SIGN_MESSAGE_PARA;
  12051. {$EXTERNALSYM CRYPT_KEY_SIGN_MESSAGE_PARA}
  12052. TCryptKeySignMessagePara = CRYPT_KEY_SIGN_MESSAGE_PARA;
  12053. PCryptKeySignMessagePara = PCRYPT_KEY_SIGN_MESSAGE_PARA;
  12054. //+-------------------------------------------------------------------------
  12055. // The CRYPT_KEY_VERIFY_MESSAGE_PARA are used to verify signed messages without
  12056. // a certificate for the signer.
  12057. //
  12058. // Normally used until a certificate has been created for the key.
  12059. //
  12060. // hCryptProv is used to do hashing and signature verification.
  12061. //
  12062. // cbSize must be set to the sizeof(CRYPT_KEY_VERIFY_MESSAGE_PARA) or else
  12063. // LastError will be updated with E_INVALIDARG.
  12064. //--------------------------------------------------------------------------
  12065. PCRYPT_KEY_VERIFY_MESSAGE_PARA = ^CRYPT_KEY_VERIFY_MESSAGE_PARA;
  12066. {$EXTERNALSYM PCRYPT_KEY_VERIFY_MESSAGE_PARA}
  12067. _CRYPT_KEY_VERIFY_MESSAGE_PARA = record
  12068. cbSize: DWORD;
  12069. dwMsgEncodingType: DWORD;
  12070. hCryptProv: HCRYPTPROV;
  12071. end;
  12072. {$EXTERNALSYM _CRYPT_KEY_VERIFY_MESSAGE_PARA}
  12073. CRYPT_KEY_VERIFY_MESSAGE_PARA = _CRYPT_KEY_VERIFY_MESSAGE_PARA;
  12074. {$EXTERNALSYM CRYPT_KEY_VERIFY_MESSAGE_PARA}
  12075. TCryptKeyVerifyMessagePara = CRYPT_KEY_VERIFY_MESSAGE_PARA;
  12076. PCryptKeyVerifyMessagePara = PCRYPT_KEY_VERIFY_MESSAGE_PARA;
  12077. //+-------------------------------------------------------------------------
  12078. // Sign the message.
  12079. //
  12080. // If fDetachedSignature is TRUE, the "to be signed" content isn't included
  12081. // in the encoded signed blob.
  12082. //--------------------------------------------------------------------------
  12083. function CryptSignMessage(pSignPara: PCRYPT_SIGN_MESSAGE_PARA;
  12084. fDetachedSignature: BOOL; cToBeSigned: DWORD; rgpbToBeSigned: LPBYTE;
  12085. rgcbToBeSigned: LPDWORD; pbSignedBlob: LPBYTE; var pcbSignedBlob: DWORD): BOOL; stdcall;
  12086. {$EXTERNALSYM CryptSignMessage}
  12087. //+-------------------------------------------------------------------------
  12088. // Verify a signed message.
  12089. //
  12090. // If pbDecoded == NULL, then, *pcbDecoded is implicitly set to 0 on input.
  12091. // For *pcbDecoded == 0 && ppSignerCert == NULL on input, the signer isn't
  12092. // verified.
  12093. //
  12094. // A message might have more than one signer. Set dwSignerIndex to iterate
  12095. // through all the signers. dwSignerIndex == 0 selects the first signer.
  12096. //
  12097. // pVerifyPara's pfnGetSignerCertificate is called to get the signer's
  12098. // certificate.
  12099. //
  12100. // For a verified signer and message, *ppSignerCert is updated
  12101. // with the CertContext of the signer. It must be freed by calling
  12102. // CertFreeCertificateContext. Otherwise, *ppSignerCert is set to NULL.
  12103. //
  12104. // ppSignerCert can be NULL, indicating the caller isn't interested
  12105. // in getting the CertContext of the signer.
  12106. //
  12107. // pcbDecoded can be NULL, indicating the caller isn't interested in getting
  12108. // the decoded content. Furthermore, if the message doesn't contain any
  12109. // content or signers, then, pcbDecoded must be set to NULL, to allow the
  12110. // pVerifyPara->pfnGetCertificate to be called. Normally, this would be
  12111. // the case when the signed message contains only certficates and CRLs.
  12112. // If pcbDecoded is NULL and the message doesn't have the indicated signer,
  12113. // pfnGetCertificate is called with pSignerId set to NULL.
  12114. //
  12115. // If the message doesn't contain any signers || dwSignerIndex > message's
  12116. // SignerCount, then, an error is returned with LastError set to
  12117. // CRYPT_E_NO_SIGNER. Also, for CRYPT_E_NO_SIGNER, pfnGetSignerCertificate
  12118. // is still called with pSignerId set to NULL.
  12119. //
  12120. // Note, an alternative way to get the certificates and CRLs from a
  12121. // signed message is to call CryptGetMessageCertificates.
  12122. //--------------------------------------------------------------------------
  12123. function CryptVerifyMessageSignature(pVerifyPara: PCRYPT_VERIFY_MESSAGE_PARA;
  12124. dwSignerIndex: DWORD; pbSignedBlob: LPBYTE; cbSignedBlob: DWORD;
  12125. pbDecoded: LPBYTE; pcbDecoded: LPDWORD; ppSignerCert: PPCCERT_CONTEXT): BOOL; stdcall;
  12126. {$EXTERNALSYM CryptVerifyMessageSignature}
  12127. //+-------------------------------------------------------------------------
  12128. // Returns the count of signers in the signed message. For no signers, returns
  12129. // 0. For an error returns -1 with LastError updated accordingly.
  12130. //--------------------------------------------------------------------------
  12131. function CryptGetMessageSignerCount(dwMsgEncodingType: DWORD; pbSignedBlob: LPBYTE;
  12132. cbSignedBlob: DWORD): LONG; stdcall;
  12133. {$EXTERNALSYM CryptGetMessageSignerCount}
  12134. //+-------------------------------------------------------------------------
  12135. // Returns the cert store containing the message's certs and CRLs.
  12136. // For an error, returns NULL with LastError updated.
  12137. //--------------------------------------------------------------------------
  12138. function CryptGetMessageCertificates(dwMsgAndCertEncodingType: DWORD;
  12139. hCryptProv: HCRYPTPROV; dwFlags: DWORD; pbSignedBlob: LPBYTE;
  12140. cbSignedBlob: DWORD): HCERTSTORE; stdcall;
  12141. {$EXTERNALSYM CryptGetMessageCertificates}
  12142. //+-------------------------------------------------------------------------
  12143. // Verify a signed message containing detached signature(s).
  12144. // The "to be signed" content is passed in separately. No
  12145. // decoded output. Otherwise, identical to CryptVerifyMessageSignature.
  12146. //--------------------------------------------------------------------------
  12147. function CryptVerifyDetachedMessageSignature(pVerifyPara: PCRYPT_VERIFY_MESSAGE_PARA;
  12148. dwSignerIndex: DWORD; pbDetachedSignBlob: LPBYTE; cbDetachedSignBlob: DWORD;
  12149. cToBeSigned: DWORD; rgpbToBeSigned: LPBYTE; rgcbToBeSigned: LPDWORD;
  12150. ppSignerCert: PPCCERT_CONTEXT): BOOL; stdcall;
  12151. {$EXTERNALSYM CryptVerifyDetachedMessageSignature}
  12152. //+-------------------------------------------------------------------------
  12153. // Encrypts the message for the recipient(s).
  12154. //--------------------------------------------------------------------------
  12155. function CryptEncryptMessage(pEncryptPara: PCRYPT_ENCRYPT_MESSAGE_PARA;
  12156. cRecipientCert: DWORD; rgpRecipientCert: PCCERT_CONTEXT; pbToBeEncrypted: LPBYTE;
  12157. cbToBeEncrypted: DWORD; pbEncryptedBlob: LPBYTE; var pcbEncryptedBlob: DWORD): BOOL; stdcall;
  12158. {$EXTERNALSYM CryptEncryptMessage}
  12159. //+-------------------------------------------------------------------------
  12160. // Decrypts the message.
  12161. //
  12162. // If pbDecrypted == NULL, then, *pcbDecrypted is implicitly set to 0 on input.
  12163. // For *pcbDecrypted == 0 && ppXchgCert == NULL on input, the message isn't
  12164. // decrypted.
  12165. //
  12166. // For a successfully decrypted message, *ppXchgCert is updated
  12167. // with the CertContext used to decrypt. It must be freed by calling
  12168. // CertStoreFreeCert. Otherwise, *ppXchgCert is set to NULL.
  12169. //
  12170. // ppXchgCert can be NULL, indicating the caller isn't interested
  12171. // in getting the CertContext used to decrypt.
  12172. //--------------------------------------------------------------------------
  12173. function CryptDecryptMessage(pDecryptPara: PCRYPT_DECRYPT_MESSAGE_PARA;
  12174. pbEncryptedBlob: LPBYTE; cbEncryptedBlob: DWORD; pbDecrypted: LPBYTE;
  12175. pcbDecrypted: LPDWORD; ppXchgCert: PPCCERT_CONTEXT): BOOL; stdcall;
  12176. {$EXTERNALSYM CryptDecryptMessage}
  12177. //+-------------------------------------------------------------------------
  12178. // Sign the message and encrypt for the recipient(s). Does a CryptSignMessage
  12179. // followed with a CryptEncryptMessage.
  12180. //
  12181. // Note: this isn't the CMSG_SIGNED_AND_ENVELOPED. Its a CMSG_SIGNED
  12182. // inside of an CMSG_ENVELOPED.
  12183. //--------------------------------------------------------------------------
  12184. function CryptSignAndEncryptMessage(pSignPara: PCRYPT_SIGN_MESSAGE_PARA;
  12185. pEncryptPara: PCRYPT_ENCRYPT_MESSAGE_PARA; cRecipientCert: DWORD;
  12186. rgpRecipientCert: PCCERT_CONTEXT; pbToBeSignedAndEncrypted: LPBYTE;
  12187. cbToBeSignedAndEncrypted: DWORD; pbSignedAndEncryptedBlob: LPBYTE;
  12188. var pcbSignedAndEncryptedBlob: DWORD): BOOL; stdcall;
  12189. {$EXTERNALSYM CryptSignAndEncryptMessage}
  12190. //+-------------------------------------------------------------------------
  12191. // Decrypts the message and verifies the signer. Does a CryptDecryptMessage
  12192. // followed with a CryptVerifyMessageSignature.
  12193. //
  12194. // If pbDecrypted == NULL, then, *pcbDecrypted is implicitly set to 0 on input.
  12195. // For *pcbDecrypted == 0 && ppSignerCert == NULL on input, the signer isn't
  12196. // verified.
  12197. //
  12198. // A message might have more than one signer. Set dwSignerIndex to iterate
  12199. // through all the signers. dwSignerIndex == 0 selects the first signer.
  12200. //
  12201. // The pVerifyPara's VerifySignerPolicy is called to verify the signer's
  12202. // certificate.
  12203. //
  12204. // For a successfully decrypted and verified message, *ppXchgCert and
  12205. // *ppSignerCert are updated. They must be freed by calling
  12206. // CertStoreFreeCert. Otherwise, they are set to NULL.
  12207. //
  12208. // ppXchgCert and/or ppSignerCert can be NULL, indicating the
  12209. // caller isn't interested in getting the CertContext.
  12210. //
  12211. // Note: this isn't the CMSG_SIGNED_AND_ENVELOPED. Its a CMSG_SIGNED
  12212. // inside of an CMSG_ENVELOPED.
  12213. //
  12214. // The message always needs to be decrypted to allow access to the
  12215. // signed message. Therefore, if ppXchgCert != NULL, its always updated.
  12216. //--------------------------------------------------------------------------
  12217. function CryptDecryptAndVerifyMessageSignature(pDecryptPara: PCRYPT_DECRYPT_MESSAGE_PARA;
  12218. pVerifyPara: PCRYPT_VERIFY_MESSAGE_PARA; dwSignerIndex: DWORD; pbEncryptedBlob: LPBYTE;
  12219. cbEncryptedBlob: DWORD; pbDecrypted: LPBYTE; pcbDecrypted: LPDWORD;
  12220. ppXchgCert: PPCCERT_CONTEXT; ppSignerCert: PPCCERT_CONTEXT): BOOL; stdcall;
  12221. {$EXTERNALSYM CryptDecryptAndVerifyMessageSignature}
  12222. //+-------------------------------------------------------------------------
  12223. // Decodes a cryptographic message which may be one of the following types:
  12224. // CMSG_DATA
  12225. // CMSG_SIGNED
  12226. // CMSG_ENVELOPED
  12227. // CMSG_SIGNED_AND_ENVELOPED
  12228. // CMSG_HASHED
  12229. //
  12230. // dwMsgTypeFlags specifies the set of allowable messages. For example, to
  12231. // decode either SIGNED or ENVELOPED messages, set dwMsgTypeFlags to:
  12232. // CMSG_SIGNED_FLAG | CMSG_ENVELOPED_FLAG.
  12233. //
  12234. // dwProvInnerContentType is only applicable when processing nested
  12235. // crytographic messages. When processing an outer crytographic message
  12236. // it must be set to 0. When decoding a nested cryptographic message
  12237. // its the dwInnerContentType returned by a previous CryptDecodeMessage
  12238. // of the outer message. The InnerContentType can be any of the CMSG types,
  12239. // for example, CMSG_DATA, CMSG_SIGNED, ...
  12240. //
  12241. // The optional *pdwMsgType is updated with the type of message.
  12242. //
  12243. // The optional *pdwInnerContentType is updated with the type of the inner
  12244. // message. Unless there is cryptographic message nesting, CMSG_DATA
  12245. // is returned.
  12246. //
  12247. // For CMSG_DATA: returns decoded content.
  12248. // For CMSG_SIGNED: same as CryptVerifyMessageSignature.
  12249. // For CMSG_ENVELOPED: same as CryptDecryptMessage.
  12250. // For CMSG_SIGNED_AND_ENVELOPED: same as CryptDecryptMessage plus
  12251. // CryptVerifyMessageSignature.
  12252. // For CMSG_HASHED: verifies the hash and returns decoded content.
  12253. //--------------------------------------------------------------------------
  12254. function CryptDecodeMessage(dwMsgTypeFlags: DWORD; pDecryptPara: PCRYPT_DECRYPT_MESSAGE_PARA;
  12255. pVerifyPara: PCRYPT_VERIFY_MESSAGE_PARA; dwSignerIndex: DWORD; pbEncodedBlob: LPBYTE;
  12256. cbEncodedBlob: DWORD; dwPrevInnerContentType: DWORD; pdwMsgType: LPDWORD;
  12257. pdwInnerContentType: LPDWORD; pbDecoded: LPBYTE; pcbDecoded: LPDWORD;
  12258. ppXchgCert: PPCCERT_CONTEXT; ppSignerCert: PPCCERT_CONTEXT): BOOL; stdcall;
  12259. {$EXTERNALSYM CryptDecodeMessage}
  12260. //+-------------------------------------------------------------------------
  12261. // Hash the message.
  12262. //
  12263. // If fDetachedHash is TRUE, only the ComputedHash is encoded in the
  12264. // pbHashedBlob. Otherwise, both the ToBeHashed and ComputedHash
  12265. // are encoded.
  12266. //
  12267. // pcbHashedBlob or pcbComputedHash can be NULL, indicating the caller
  12268. // isn't interested in getting the output.
  12269. //--------------------------------------------------------------------------
  12270. function CryptHashMessage(pHashPara: PCRYPT_HASH_MESSAGE_PARA; fDetachedHash: BOOL;
  12271. cToBeHashed: DWORD; rgpbToBeHashed: LPBYTE; rgcbToBeHashed: LPDWORD;
  12272. pbHashedBlob: LPBYTE; pcbHashedBlob: LPDWORD; pbComputedHash: LPBYTE;
  12273. pcbComputedHash: LPDWORD): BOOL; stdcall;
  12274. {$EXTERNALSYM CryptHashMessage}
  12275. //+-------------------------------------------------------------------------
  12276. // Verify a hashed message.
  12277. //
  12278. // pcbToBeHashed or pcbComputedHash can be NULL,
  12279. // indicating the caller isn't interested in getting the output.
  12280. //--------------------------------------------------------------------------
  12281. function CryptVerifyMessageHash(pHashPara: PCRYPT_HASH_MESSAGE_PARA;
  12282. pbHashedBlob: LPBYTE; cbHashedBlob: DWORD; pbToBeHashed: LPBYTE;
  12283. pcbToBeHashed: LPDWORD; pbComputedHash: LPBYTE; pcbComputedHash: LPDWORD): BOOL; stdcall;
  12284. {$EXTERNALSYM CryptVerifyMessageHash}
  12285. //+-------------------------------------------------------------------------
  12286. // Verify a hashed message containing a detached hash.
  12287. // The "to be hashed" content is passed in separately. No
  12288. // decoded output. Otherwise, identical to CryptVerifyMessageHash.
  12289. //
  12290. // pcbComputedHash can be NULL, indicating the caller isn't interested
  12291. // in getting the output.
  12292. //--------------------------------------------------------------------------
  12293. function CryptVerifyDetachedMessageHash(pHashPara: PCRYPT_HASH_MESSAGE_PARA;
  12294. pbDetachedHashBlob: LPBYTE; cbDetachedHashBlob: DWORD; cToBeHashed: DWORD;
  12295. rgpbToBeHashed: LPBYTE; rgcbToBeHashed: LPDWORD; pbComputedHash: LPBYTE;
  12296. pcbComputedHash: LPDWORD): BOOL; stdcall;
  12297. {$EXTERNALSYM CryptVerifyDetachedMessageHash}
  12298. //+-------------------------------------------------------------------------
  12299. // Sign the message using the provider's private key specified in the
  12300. // parameters. A dummy SignerId is created and stored in the message.
  12301. //
  12302. // Normally used until a certificate has been created for the key.
  12303. //--------------------------------------------------------------------------
  12304. function CryptSignMessageWithKey(pSignPara: PCRYPT_KEY_SIGN_MESSAGE_PARA;
  12305. pbToBeSigned: LPBYTE; cbToBeSigned: DWORD; pbSignedBlob: LPBYTE;
  12306. var pcbSignedBlob: DWORD): BOOL; stdcall;
  12307. {$EXTERNALSYM CryptSignMessageWithKey}
  12308. //+-------------------------------------------------------------------------
  12309. // Verify a signed message using the specified public key info.
  12310. //
  12311. // Normally called by a CA until it has created a certificate for the
  12312. // key.
  12313. //
  12314. // pPublicKeyInfo contains the public key to use to verify the signed
  12315. // message. If NULL, the signature isn't verified (for instance, the decoded
  12316. // content may contain the PublicKeyInfo).
  12317. //
  12318. // pcbDecoded can be NULL, indicating the caller isn't interested
  12319. // in getting the decoded content.
  12320. //--------------------------------------------------------------------------
  12321. function CryptVerifyMessageSignatureWithKey(pVerifyPara: PCRYPT_KEY_VERIFY_MESSAGE_PARA;
  12322. pPublicKeyInfo: PCERT_PUBLIC_KEY_INFO; pbSignedBlob: LPBYTE; cbSignedBlob: DWORD;
  12323. pbDecoded: LPBYTE; pcbDecoded: LPDWORD): BOOL; stdcall;
  12324. {$EXTERNALSYM CryptVerifyMessageSignatureWithKey}
  12325. //+=========================================================================
  12326. // System Certificate Store Data Structures and APIs
  12327. //==========================================================================
  12328. //+-------------------------------------------------------------------------
  12329. // Get a system certificate store based on a subsystem protocol.
  12330. //
  12331. // Current examples of subsystems protocols are:
  12332. // "MY" Cert Store hold certs with associated Private Keys
  12333. // "CA" Certifying Authority certs
  12334. // "ROOT" Root Certs
  12335. // "SPC" Software publisher certs
  12336. //
  12337. //
  12338. // If hProv is NULL the default provider "1" is opened for you.
  12339. // When the store is closed the provider is release. Otherwise
  12340. // if hProv is not NULL, no provider is created or released.
  12341. //
  12342. // The returned Cert Store can be searched for an appropriate Cert
  12343. // using the Cert Store API's (see certstor.h)
  12344. //
  12345. // When done, the cert store should be closed using CertStoreClose
  12346. //--------------------------------------------------------------------------
  12347. function CertOpenSystemStoreA(hProv: HCRYPTPROV; szSubsystemProtocol: LPCSTR): HCERTSTORE; stdcall;
  12348. {$EXTERNALSYM CertOpenSystemStoreA}
  12349. function CertOpenSystemStoreW(hProv: HCRYPTPROV; szSubsystemProtocol: LPCWSTR): HCERTSTORE; stdcall;
  12350. {$EXTERNALSYM CertOpenSystemStoreW}
  12351. function CertOpenSystemStore(hProv: HCRYPTPROV; szSubsystemProtocol: LPCTSTR): HCERTSTORE; stdcall;
  12352. {$EXTERNALSYM CertOpenSystemStore}
  12353. function CertAddEncodedCertificateToSystemStoreA(szCertStoreName: LPCSTR;
  12354. pbCertEncoded: LPBYTE; cbCertEncoded: DWORD): BOOL; stdcall;
  12355. {$EXTERNALSYM CertAddEncodedCertificateToSystemStoreA}
  12356. function CertAddEncodedCertificateToSystemStoreW(szCertStoreName: LPCWSTR;
  12357. pbCertEncoded: LPBYTE; cbCertEncoded: DWORD): BOOL; stdcall;
  12358. {$EXTERNALSYM CertAddEncodedCertificateToSystemStoreW}
  12359. function CertAddEncodedCertificateToSystemStore(szCertStoreName: LPCTSTR;
  12360. pbCertEncoded: LPBYTE; cbCertEncoded: DWORD): BOOL; stdcall;
  12361. {$EXTERNALSYM CertAddEncodedCertificateToSystemStore}
  12362. //+-------------------------------------------------------------------------
  12363. // Find all certificate chains tying the given issuer name to any certificate
  12364. // that the current user has a private key for.
  12365. //
  12366. // If no certificate chain is found, FALSE is returned with LastError set
  12367. // to CRYPT_E_NOT_FOUND and the counts zeroed.
  12368. //
  12369. // IE 3.0 ASSUMPTION:
  12370. // The client certificates are in the "My" system store. The issuer
  12371. // cerificates may be in the "Root", "CA" or "My" system stores.
  12372. //--------------------------------------------------------------------------
  12373. type
  12374. PCERT_CHAIN = ^CERT_CHAIN;
  12375. {$EXTERNALSYM PCERT_CHAIN}
  12376. _CERT_CHAIN = record
  12377. cCerts: DWORD; // number of certs in chain
  12378. certs: PCERT_BLOB; // pointer to array of cert chain blobs
  12379. // representing the certs
  12380. keyLocatorInfo: CRYPT_KEY_PROV_INFO; // key locator for cert
  12381. end;
  12382. {$EXTERNALSYM _CERT_CHAIN}
  12383. CERT_CHAIN = _CERT_CHAIN;
  12384. {$EXTERNALSYM CERT_CHAIN}
  12385. TCertChain = CERT_CHAIN;
  12386. PCertChain = PCERT_CHAIN;
  12387. // WINCRYPT32API This is not exported by crypt32, it is exported by softpub
  12388. function FindCertsByIssuer(pCertChains: PCERT_CHAIN; var pcbCertChains: DWORD;
  12389. pcCertChains: LPDWORD; pbEncodedIssuerName: LPBYTE; cbEncodedIssuerName: DWORD;
  12390. pwszPurpose: LPCWSTR; dwKeySpec: DWORD): HRESULT; stdcall;
  12391. {$EXTERNALSYM FindCertsByIssuer}
  12392. //-------------------------------------------------------------------------
  12393. //
  12394. // CryptQueryObject takes a CERT_BLOB or a file name and returns the
  12395. // information about the content in the blob or in the file.
  12396. //
  12397. // Parameters:
  12398. // INPUT dwObjectType:
  12399. // Indicate the type of the object. Should be one of the
  12400. // following:
  12401. // CERT_QUERY_OBJECT_FILE
  12402. // CERT_QUERY_OBJECT_BLOB
  12403. //
  12404. // INPUT pvObject:
  12405. // If dwObjectType == CERT_QUERY_OBJECT_FILE, it is a
  12406. // LPWSTR, that is, the pointer to a wchar file name
  12407. // if dwObjectType == CERT_QUERY_OBJECT_BLOB, it is a
  12408. // PCERT_BLOB, that is, a pointer to a CERT_BLOB
  12409. //
  12410. // INPUT dwExpectedContentTypeFlags:
  12411. // Indicate the expected contenet type.
  12412. // Can be one of the following:
  12413. // CERT_QUERY_CONTENT_FLAG_ALL (the content can be any type)
  12414. // CERT_QUERY_CONTENT_FLAG_CERT
  12415. // CERT_QUERY_CONTENT_FLAG_CTL
  12416. // CERT_QUERY_CONTENT_FLAG_CRL
  12417. // CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE
  12418. // CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT
  12419. // CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL
  12420. // CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL
  12421. // CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED
  12422. // CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED
  12423. // CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED
  12424. // CERT_QUERY_CONTNET_FLAG_PKCS10
  12425. // CERT_QUERY_CONTNET_FLAG_PFX
  12426. //
  12427. // INPUT dwExpectedFormatTypeFlags:
  12428. // Indicate the expected format type.
  12429. // Can be one of the following:
  12430. // CERT_QUERY_FORMAT_FLAG_ALL (the content can be any format)
  12431. // CERT_QUERY_FORMAT_FLAG_BINARY
  12432. // CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED
  12433. //
  12434. //
  12435. // INPUT dwFlags
  12436. // Reserved flag. Should always set to 0
  12437. //
  12438. // OUTPUT pdwMsgAndCertEncodingType
  12439. // Optional output. If NULL != pdwMsgAndCertEncodingType,
  12440. // it contains the encoding type of the content as any
  12441. // combination of the following:
  12442. // X509_ASN_ENCODING
  12443. // PKCS_7_ASN_ENCODING
  12444. //
  12445. // OUTPUT pdwContentType
  12446. // Optional output. If NULL!=pdwContentType, it contains
  12447. // the content type as one of the the following:
  12448. // CERT_QUERY_CONTENT_CERT
  12449. // CERT_QUERY_CONTENT_CTL
  12450. // CERT_QUERY_CONTENT_CRL
  12451. // CERT_QUERY_CONTENT_SERIALIZED_STORE
  12452. // CERT_QUERY_CONTENT_SERIALIZED_CERT
  12453. // CERT_QUERY_CONTENT_SERIALIZED_CTL
  12454. // CERT_QUERY_CONTENT_SERIALIZED_CRL
  12455. // CERT_QUERY_CONTENT_PKCS7_SIGNED
  12456. // CERT_QUERY_CONTENT_PKCS7_UNSIGNED
  12457. // CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED
  12458. // CERT_QUERY_CONTENT_PKCS10
  12459. // CERT_QUERY_CONTENT_PFX
  12460. //
  12461. // OUTPUT pdwFormatType
  12462. // Optional output. If NULL !=pdwFormatType, it
  12463. // contains the format type of the content as one of the
  12464. // following:
  12465. // CERT_QUERY_FORMAT_BINARY
  12466. // CERT_QUERY_FORMAT_BASE64_ENCODED
  12467. //
  12468. //
  12469. // OUTPUT phCertStore
  12470. // Optional output. If NULL !=phStore,
  12471. // it contains a cert store that includes all of certificates,
  12472. // CRL, and CTL in the object if the object content type is
  12473. // one of the following:
  12474. // CERT_QUERY_CONTENT_CERT
  12475. // CERT_QUERY_CONTENT_CTL
  12476. // CERT_QUERY_CONTENT_CRL
  12477. // CERT_QUERY_CONTENT_SERIALIZED_STORE
  12478. // CERT_QUERY_CONTENT_SERIALIZED_CERT
  12479. // CERT_QUERY_CONTENT_SERIALIZED_CTL
  12480. // CERT_QUERY_CONTENT_SERIALIZED_CRL
  12481. // CERT_QUERY_CONTENT_PKCS7_SIGNED
  12482. // CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED
  12483. //
  12484. // Caller should free *phCertStore via CertCloseStore.
  12485. //
  12486. //
  12487. // OUTPUT phMsg Optional output. If NULL != phMsg,
  12488. // it contains a handle to a opened message if
  12489. // the content type is one of the following:
  12490. // CERT_QUERY_CONTENT_PKCS7_SIGNED
  12491. // CERT_QUERY_CONTENT_PKCS7_UNSIGNED
  12492. // CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED
  12493. //
  12494. // Caller should free *phMsg via CryptMsgClose.
  12495. //
  12496. // OUTPUT pContext Optional output. If NULL != pContext,
  12497. // it contains either a PCCERT_CONTEXT or PCCRL_CONTEXT,
  12498. // or PCCTL_CONTEXT based on the content type.
  12499. //
  12500. // If the content type is CERT_QUERY_CONTENT_CERT or
  12501. // CERT_QUERY_CONTENT_SERIALIZED_CERT, it is a PCCERT_CONTEXT;
  12502. // Caller should free the pContext via CertFreeCertificateContext.
  12503. //
  12504. // If the content type is CERT_QUERY_CONTENT_CRL or
  12505. // CERT_QUERY_CONTENT_SERIALIZED_CRL, it is a PCCRL_CONTEXT;
  12506. // Caller should free the pContext via CertFreeCRLContext.
  12507. //
  12508. // If the content type is CERT_QUERY_CONTENT_CTL or
  12509. // CERT_QUERY_CONTENT_SERIALIZED_CTL, it is a PCCTL_CONTEXT;
  12510. // Caller should free the pContext via CertFreeCTLContext.
  12511. //
  12512. // If the *pbObject is of type CERT_QUERY_CONTENT_PKCS10 or CERT_QUERY_CONTENT_PFX, CryptQueryObject
  12513. // will not return anything in *phCertstore, *phMsg, or *ppvContext.
  12514. //--------------------------------------------------------------------------
  12515. function CryptQueryObject(dwObjectType: DWORD; pvObject: Pointer;
  12516. dwExpectedContentTypeFlags, dwExpectedFormatTypeFlags, dwFlags: DWORD;
  12517. pdwMsgAndCertEncodingType, pdwContentType, pdwFormatType: LPDWORD;
  12518. phCertStore: PHCERTSTORE; phMsg: PHCRYPTMSG; ppvContext: PPointer): BOOL; stdcall;
  12519. {$EXTERNALSYM CryptQueryObject}
  12520. //-------------------------------------------------------------------------
  12521. //dwObjectType for CryptQueryObject
  12522. //-------------------------------------------------------------------------
  12523. const
  12524. CERT_QUERY_OBJECT_FILE = $00000001;
  12525. {$EXTERNALSYM CERT_QUERY_OBJECT_FILE}
  12526. CERT_QUERY_OBJECT_BLOB = $00000002;
  12527. {$EXTERNALSYM CERT_QUERY_OBJECT_BLOB}
  12528. //-------------------------------------------------------------------------
  12529. //dwConentType for CryptQueryObject
  12530. //-------------------------------------------------------------------------
  12531. //encoded single certificate
  12532. CERT_QUERY_CONTENT_CERT = 1;
  12533. {$EXTERNALSYM CERT_QUERY_CONTENT_CERT}
  12534. //encoded single CTL
  12535. CERT_QUERY_CONTENT_CTL = 2;
  12536. {$EXTERNALSYM CERT_QUERY_CONTENT_CTL}
  12537. //encoded single CRL
  12538. CERT_QUERY_CONTENT_CRL = 3;
  12539. {$EXTERNALSYM CERT_QUERY_CONTENT_CRL}
  12540. //serialized store
  12541. CERT_QUERY_CONTENT_SERIALIZED_STORE = 4;
  12542. {$EXTERNALSYM CERT_QUERY_CONTENT_SERIALIZED_STORE}
  12543. //serialized single certificate
  12544. CERT_QUERY_CONTENT_SERIALIZED_CERT = 5;
  12545. {$EXTERNALSYM CERT_QUERY_CONTENT_SERIALIZED_CERT}
  12546. //serialized single CTL
  12547. CERT_QUERY_CONTENT_SERIALIZED_CTL = 6;
  12548. {$EXTERNALSYM CERT_QUERY_CONTENT_SERIALIZED_CTL}
  12549. //serialized single CRL
  12550. CERT_QUERY_CONTENT_SERIALIZED_CRL = 7;
  12551. {$EXTERNALSYM CERT_QUERY_CONTENT_SERIALIZED_CRL}
  12552. //a PKCS#7 signed message
  12553. CERT_QUERY_CONTENT_PKCS7_SIGNED = 8;
  12554. {$EXTERNALSYM CERT_QUERY_CONTENT_PKCS7_SIGNED}
  12555. //a PKCS#7 message, such as enveloped message. But it is not a signed message,
  12556. CERT_QUERY_CONTENT_PKCS7_UNSIGNED = 9;
  12557. {$EXTERNALSYM CERT_QUERY_CONTENT_PKCS7_UNSIGNED}
  12558. //a PKCS7 signed message embedded in a file
  12559. CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED = 10;
  12560. {$EXTERNALSYM CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED}
  12561. //an encoded PKCS#10
  12562. CERT_QUERY_CONTENT_PKCS10 = 11;
  12563. {$EXTERNALSYM CERT_QUERY_CONTENT_PKCS10}
  12564. //an encoded PKX BLOB
  12565. CERT_QUERY_CONTENT_PFX = 12;
  12566. {$EXTERNALSYM CERT_QUERY_CONTENT_PFX}
  12567. //-------------------------------------------------------------------------
  12568. //dwExpectedConentTypeFlags for CryptQueryObject
  12569. //-------------------------------------------------------------------------
  12570. //encoded single certificate
  12571. CERT_QUERY_CONTENT_FLAG_CERT = 1 shl CERT_QUERY_CONTENT_CERT;
  12572. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_CERT}
  12573. //encoded single CTL
  12574. CERT_QUERY_CONTENT_FLAG_CTL = 1 shl CERT_QUERY_CONTENT_CTL;
  12575. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_CTL}
  12576. //encoded single CRL
  12577. CERT_QUERY_CONTENT_FLAG_CRL = 1 shl CERT_QUERY_CONTENT_CRL;
  12578. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_CRL}
  12579. //serialized store
  12580. CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE = 1 shl CERT_QUERY_CONTENT_SERIALIZED_STORE;
  12581. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE}
  12582. //serialized single certificate
  12583. CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT = 1 shl CERT_QUERY_CONTENT_SERIALIZED_CERT;
  12584. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT}
  12585. //serialized single CTL
  12586. CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL = 1 shl CERT_QUERY_CONTENT_SERIALIZED_CTL;
  12587. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL}
  12588. //serialized single CRL
  12589. CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL = 1 shl CERT_QUERY_CONTENT_SERIALIZED_CRL;
  12590. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL}
  12591. //an encoded PKCS#7 signed message
  12592. CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED = 1 shl CERT_QUERY_CONTENT_PKCS7_SIGNED;
  12593. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED}
  12594. //an encoded PKCS#7 message. But it is not a signed message
  12595. CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED = 1 shl CERT_QUERY_CONTENT_PKCS7_UNSIGNED;
  12596. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED}
  12597. //the content includes an embedded PKCS7 signed message
  12598. CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED = 1 shl CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED;
  12599. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED}
  12600. //an encoded PKCS#10
  12601. CERT_QUERY_CONTENT_FLAG_PKCS10 = 1 shl CERT_QUERY_CONTENT_PKCS10;
  12602. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_PKCS10}
  12603. //an encoded PFX BLOB
  12604. CERT_QUERY_CONTENT_FLAG_PFX = 1 shl CERT_QUERY_CONTENT_PFX;
  12605. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_PFX}
  12606. //content can be any type
  12607. CERT_QUERY_CONTENT_FLAG_ALL = CERT_QUERY_CONTENT_FLAG_CERT or
  12608. CERT_QUERY_CONTENT_FLAG_CTL or
  12609. CERT_QUERY_CONTENT_FLAG_CRL or
  12610. CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE or
  12611. CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT or
  12612. CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL or
  12613. CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL or
  12614. CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED or
  12615. CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED or
  12616. CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED or
  12617. CERT_QUERY_CONTENT_FLAG_PKCS10 or
  12618. CERT_QUERY_CONTENT_FLAG_PFX;
  12619. {$EXTERNALSYM CERT_QUERY_CONTENT_FLAG_ALL}
  12620. //-------------------------------------------------------------------------
  12621. //dwFormatType for CryptQueryObject
  12622. //-------------------------------------------------------------------------
  12623. //the content is in binary format
  12624. CERT_QUERY_FORMAT_BINARY = 1;
  12625. {$EXTERNALSYM CERT_QUERY_FORMAT_BINARY}
  12626. //the content is base64 encoded
  12627. CERT_QUERY_FORMAT_BASE64_ENCODED = 2;
  12628. {$EXTERNALSYM CERT_QUERY_FORMAT_BASE64_ENCODED}
  12629. //-------------------------------------------------------------------------
  12630. //dwExpectedFormatTypeFlags for CryptQueryObject
  12631. //-------------------------------------------------------------------------
  12632. //the content is in binary format
  12633. CERT_QUERY_FORMAT_FLAG_BINARY = 1 shl CERT_QUERY_FORMAT_BINARY;
  12634. {$EXTERNALSYM CERT_QUERY_FORMAT_FLAG_BINARY}
  12635. //the content is base64 encoded
  12636. CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED = 1 shl CERT_QUERY_FORMAT_BASE64_ENCODED;
  12637. {$EXTERNALSYM CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED}
  12638. //the content can be of any format
  12639. CERT_QUERY_FORMAT_FLAG_ALL = CERT_QUERY_FORMAT_FLAG_BINARY or CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED;
  12640. {$EXTERNALSYM CERT_QUERY_FORMAT_FLAG_ALL}
  12641. //
  12642. // Crypt32 Memory Management Routines. All Crypt32 API which return allocated
  12643. // buffers will do so via CryptMemAlloc, CryptMemRealloc. Clients can free
  12644. // those buffers using CryptMemFree. Also included is CryptMemSize
  12645. //
  12646. function CryptMemAlloc(cbSize: ULONG): LPVOID; stdcall;
  12647. {$EXTERNALSYM CryptMemAlloc}
  12648. function CryptMemRealloc(pv: LPVOID; cbSize: ULONG): LPVOID; stdcall;
  12649. {$EXTERNALSYM CryptMemRealloc}
  12650. procedure CryptMemFree(pv: LPVOID); stdcall;
  12651. {$EXTERNALSYM CryptMemFree}
  12652. //
  12653. // Crypt32 Asynchronous Parameter Management Routines. All Crypt32 API which
  12654. // expose asynchronous mode operation use a Crypt32 Async Handle to pass
  12655. // around information about the operation e.g. callback routines. The
  12656. // following API are used for manipulation of the async handle
  12657. //
  12658. type
  12659. HCRYPTASYNC = HANDLE;
  12660. {$EXTERNALSYM HCRYPTASYNC}
  12661. PHCRYPTASYNC = ^HCRYPTASYNC;
  12662. {$EXTERNALSYM PHCRYPTASYNC}
  12663. PFN_CRYPT_ASYNC_PARAM_FREE_FUNC = procedure(pszParamOid: LPSTR; pvParam: LPVOID); stdcall;
  12664. {$EXTERNALSYM PFN_CRYPT_ASYNC_PARAM_FREE_FUNC}
  12665. PFnCryptAsyncParamFreeFunc = PFN_CRYPT_ASYNC_PARAM_FREE_FUNC;
  12666. function CryptCreateAsyncHandle(dwFlags: DWORD; phAsync: PHCRYPTASYNC): BOOL; stdcall;
  12667. {$EXTERNALSYM CryptCreateAsyncHandle}
  12668. function CryptSetAsyncParam(hAsync: HCRYPTASYNC; pszParamOid: LPSTR;
  12669. pvParam: LPVOID; pfnFree: PFN_CRYPT_ASYNC_PARAM_FREE_FUNC): BOOL; stdcall;
  12670. {$EXTERNALSYM CryptSetAsyncParam}
  12671. function CryptGetAsyncParam(hAsync: HCRYPTASYNC; pszParamOid: LPSTR;
  12672. var ppvParam: LPVOID; var ppfnFree: PFN_CRYPT_ASYNC_PARAM_FREE_FUNC): BOOL; stdcall;
  12673. {$EXTERNALSYM CryptGetAsyncParam}
  12674. function CryptCloseAsyncHandle(hAsync: HCRYPTASYNC): BOOL; stdcall;
  12675. {$EXTERNALSYM CryptCloseAsyncHandle}
  12676. //
  12677. // Crypt32 Remote Object Retrieval Routines. This API allows retrieval of
  12678. // remote PKI objects where the location is given by an URL. The remote
  12679. // object retrieval manager exposes two provider models. One is the "Scheme
  12680. // Provider" model which allows for installable protocol providers as defined
  12681. // by the URL scheme e.g. ldap, http, ftp. The scheme provider entry point is
  12682. // the same as the CryptRetrieveObjectByUrl however the *ppvObject returned
  12683. // is ALWAYS a counted array of encoded bits (one per object retrieved). The
  12684. // second provider model is the "Context Provider" model which allows for
  12685. // installable creators of CAPI2 context handles (objects) based on the
  12686. // retrieved encoded bits. These are dispatched based on the object OID given
  12687. // in the call to CryptRetrieveObjectByUrl.
  12688. //
  12689. type
  12690. PCRYPT_BLOB_ARRAY = ^CRYPT_BLOB_ARRAY;
  12691. {$EXTERNALSYM PCRYPT_BLOB_ARRAY}
  12692. _CRYPT_BLOB_ARRAY = record
  12693. cBlob: DWORD;
  12694. rgBlob: PCRYPT_DATA_BLOB;
  12695. end;
  12696. {$EXTERNALSYM _CRYPT_BLOB_ARRAY}
  12697. CRYPT_BLOB_ARRAY = _CRYPT_BLOB_ARRAY;
  12698. {$EXTERNALSYM CRYPT_BLOB_ARRAY}
  12699. TCryptBlobArray = CRYPT_BLOB_ARRAY;
  12700. PCryptBlobArray = PCRYPT_BLOB_ARRAY;
  12701. PCRYPT_CREDENTIALS = ^CRYPT_CREDENTIALS;
  12702. {$EXTERNALSYM PCRYPT_CREDENTIALS}
  12703. _CRYPT_CREDENTIALS = record
  12704. cbSize: DWORD;
  12705. pszCredentialsOid: LPCSTR;
  12706. pvCredentials: LPVOID;
  12707. end;
  12708. {$EXTERNALSYM _CRYPT_CREDENTIALS}
  12709. CRYPT_CREDENTIALS = _CRYPT_CREDENTIALS;
  12710. {$EXTERNALSYM CRYPT_CREDENTIALS}
  12711. TCryptCredentials = CRYPT_CREDENTIALS;
  12712. PCryptCredentials = PCRYPT_CREDENTIALS;
  12713. const
  12714. CREDENTIAL_OID_PASSWORD_CREDENTIALS_A = LPCSTR(1);
  12715. {$EXTERNALSYM CREDENTIAL_OID_PASSWORD_CREDENTIALS_A}
  12716. CREDENTIAL_OID_PASSWORD_CREDENTIALS_W = LPCSTR(2);
  12717. {$EXTERNALSYM CREDENTIAL_OID_PASSWORD_CREDENTIALS_W}
  12718. {$IFDEF UNICODE}
  12719. CREDENTIAL_OID_PASSWORD_CREDENTIALS = CREDENTIAL_OID_PASSWORD_CREDENTIALS_W;
  12720. {$EXTERNALSYM CREDENTIAL_OID_PASSWORD_CREDENTIALS}
  12721. {$ELSE}
  12722. CREDENTIAL_OID_PASSWORD_CREDENTIALS = CREDENTIAL_OID_PASSWORD_CREDENTIALS_A;
  12723. {$EXTERNALSYM CREDENTIAL_OID_PASSWORD_CREDENTIALS}
  12724. {$ENDIF UNICODE}
  12725. type
  12726. PCRYPT_PASSWORD_CREDENTIALSA = ^CRYPT_PASSWORD_CREDENTIALSA;
  12727. {$EXTERNALSYM PCRYPT_PASSWORD_CREDENTIALSA}
  12728. _CRYPT_PASSWORD_CREDENTIALSA = record
  12729. cbSize: DWORD;
  12730. pszUsername: LPSTR;
  12731. pszPassword: LPSTR;
  12732. end;
  12733. {$EXTERNALSYM _CRYPT_PASSWORD_CREDENTIALSA}
  12734. CRYPT_PASSWORD_CREDENTIALSA = _CRYPT_PASSWORD_CREDENTIALSA;
  12735. {$EXTERNALSYM CRYPT_PASSWORD_CREDENTIALSA}
  12736. TCryptPasswordCredentialsA = CRYPT_PASSWORD_CREDENTIALSA;
  12737. PCryptPasswordCredentialsA = PCRYPT_PASSWORD_CREDENTIALSA;
  12738. PCRYPT_PASSWORD_CREDENTIALSW = ^CRYPT_PASSWORD_CREDENTIALSW;
  12739. {$EXTERNALSYM PCRYPT_PASSWORD_CREDENTIALSW}
  12740. _CRYPT_PASSWORD_CREDENTIALSW = record
  12741. cbSize: DWORD;
  12742. pszUsername: LPWSTR;
  12743. pszPassword: LPWSTR;
  12744. end;
  12745. {$EXTERNALSYM _CRYPT_PASSWORD_CREDENTIALSW}
  12746. CRYPT_PASSWORD_CREDENTIALSW = _CRYPT_PASSWORD_CREDENTIALSW;
  12747. {$EXTERNALSYM CRYPT_PASSWORD_CREDENTIALSW}
  12748. TCryptPasswordCredentialsW = CRYPT_PASSWORD_CREDENTIALSW;
  12749. PCryptPasswordCredentialsW = PCRYPT_PASSWORD_CREDENTIALSW;
  12750. {$IFDEF UNICODE}
  12751. CRYPT_PASSWORD_CREDENTIALS = CRYPT_PASSWORD_CREDENTIALSW;
  12752. {$EXTERNALSYM CRYPT_PASSWORD_CREDENTIALS}
  12753. PCRYPT_PASSWORD_CREDENTIALS = PCRYPT_PASSWORD_CREDENTIALSW;
  12754. {$EXTERNALSYM PCRYPT_PASSWORD_CREDENTIALS}
  12755. TCryptPasswordCredentials = TCryptPasswordCredentialsW;
  12756. PCryptPasswordCredentials = PCryptPasswordCredentialsW;
  12757. {$ELSE}
  12758. CRYPT_PASSWORD_CREDENTIALS = CRYPT_PASSWORD_CREDENTIALSA;
  12759. {$EXTERNALSYM CRYPT_PASSWORD_CREDENTIALS}
  12760. PCRYPT_PASSWORD_CREDENTIALS = PCRYPT_PASSWORD_CREDENTIALSA;
  12761. {$EXTERNALSYM PCRYPT_PASSWORD_CREDENTIALS}
  12762. TCryptPasswordCredentials = TCryptPasswordCredentialsA;
  12763. PCryptPasswordCredentials = PCryptPasswordCredentialsA;
  12764. {$ENDIF UNICODE}
  12765. //
  12766. // Scheme Provider Signatures
  12767. //
  12768. const
  12769. SCHEME_OID_RETRIEVE_ENCODED_OBJECT_FUNC = 'SchemeDllRetrieveEncodedObject';
  12770. {$EXTERNALSYM SCHEME_OID_RETRIEVE_ENCODED_OBJECT_FUNC}
  12771. type
  12772. PFN_FREE_ENCODED_OBJECT_FUNC = procedure(pszObjectOid: LPCSTR;
  12773. pObject: PCRYPT_BLOB_ARRAY; pvFreeContext: LPVOID); stdcall;
  12774. {$EXTERNALSYM PFN_FREE_ENCODED_OBJECT_FUNC}
  12775. PFnFreeEncodedObjectFunc = PFN_FREE_ENCODED_OBJECT_FUNC;
  12776. //
  12777. // SchemeDllRetrieveEncodedObject has the following signature:
  12778. //
  12779. // BOOL WINAPI SchemeDllRetrieveEncodedObject (
  12780. // IN LPCSTR pszUrl,
  12781. // IN LPCSTR pszObjectOid,
  12782. // IN DWORD dwRetrievalFlags,
  12783. // IN DWORD dwTimeout,
  12784. // OUT PCRYPT_BLOB_ARRAY pObject,
  12785. // OUT PFN_FREE_ENCODED_OBJECT_FUNC* ppfnFreeObject,
  12786. // OUT LPVOID* ppvFreeContext,
  12787. // IN HCRYPTASYNC hAsyncRetrieve,
  12788. // IN PCRYPT_CREDENTIALS pCredentials,
  12789. // IN LPVOID pvReserved
  12790. // )
  12791. //
  12792. //
  12793. // Context Provider Signatures
  12794. //
  12795. const
  12796. CONTEXT_OID_CREATE_OBJECT_CONTEXT_FUNC = 'ContextDllCreateObjectContext';
  12797. {$EXTERNALSYM CONTEXT_OID_CREATE_OBJECT_CONTEXT_FUNC}
  12798. CONTEXT_OID_CERTIFICATE = LPCSTR(1);
  12799. {$EXTERNALSYM CONTEXT_OID_CERTIFICATE}
  12800. CONTEXT_OID_CRL = LPCSTR(2);
  12801. {$EXTERNALSYM CONTEXT_OID_CRL}
  12802. CONTEXT_OID_CTL = LPCSTR(3);
  12803. {$EXTERNALSYM CONTEXT_OID_CTL}
  12804. CONTEXT_OID_PKCS7 = LPCSTR(4);
  12805. {$EXTERNALSYM CONTEXT_OID_PKCS7}
  12806. CONTEXT_OID_CAPI2_ANY = LPCSTR(5);
  12807. {$EXTERNALSYM CONTEXT_OID_CAPI2_ANY}
  12808. //
  12809. // ContextDllCreateObjectContext has the following signature:
  12810. //
  12811. // BOOL WINAPI ContextDllCreateObjectContext (
  12812. // IN LPCSTR pszObjectOid,
  12813. // IN DWORD dwRetrievalFlags,
  12814. // IN PCRYPT_BLOB_ARRAY pObject,
  12815. // OUT LPVOID* ppvContext
  12816. // )
  12817. //
  12818. //
  12819. // Remote Object Retrieval API
  12820. //
  12821. //
  12822. // Retrieval flags
  12823. //
  12824. CRYPT_RETRIEVE_MULTIPLE_OBJECTS = $00000001;
  12825. {$EXTERNALSYM CRYPT_RETRIEVE_MULTIPLE_OBJECTS}
  12826. CRYPT_CACHE_ONLY_RETRIEVAL = $00000002;
  12827. {$EXTERNALSYM CRYPT_CACHE_ONLY_RETRIEVAL}
  12828. CRYPT_WIRE_ONLY_RETRIEVAL = $00000004;
  12829. {$EXTERNALSYM CRYPT_WIRE_ONLY_RETRIEVAL}
  12830. CRYPT_DONT_CACHE_RESULT = $00000008;
  12831. {$EXTERNALSYM CRYPT_DONT_CACHE_RESULT}
  12832. CRYPT_ASYNC_RETRIEVAL = $00000010;
  12833. {$EXTERNALSYM CRYPT_ASYNC_RETRIEVAL}
  12834. //
  12835. // Data verification retrieval flags
  12836. //
  12837. // CRYPT_VERIFY_CONTEXT_SIGNATURE is used to get signature verification
  12838. // on the context created. In this case pszObjectOid must be non-NULL and
  12839. // pvVerify points to the signer certificate context
  12840. //
  12841. // CRYPT_VERIFY_DATA_HASH is used to get verification of the blob data
  12842. // retrieved by the protocol. The pvVerify points to an URL_DATA_HASH
  12843. // structure (TBD)
  12844. //
  12845. CRYPT_VERIFY_CONTEXT_SIGNATURE = $00000020;
  12846. {$EXTERNALSYM CRYPT_VERIFY_CONTEXT_SIGNATURE}
  12847. CRYPT_VERIFY_DATA_HASH = $00000040;
  12848. {$EXTERNALSYM CRYPT_VERIFY_DATA_HASH}
  12849. //
  12850. // Time Valid Object flags
  12851. //
  12852. CRYPT_KEEP_TIME_VALID = $00000080;
  12853. {$EXTERNALSYM CRYPT_KEEP_TIME_VALID}
  12854. CRYPT_DONT_VERIFY_SIGNATURE = $00000100;
  12855. {$EXTERNALSYM CRYPT_DONT_VERIFY_SIGNATURE}
  12856. CRYPT_DONT_CHECK_TIME_VALIDITY = $00000200;
  12857. {$EXTERNALSYM CRYPT_DONT_CHECK_TIME_VALIDITY}
  12858. function CryptRetrieveObjectByUrlA(pszUrl: LPCSTR; pszObjectOid: LPCSTR;
  12859. dwRetrievalFlags: DWORD; dwTimeout: DWORD; var ppvObject: LPVOID;
  12860. hAsyncRetrieve: HCRYPTASYNC; pCredentials: PCRYPT_CREDENTIALS;
  12861. pvVerify: LPVOID; pvReserved: LPVOID): BOOL; stdcall;
  12862. {$EXTERNALSYM CryptRetrieveObjectByUrlA}
  12863. function CryptRetrieveObjectByUrlW(pszUrl: LPCWSTR; pszObjectOid: LPCSTR;
  12864. dwRetrievalFlags: DWORD; dwTimeout: DWORD; var ppvObject: LPVOID;
  12865. hAsyncRetrieve: HCRYPTASYNC; pCredentials: PCRYPT_CREDENTIALS;
  12866. pvVerify: LPVOID; pvReserved: LPVOID): BOOL; stdcall;
  12867. {$EXTERNALSYM CryptRetrieveObjectByUrlW}
  12868. function CryptRetrieveObjectByUrl(pszUrl: LPCTSTR; pszObjectOid: LPCSTR;
  12869. dwRetrievalFlags: DWORD; dwTimeout: DWORD; var ppvObject: LPVOID;
  12870. hAsyncRetrieve: HCRYPTASYNC; pCredentials: PCRYPT_CREDENTIALS;
  12871. pvVerify: LPVOID; pvReserved: LPVOID): BOOL; stdcall;
  12872. {$EXTERNALSYM CryptRetrieveObjectByUrl}
  12873. //
  12874. // Call back function to cancel object retrieval
  12875. //
  12876. // The function can be installed on a per thread basis.
  12877. // If CryptInstallCancelRetrieval is called for multiple times, only the most recent
  12878. // installation will be kept.
  12879. //
  12880. // This is only effective for http, https, gopher, and ftp protocol.
  12881. // It is ignored by the rest of the protocols.
  12882. type
  12883. PFN_CRYPT_CANCEL_RETRIEVAL = function(dwFlags: DWORD; pvArg: Pointer): BOOL; stdcall;
  12884. {$EXTERNALSYM PFN_CRYPT_CANCEL_RETRIEVAL}
  12885. PFnCryptCancelRetrieval = PFN_CRYPT_CANCEL_RETRIEVAL;
  12886. //
  12887. // PFN_CRYPT_CANCEL_RETRIEVAL
  12888. //
  12889. // This function should return FALSE when the object retrieval should be continued
  12890. // and return TRUE when the object retrieval should be cancelled.
  12891. //
  12892. function CryptInstallCancelRetrieval(pfnCancel: PFN_CRYPT_CANCEL_RETRIEVAL;
  12893. pvArg: Pointer; dwFlags: DWORD; pvReserved: Pointer): BOOL; stdcall;
  12894. {$EXTERNALSYM CryptInstallCancelRetrieval}
  12895. function CryptUninstallCancelRetrieval(dwFlags: DWORD; pvReserved: Pointer): BOOL; stdcall;
  12896. {$EXTERNALSYM CryptUninstallCancelRetrieval}
  12897. function CryptCancelAsyncRetrieval(hAsyncRetrieval: HCRYPTASYNC): BOOL; stdcall;
  12898. {$EXTERNALSYM CryptCancelAsyncRetrieval}
  12899. //
  12900. // Remote Object Async Retrieval parameters
  12901. //
  12902. //
  12903. // A client that wants to be notified of asynchronous object retrieval
  12904. // completion sets this parameter on the async handle
  12905. //
  12906. const
  12907. CRYPT_PARAM_ASYNC_RETRIEVAL_COMPLETION = LPCSTR(1);
  12908. {$EXTERNALSYM CRYPT_PARAM_ASYNC_RETRIEVAL_COMPLETION}
  12909. type
  12910. PFN_CRYPT_ASYNC_RETRIEVAL_COMPLETION_FUNC = procedure(pvCompletion: LPVOID;
  12911. dwCompletionCode: DWORD; pszUrl: LPCSTR; pszObjectOid: LPSTR; pvObject: LPVOID); stdcall;
  12912. {$EXTERNALSYM PFN_CRYPT_ASYNC_RETRIEVAL_COMPLETION_FUNC}
  12913. PFnCryptASynchRetrievalCompletionFunc = PFN_CRYPT_ASYNC_RETRIEVAL_COMPLETION_FUNC;
  12914. PCRYPT_ASYNC_RETRIEVAL_COMPLETION = ^CRYPT_ASYNC_RETRIEVAL_COMPLETION;
  12915. {$EXTERNALSYM PCRYPT_ASYNC_RETRIEVAL_COMPLETION}
  12916. _CRYPT_ASYNC_RETRIEVAL_COMPLETION = record
  12917. pfnCompletion: PFN_CRYPT_ASYNC_RETRIEVAL_COMPLETION_FUNC;
  12918. pvCompletion: LPVOID;
  12919. end;
  12920. {$EXTERNALSYM _CRYPT_ASYNC_RETRIEVAL_COMPLETION}
  12921. CRYPT_ASYNC_RETRIEVAL_COMPLETION = _CRYPT_ASYNC_RETRIEVAL_COMPLETION;
  12922. {$EXTERNALSYM CRYPT_ASYNC_RETRIEVAL_COMPLETION}
  12923. TCryptAsyncRetrievalCompletion = CRYPT_ASYNC_RETRIEVAL_COMPLETION;
  12924. PCryptAsyncRetrievalCompletion = PCRYPT_ASYNC_RETRIEVAL_COMPLETION;
  12925. //
  12926. // This function is set on the async handle by a scheme provider that
  12927. // supports asynchronous retrieval
  12928. //
  12929. const
  12930. CRYPT_PARAM_CANCEL_ASYNC_RETRIEVAL = LPCSTR(2);
  12931. {$EXTERNALSYM CRYPT_PARAM_CANCEL_ASYNC_RETRIEVAL}
  12932. type
  12933. PFN_CANCEL_ASYNC_RETRIEVAL_FUNC = function(hAsyncRetrieve: HCRYPTASYNC): BOOL; stdcall;
  12934. {$EXTERNALSYM PFN_CANCEL_ASYNC_RETRIEVAL_FUNC}
  12935. PFnCancelASynchRetrievalFunc = PFN_CANCEL_ASYNC_RETRIEVAL_FUNC;
  12936. //
  12937. // Get the locator for a CAPI object
  12938. //
  12939. const
  12940. CRYPT_GET_URL_FROM_PROPERTY = $00000001;
  12941. {$EXTERNALSYM CRYPT_GET_URL_FROM_PROPERTY}
  12942. CRYPT_GET_URL_FROM_EXTENSION = $00000002;
  12943. {$EXTERNALSYM CRYPT_GET_URL_FROM_EXTENSION}
  12944. CRYPT_GET_URL_FROM_UNAUTH_ATTRIBUTE = $00000004;
  12945. {$EXTERNALSYM CRYPT_GET_URL_FROM_UNAUTH_ATTRIBUTE}
  12946. CRYPT_GET_URL_FROM_AUTH_ATTRIBUTE = $00000008;
  12947. {$EXTERNALSYM CRYPT_GET_URL_FROM_AUTH_ATTRIBUTE}
  12948. type
  12949. PCRYPT_URL_ARRAY = ^CRYPT_URL_ARRAY;
  12950. {$EXTERNALSYM PCRYPT_URL_ARRAY}
  12951. _CRYPT_URL_ARRAY = record
  12952. cUrl: DWORD;
  12953. rgwszUrl: LPWSTR;
  12954. end;
  12955. {$EXTERNALSYM _CRYPT_URL_ARRAY}
  12956. CRYPT_URL_ARRAY = _CRYPT_URL_ARRAY;
  12957. {$EXTERNALSYM CRYPT_URL_ARRAY}
  12958. TCryptUrlArray = CRYPT_URL_ARRAY;
  12959. PCryptUrlArray = PCRYPT_URL_ARRAY;
  12960. PCRYPT_URL_INFO = ^CRYPT_URL_INFO;
  12961. {$EXTERNALSYM PCRYPT_URL_INFO}
  12962. _CRYPT_URL_INFO = record
  12963. cbSize: DWORD;
  12964. end;
  12965. {$EXTERNALSYM _CRYPT_URL_INFO}
  12966. CRYPT_URL_INFO = _CRYPT_URL_INFO;
  12967. {$EXTERNALSYM CRYPT_URL_INFO}
  12968. TCryptUrlInfo = CRYPT_URL_INFO;
  12969. PCryptUrlInfo = PCRYPT_URL_INFO;
  12970. function CryptGetObjectUrl(pszUrlOid: LPCSTR; pvPara: LPVOID; dwFlags: DWORD;
  12971. pUrlArray: PCRYPT_URL_ARRAY; var pcbUrlArray: DWORD; pUrlInfo: PCRYPT_URL_INFO;
  12972. pcbUrlInfo: LPDWORD; pvReserved: LPVOID): BOOL; stdcall;
  12973. {$EXTERNALSYM CryptGetObjectUrl}
  12974. const
  12975. URL_OID_GET_OBJECT_URL_FUNC = 'UrlDllGetObjectUrl';
  12976. {$EXTERNALSYM URL_OID_GET_OBJECT_URL_FUNC}
  12977. //
  12978. // UrlDllGetObjectUrl has the same signature as CryptGetObjectUrl
  12979. //
  12980. //
  12981. // URL_OID_CERTIFICATE_ISSUER
  12982. //
  12983. // pvPara == PCCERT_CONTEXT, certificate whose issuer's URL is being requested
  12984. //
  12985. // This will be retrieved from the authority info access extension or property
  12986. // on the certificate
  12987. //
  12988. // URL_OID_CERTIFICATE_CRL_DIST_POINT
  12989. //
  12990. // pvPara == PCCERT_CONTEXT, certificate whose CRL distribution point is being
  12991. // requested
  12992. //
  12993. // This will be retrieved from the CRL distribution point extension or property
  12994. // on the certificate
  12995. //
  12996. // URL_OID_CTL_ISSUER
  12997. //
  12998. // pvPara == PCCTL_CONTEXT, Signer Index, CTL whose issuer's URL (identified
  12999. // by the signer index) is being requested
  13000. //
  13001. // This will be retrieved from an authority info access attribute method encoded
  13002. // in each signer info in the PKCS7 (CTL)
  13003. //
  13004. // URL_OID_CTL_NEXT_UPDATE
  13005. //
  13006. // pvPara == PCCTL_CONTEXT, Signer Index, CTL whose next update URL is being
  13007. // requested and an optional signer index in case we need to check signer
  13008. // info attributes
  13009. //
  13010. // This will be retrieved from an authority info access CTL extension, property,
  13011. // or signer info attribute method
  13012. //
  13013. // URL_OID_CRL_ISSUER
  13014. //
  13015. // pvPara == PCCRL_CONTEXT, CRL whose issuer's URL is being requested
  13016. //
  13017. // This will be retrieved from a property on the CRL which has been inherited
  13018. // from the subject cert (either from the subject cert issuer or the subject
  13019. // cert distribution point extension). It will be encoded as an authority
  13020. // info access extension method.
  13021. //
  13022. const
  13023. URL_OID_CERTIFICATE_ISSUER = LPCSTR(1);
  13024. {$EXTERNALSYM URL_OID_CERTIFICATE_ISSUER}
  13025. URL_OID_CERTIFICATE_CRL_DIST_POINT = LPCSTR(2);
  13026. {$EXTERNALSYM URL_OID_CERTIFICATE_CRL_DIST_POINT}
  13027. URL_OID_CTL_ISSUER = LPCSTR(3);
  13028. {$EXTERNALSYM URL_OID_CTL_ISSUER}
  13029. URL_OID_CTL_NEXT_UPDATE = LPCSTR(4);
  13030. {$EXTERNALSYM URL_OID_CTL_NEXT_UPDATE}
  13031. URL_OID_CRL_ISSUER = LPCSTR(5);
  13032. {$EXTERNALSYM URL_OID_CRL_ISSUER}
  13033. //
  13034. // Get a time valid CAPI2 object
  13035. //
  13036. function CryptGetTimeValidObject(pszTimeValidOid: LPCSTR; pvPara: LPVOID;
  13037. pIssuer: PCCERT_CONTEXT; pftValidFor: LPFILETIME; dwFlags, dwTimeout: DWORD;
  13038. ppvObject: LPLPVOID; pCredentials: PCRYPT_CREDENTIALS; pvReserved: LPVOID): BOOL; stdcall;
  13039. {$EXTERNALSYM CryptGetTimeValidObject}
  13040. const
  13041. TIME_VALID_OID_GET_OBJECT_FUNC = 'TimeValidDllGetObject';
  13042. {$EXTERNALSYM TIME_VALID_OID_GET_OBJECT_FUNC}
  13043. //
  13044. // TimeValidDllGetObject has the same signature as CryptGetTimeValidObject
  13045. //
  13046. //
  13047. // TIME_VALID_OID_GET_CTL
  13048. //
  13049. // pvPara == PCCTL_CONTEXT, the current CTL
  13050. //
  13051. // TIME_VALID_OID_GET_CRL
  13052. //
  13053. // pvPara == PCCRL_CONTEXT, the current CRL
  13054. //
  13055. // TIME_VALID_OID_GET_CRL_FROM_CERT
  13056. //
  13057. // pvPara == PCCERT_CONTEXT, the subject cert
  13058. //
  13059. TIME_VALID_OID_GET_CTL = LPCSTR(1);
  13060. {$EXTERNALSYM TIME_VALID_OID_GET_CTL}
  13061. TIME_VALID_OID_GET_CRL = LPCSTR(2);
  13062. {$EXTERNALSYM TIME_VALID_OID_GET_CRL}
  13063. TIME_VALID_OID_GET_CRL_FROM_CERT = LPCSTR(3);
  13064. {$EXTERNALSYM TIME_VALID_OID_GET_CRL_FROM_CERT}
  13065. function CryptFlushTimeValidObject(pszFlushTimeValidOid: LPCSTR; pvPara: LPVOID;
  13066. pIssuer: PCCERT_CONTEXT; dwFlags: DWORD; pvReserved: LPVOID): BOOL; stdcall;
  13067. {$EXTERNALSYM CryptFlushTimeValidObject}
  13068. const
  13069. TIME_VALID_OID_FLUSH_OBJECT_FUNC = 'TimeValidDllFlushObject';
  13070. {$EXTERNALSYM TIME_VALID_OID_FLUSH_OBJECT_FUNC}
  13071. //
  13072. // TimeValidDllFlushObject has the same signature as CryptFlushTimeValidObject
  13073. //
  13074. //
  13075. // TIME_VALID_OID_FLUSH_CTL
  13076. //
  13077. // pvPara == PCCTL_CONTEXT, the CTL to flush
  13078. //
  13079. // TIME_VALID_OID_FLUSH_CRL
  13080. //
  13081. // pvPara == PCCRL_CONTEXT, the CRL to flush
  13082. //
  13083. // TIME_VALID_OID_FLUSH_CRL_FROM_CERT
  13084. //
  13085. TIME_VALID_OID_FLUSH_CTL = LPCSTR(1);
  13086. {$EXTERNALSYM TIME_VALID_OID_FLUSH_CTL}
  13087. TIME_VALID_OID_FLUSH_CRL = LPCSTR(2);
  13088. {$EXTERNALSYM TIME_VALID_OID_FLUSH_CRL}
  13089. TIME_VALID_OID_FLUSH_CRL_FROM_CERT = LPCSTR(3);
  13090. {$EXTERNALSYM TIME_VALID_OID_FLUSH_CRL_FROM_CERT}
  13091. //-------------------------------------------------------------------------
  13092. // Data Protection APIs
  13093. //-------------------------------------------------------------------------
  13094. //
  13095. // Data protection APIs enable applications to easily secure data.
  13096. //
  13097. // The base provider provides protection based on the users' logon
  13098. // credentials. The data secured with these APIs follow the same
  13099. // roaming characteristics as HKCU -- if HKCU roams, the data
  13100. // protected by the base provider may roam as well. This makes
  13101. // the API ideal for the munging of data stored in the registry.
  13102. //
  13103. //
  13104. // Prompt struct -- what to tell users about the access
  13105. //
  13106. type
  13107. PCRYPTPROTECT_PROMPTSTRUCT = ^CRYPTPROTECT_PROMPTSTRUCT;
  13108. {$EXTERNALSYM PCRYPTPROTECT_PROMPTSTRUCT}
  13109. _CRYPTPROTECT_PROMPTSTRUCT = record
  13110. cbSize: DWORD;
  13111. dwPromptFlags: DWORD;
  13112. hwndApp: HWND;
  13113. szPrompt: LPCWSTR;
  13114. end;
  13115. {$EXTERNALSYM _CRYPTPROTECT_PROMPTSTRUCT}
  13116. CRYPTPROTECT_PROMPTSTRUCT = _CRYPTPROTECT_PROMPTSTRUCT;
  13117. {$EXTERNALSYM CRYPTPROTECT_PROMPTSTRUCT}
  13118. TCryptProtectPromptStruct = CRYPTPROTECT_PROMPTSTRUCT;
  13119. PCryptProtectPromptStruct = PCRYPTPROTECT_PROMPTSTRUCT;
  13120. //
  13121. // base provider action
  13122. //
  13123. const
  13124. CRYPTPROTECT_DEFAULT_PROVIDER: GUID = (
  13125. D1:$df9d8cd0; D2:$1501; D3:$11d1; D4:($8c, $7a, $00, $c0, $4f, $c2, $97, $eb));
  13126. {$EXTERNALSYM CRYPTPROTECT_DEFAULT_PROVIDER}
  13127. //
  13128. // CryptProtect PromptStruct dwPromtFlags
  13129. //
  13130. //
  13131. // prompt on unprotect
  13132. CRYPTPROTECT_PROMPT_ON_UNPROTECT = $1; // 1<<0
  13133. {$EXTERNALSYM CRYPTPROTECT_PROMPT_ON_UNPROTECT}
  13134. //
  13135. // prompt on protect
  13136. CRYPTPROTECT_PROMPT_ON_PROTECT = $2; // 1<<1
  13137. {$EXTERNALSYM CRYPTPROTECT_PROMPT_ON_PROTECT}
  13138. CRYPTPROTECT_PROMPT_RESERVED = $04; // reserved, do not use.
  13139. {$EXTERNALSYM CRYPTPROTECT_PROMPT_RESERVED}
  13140. //
  13141. // only allow strong variant UI protection (user supplied password currently).
  13142. CRYPTPROTECT_PROMPT_STRONG = $08; // 1<<3
  13143. {$EXTERNALSYM CRYPTPROTECT_PROMPT_STRONG}
  13144. //
  13145. // CryptProtectData and CryptUnprotectData dwFlags
  13146. //
  13147. // for remote-access situations where ui is not an option
  13148. // if UI was specified on protect or unprotect operation, the call
  13149. // will fail and GetLastError() will indicate ERROR_PASSWORD_RESTRICTION
  13150. CRYPTPROTECT_UI_FORBIDDEN = $1;
  13151. {$EXTERNALSYM CRYPTPROTECT_UI_FORBIDDEN}
  13152. //
  13153. // per machine protected data -- any user on machine where CryptProtectData
  13154. // took place may CryptUnprotectData
  13155. CRYPTPROTECT_LOCAL_MACHINE = $4;
  13156. {$EXTERNALSYM CRYPTPROTECT_LOCAL_MACHINE}
  13157. //
  13158. // force credential synchronize during CryptProtectData()
  13159. // Synchronize is only operation that occurs during this operation
  13160. CRYPTPROTECT_CRED_SYNC = $8;
  13161. {$EXTERNALSYM CRYPTPROTECT_CRED_SYNC}
  13162. // flags reserved for system use
  13163. CRYPTPROTECT_FIRST_RESERVED_FLAGVAL = $0FFFFFFF;
  13164. {$EXTERNALSYM CRYPTPROTECT_FIRST_RESERVED_FLAGVAL}
  13165. CRYPTPROTECT_LAST_RESERVED_FLAGVAL = DWORD($FFFFFFFF);
  13166. {$EXTERNALSYM CRYPTPROTECT_LAST_RESERVED_FLAGVAL}
  13167. //
  13168. // flags specific to base provider
  13169. //
  13170. function CryptProtectData(pDataIn: PDATA_BLOB; szDataDescr: LPCWSTR;
  13171. pOptionalEntropy: PDATA_BLOB; pvReserved: PVOID;
  13172. pPromptStruct: PCRYPTPROTECT_PROMPTSTRUCT; dwFlags: DWORD; pDataOut: PDATA_BLOB): BOOL; stdcall;
  13173. {$EXTERNALSYM CryptProtectData}
  13174. function CryptUnprotectData(pDataIn: PDATA_BLOB; ppszDataDescr: LPLPWSTR;
  13175. pOptionalEntropy: PDATA_BLOB; pvReserved: PVOID;
  13176. pPromptStruct: PCRYPTPROTECT_PROMPTSTRUCT; dwFlags: DWORD; pDataOut: PDATA_BLOB): BOOL; stdcall;
  13177. {$EXTERNALSYM CryptUnprotectData}
  13178. //+=========================================================================
  13179. // Helper functions to build certificates
  13180. //==========================================================================
  13181. //+-------------------------------------------------------------------------
  13182. //
  13183. // Builds a self-signed certificate and returns a PCCERT_CONTEXT representing
  13184. // the certificate. A hProv must be specified to build the cert context.
  13185. //
  13186. // pSubjectIssuerBlob is the DN for the certifcate. If an alternate subject
  13187. // name is desired it must be specified as an extension in the pExtensions
  13188. // parameter. pSubjectIssuerBlob can NOT be NULL, so minimually an empty DN
  13189. // must be specified.
  13190. //
  13191. // By default:
  13192. // pKeyProvInfo - The CSP is queried for the KeyProvInfo parameters. Only the Provider,
  13193. // Provider Type and Container is queried. Many CSPs don't support these
  13194. // queries and will cause a failure. In such cases the pKeyProvInfo
  13195. // must be specified (RSA BASE works fine).
  13196. //
  13197. // pSignatureAlgorithm - will default to SHA1RSA
  13198. // pStartTime will default to the current time
  13199. // pEndTime will default to 1 year
  13200. // pEntensions will be empty.
  13201. //
  13202. // The returned PCCERT_CONTEXT will reference the private keys by setting the
  13203. // CERT_KEY_PROV_INFO_PROP_ID. However, if this property is not desired specify the
  13204. // CERT_CREATE_SELFSIGN_NO_KEY_INFO in dwFlags.
  13205. //
  13206. // If the cert being built is only a dummy placeholder cert for speed it may not
  13207. // need to be signed. Signing of the cert is skipped if CERT_CREATE_SELFSIGN_NO_SIGN
  13208. // is specified in dwFlags.
  13209. //
  13210. //--------------------------------------------------------------------------
  13211. function CertCreateSelfSignCertificate(hProv: HCRYPTPROV;
  13212. pSubjectIssuerBlob: PCERT_NAME_BLOB; dwFlags: DWORD;
  13213. pKeyProvInfo: PCRYPT_KEY_PROV_INFO; pSignatureAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER;
  13214. pStartTime, pEndTime: PSYSTEMTIME; pExtensions: PCERT_EXTENSIONS): PCCERT_CONTEXT; stdcall;
  13215. {$EXTERNALSYM CertCreateSelfSignCertificate}
  13216. const
  13217. CERT_CREATE_SELFSIGN_NO_SIGN = 1;
  13218. {$EXTERNALSYM CERT_CREATE_SELFSIGN_NO_SIGN}
  13219. CERT_CREATE_SELFSIGN_NO_KEY_INFO = 2;
  13220. {$EXTERNALSYM CERT_CREATE_SELFSIGN_NO_KEY_INFO}
  13221. //+=========================================================================
  13222. // Key Identifier Property Data Structures and APIs
  13223. //==========================================================================
  13224. //+-------------------------------------------------------------------------
  13225. // Get the property for the specified Key Identifier.
  13226. //
  13227. // The Key Identifier is the SHA1 hash of the encoded CERT_PUBLIC_KEY_INFO.
  13228. // The Key Identifier for a certificate can be obtained by getting the
  13229. // certificate's CERT_KEY_IDENTIFIER_PROP_ID. The
  13230. // CryptCreateKeyIdentifierFromCSP API can be called to create the Key
  13231. // Identifier from a CSP Public Key Blob.
  13232. //
  13233. // A Key Identifier can have the same properties as a certificate context.
  13234. // CERT_KEY_PROV_INFO_PROP_ID is the property of most interest.
  13235. // For CERT_KEY_PROV_INFO_PROP_ID, pvData points to a CRYPT_KEY_PROV_INFO
  13236. // structure. Elements pointed to by fields in the pvData structure follow the
  13237. // structure. Therefore, *pcbData will exceed the size of the structure.
  13238. //
  13239. // If CRYPT_KEYID_ALLOC_FLAG is set, then, *pvData is updated with a
  13240. // pointer to allocated memory. LocalFree() must be called to free the
  13241. // allocated memory.
  13242. //
  13243. // By default, searches the CurrentUser's list of Key Identifiers.
  13244. // CRYPT_KEYID_MACHINE_FLAG can be set to search the LocalMachine's list
  13245. // of Key Identifiers. When CRYPT_KEYID_MACHINE_FLAG is set, pwszComputerName
  13246. // can also be set to specify the name of a remote computer to be searched
  13247. // instead of the local machine.
  13248. //--------------------------------------------------------------------------
  13249. function CryptGetKeyIdentifierProperty(pKeyIdentifier: PCRYPT_HASH_BLOB;
  13250. dwPropId: DWORD; dwFlags: DWORD; pwszComputerName: LPCWSTR; pvReserved: Pointer;
  13251. pvData: Pointer; var pcbData: DWORD): BOOL; stdcall;
  13252. {$EXTERNALSYM CryptGetKeyIdentifierProperty}
  13253. // When the following flag is set, searches the LocalMachine instead of the
  13254. // CurrentUser. This flag is applicable to all the KeyIdentifierProperty APIs.
  13255. const
  13256. CRYPT_KEYID_MACHINE_FLAG = $00000020;
  13257. {$EXTERNALSYM CRYPT_KEYID_MACHINE_FLAG}
  13258. // When the following flag is set, *pvData is updated with a pointer to
  13259. // allocated memory. LocalFree() must be called to free the allocated memory.
  13260. CRYPT_KEYID_ALLOC_FLAG = $00008000;
  13261. {$EXTERNALSYM CRYPT_KEYID_ALLOC_FLAG}
  13262. //+-------------------------------------------------------------------------
  13263. // Set the property for the specified Key Identifier.
  13264. //
  13265. // For CERT_KEY_PROV_INFO_PROP_ID pvData points to the
  13266. // CRYPT_KEY_PROV_INFO data structure. For all other properties, pvData
  13267. // points to a CRYPT_DATA_BLOB.
  13268. //
  13269. // Setting pvData == NULL, deletes the property.
  13270. //
  13271. // Set CRYPT_KEYID_MACHINE_FLAG to set the property for a LocalMachine
  13272. // Key Identifier. Set pwszComputerName, to select a remote computer.
  13273. //
  13274. // If CRYPT_KEYID_DELETE_FLAG is set, the Key Identifier and all its
  13275. // properties is deleted.
  13276. //
  13277. // If CRYPT_KEYID_SET_NEW_FLAG is set, the set fails if the property already
  13278. // exists. For an existing property, FALSE is returned with LastError set to
  13279. // CRYPT_E_EXISTS.
  13280. //--------------------------------------------------------------------------
  13281. function CryptSetKeyIdentifierProperty(pKeyIdentifier: PCRYPT_HASH_BLOB;
  13282. dwPropId: DWORD; dwFlags: DWORD; pwszComputerName: LPCWSTR; pvReserved: Pointer;
  13283. pvData: Pointer): BOOL; stdcall;
  13284. {$EXTERNALSYM CryptSetKeyIdentifierProperty}
  13285. // When the following flag is set, the Key Identifier and all its properties
  13286. // are deleted.
  13287. const
  13288. CRYPT_KEYID_DELETE_FLAG = $00000010;
  13289. {$EXTERNALSYM CRYPT_KEYID_DELETE_FLAG}
  13290. // When the following flag is set, the set fails if the property already
  13291. // exists.
  13292. CRYPT_KEYID_SET_NEW_FLAG = $00002000;
  13293. {$EXTERNALSYM CRYPT_KEYID_SET_NEW_FLAG}
  13294. //+-------------------------------------------------------------------------
  13295. // For CERT_KEY_PROV_INFO_PROP_ID, rgppvData[] points to a
  13296. // CRYPT_KEY_PROV_INFO.
  13297. //
  13298. // Return FALSE to stop the enumeration.
  13299. //--------------------------------------------------------------------------
  13300. type
  13301. PFN_CRYPT_ENUM_KEYID_PROP = function(pKeyIdentifier: PCRYPT_HASH_BLOB;
  13302. dwFlags: DWORD; pvReserved: Pointer; pvArg: Pointer; cProp: DWORD;
  13303. rgdwPropId: LPDWORD; rgpvData: Pointer; rgcbData: LPDWORD): BOOL; stdcall;
  13304. {$EXTERNALSYM PFN_CRYPT_ENUM_KEYID_PROP}
  13305. PFnCryptEnumKeyIdProp = PFN_CRYPT_ENUM_KEYID_PROP;
  13306. //+-------------------------------------------------------------------------
  13307. // Enumerate the Key Identifiers.
  13308. //
  13309. // If pKeyIdentifier is NULL, enumerates all Key Identifers. Otherwise,
  13310. // calls the callback for the specified KeyIdentifier. If dwPropId is
  13311. // 0, calls the callback with all the properties. Otherwise, only calls
  13312. // the callback with the specified property (cProp = 1).
  13313. // Furthermore, when dwPropId is specified, skips KeyIdentifiers not
  13314. // having the property.
  13315. //
  13316. // Set CRYPT_KEYID_MACHINE_FLAG to enumerate the LocalMachine
  13317. // Key Identifiers. Set pwszComputerName, to enumerate Key Identifiers on
  13318. // a remote computer.
  13319. //--------------------------------------------------------------------------
  13320. function CryptEnumKeyIdentifierProperties(pKeyIdentifier: PCRYPT_HASH_BLOB;
  13321. dwPropId: DWORD; dwFlags: DWORD; pwszComputerName: LPCWSTR; pvReserved: Pointer;
  13322. pvArg: Pointer; pfnEnum: PFN_CRYPT_ENUM_KEYID_PROP): BOOL; stdcall;
  13323. {$EXTERNALSYM CryptEnumKeyIdentifierProperties}
  13324. //+-------------------------------------------------------------------------
  13325. // Create a KeyIdentifier from the CSP Public Key Blob.
  13326. //
  13327. // Converts the CSP PUBLICKEYSTRUC into a X.509 CERT_PUBLIC_KEY_INFO and
  13328. // encodes. The encoded CERT_PUBLIC_KEY_INFO is SHA1 hashed to obtain
  13329. // the Key Identifier.
  13330. //
  13331. // By default, the pPubKeyStruc->aiKeyAlg is used to find the appropriate
  13332. // public key Object Identifier. pszPubKeyOID can be set to override
  13333. // the default OID obtained from the aiKeyAlg.
  13334. //--------------------------------------------------------------------------
  13335. function CryptCreateKeyIdentifierFromCSP(dwCertEncodingType: DWORD;
  13336. pszPubKeyOID: LPCSTR; pPubKeyStruc: PPUBLICKEYSTRUC; cbPubKeyStruc: DWORD;
  13337. dwFlags: DWORD; pvReserved: Pointer; pbHash: LPBYTE; pcbHash: DWORD): BOOL; stdcall;
  13338. {$EXTERNALSYM CryptCreateKeyIdentifierFromCSP}
  13339. //+=========================================================================
  13340. // Certificate Chaining Infrastructure
  13341. //==========================================================================
  13342. //
  13343. // The chain engine defines the store namespace and cache partitioning for
  13344. // the Certificate Chaining infrastructure. A default chain engine
  13345. // is defined for the process which uses all default system stores e.g.
  13346. // Root, CA, Trust, for chain building and caching. If an application
  13347. // wishes to define its own store namespace or have its own partitioned
  13348. // cache then it can create its own chain engine. It is advisable to create
  13349. // a chain engine at application startup and use it throughout the lifetime
  13350. // of the application in order to get optimal caching behavior
  13351. //
  13352. type
  13353. HCERTCHAINENGINE = HANDLE;
  13354. {$EXTERNALSYM HCERTCHAINENGINE}
  13355. const
  13356. HCCE_CURRENT_USER = HCERTCHAINENGINE(0);
  13357. {$EXTERNALSYM HCCE_CURRENT_USER}
  13358. HCCE_LOCAL_MACHINE = HCERTCHAINENGINE($1);
  13359. {$EXTERNALSYM HCCE_LOCAL_MACHINE}
  13360. //
  13361. // Create a certificate chain engine.
  13362. //
  13363. //
  13364. // Configuration parameters for the certificate chain engine
  13365. //
  13366. // hRestrictedRoot - restrict the root store (must be a subset of "Root")
  13367. //
  13368. // hRestrictedTrust - restrict the store for CTLs
  13369. //
  13370. // hRestrictedOther - restrict the store for certs and CRLs
  13371. //
  13372. // cAdditionalStore, rghAdditionalStore - additional stores
  13373. //
  13374. // NOTE: The algorithm used to define the stores for the engine is as
  13375. // follows:
  13376. //
  13377. // hRoot = hRestrictedRoot or System Store "Root"
  13378. //
  13379. // hTrust = hRestrictedTrust or hWorld (defined later)
  13380. //
  13381. // hOther = hRestrictedOther or (hRestrictedTrust == NULL) ? hWorld :
  13382. // hRestrictedTrust + hWorld
  13383. //
  13384. // hWorld = hRoot + "CA" + "My" + "Trust" + rghAdditionalStore
  13385. //
  13386. // dwFlags - flags
  13387. //
  13388. // CERT_CHAIN_CACHE_END_CERT - information will be cached on
  13389. // the end cert as well as the other
  13390. // certs in the chain
  13391. //
  13392. // CERT_CHAIN_THREAD_STORE_SYNC - use separate thread for store syncs
  13393. // and related cache updates
  13394. //
  13395. // CERT_CHAIN_CACHE_ONLY_URL_RETRIEVAL - don't hit the wire to get
  13396. // URL based objects
  13397. //
  13398. // dwUrlRetrievalTimeout - timeout for wire based URL object retrievals
  13399. //
  13400. const
  13401. CERT_CHAIN_CACHE_END_CERT = $00000001;
  13402. {$EXTERNALSYM CERT_CHAIN_CACHE_END_CERT}
  13403. CERT_CHAIN_THREAD_STORE_SYNC = $00000002;
  13404. {$EXTERNALSYM CERT_CHAIN_THREAD_STORE_SYNC}
  13405. CERT_CHAIN_CACHE_ONLY_URL_RETRIEVAL = $00000004;
  13406. {$EXTERNALSYM CERT_CHAIN_CACHE_ONLY_URL_RETRIEVAL}
  13407. CERT_CHAIN_USE_LOCAL_MACHINE_STORE = $00000008;
  13408. {$EXTERNALSYM CERT_CHAIN_USE_LOCAL_MACHINE_STORE}
  13409. CERT_CHAIN_ENABLE_CACHE_AUTO_UPDATE = $00000010;
  13410. {$EXTERNALSYM CERT_CHAIN_ENABLE_CACHE_AUTO_UPDATE}
  13411. type
  13412. PCERT_CHAIN_ENGINE_CONFIG = ^CERT_CHAIN_ENGINE_CONFIG;
  13413. {$EXTERNALSYM PCERT_CHAIN_ENGINE_CONFIG}
  13414. _CERT_CHAIN_ENGINE_CONFIG = record
  13415. cbSize: DWORD;
  13416. hRestrictedRoot: HCERTSTORE;
  13417. hRestrictedTrust: HCERTSTORE;
  13418. hRestrictedOther: HCERTSTORE;
  13419. cAdditionalStore: DWORD;
  13420. rghAdditionalStore: PHCERTSTORE;
  13421. dwFlags: DWORD;
  13422. dwUrlRetrievalTimeout: DWORD;
  13423. MaximumCachedCertificates: DWORD;
  13424. CycleDetectionModulus: DWORD;
  13425. end;
  13426. {$EXTERNALSYM _CERT_CHAIN_ENGINE_CONFIG}
  13427. CERT_CHAIN_ENGINE_CONFIG = _CERT_CHAIN_ENGINE_CONFIG;
  13428. {$EXTERNALSYM CERT_CHAIN_ENGINE_CONFIG}
  13429. TCertChainEngineConfig = CERT_CHAIN_ENGINE_CONFIG;
  13430. PCertChainEngineConfig = PCERT_CHAIN_ENGINE_CONFIG;
  13431. function CertCreateCertificateChainEngine(pConfig: PCERT_CHAIN_ENGINE_CONFIG;
  13432. var phChainEngine: HCERTCHAINENGINE): BOOL; stdcall;
  13433. {$EXTERNALSYM CertCreateCertificateChainEngine}
  13434. //
  13435. // Free a certificate trust engine
  13436. //
  13437. procedure CertFreeCertificateChainEngine(hChainEngine: HCERTCHAINENGINE); stdcall;
  13438. {$EXTERNALSYM CertFreeCertificateChainEngine}
  13439. //
  13440. // Resync the certificate chain engine. This resync's the stores backing
  13441. // the engine and updates the engine caches.
  13442. //
  13443. function CertResyncCertificateChainEngine(hChainEngine: HCERTCHAINENGINE): BOOL; stdcall;
  13444. {$EXTERNALSYM CertResyncCertificateChainEngine}
  13445. //
  13446. // When an application requests a certificate chain, the data structure
  13447. // returned is in the form of a CERT_CHAIN_CONTEXT. This contains
  13448. // an array of CERT_SIMPLE_CHAIN where each simple chain goes from
  13449. // an end cert to a self signed cert and the chain context connects simple
  13450. // chains via trust lists. Each simple chain contains the chain of
  13451. // certificates, summary trust information about the chain and trust information
  13452. // about each certificate element in the chain.
  13453. //
  13454. //
  13455. // Trust status bits
  13456. //
  13457. type
  13458. PCERT_TRUST_STATUS = ^CERT_TRUST_STATUS;
  13459. {$EXTERNALSYM PCERT_TRUST_STATUS}
  13460. _CERT_TRUST_STATUS = record
  13461. dwErrorStatus: DWORD;
  13462. dwInfoStatus: DWORD;
  13463. end;
  13464. {$EXTERNALSYM _CERT_TRUST_STATUS}
  13465. CERT_TRUST_STATUS = _CERT_TRUST_STATUS;
  13466. {$EXTERNALSYM CERT_TRUST_STATUS}
  13467. TCertTrustStatus = CERT_TRUST_STATUS;
  13468. PCertTrustStatus = PCERT_TRUST_STATUS;
  13469. //
  13470. // The following are error status bits
  13471. //
  13472. // These can be applied to certificates and chains
  13473. const
  13474. CERT_TRUST_NO_ERROR = $00000000;
  13475. {$EXTERNALSYM CERT_TRUST_NO_ERROR}
  13476. CERT_TRUST_IS_NOT_TIME_VALID = $00000001;
  13477. {$EXTERNALSYM CERT_TRUST_IS_NOT_TIME_VALID}
  13478. CERT_TRUST_IS_NOT_TIME_NESTED = $00000002;
  13479. {$EXTERNALSYM CERT_TRUST_IS_NOT_TIME_NESTED}
  13480. CERT_TRUST_IS_REVOKED = $00000004;
  13481. {$EXTERNALSYM CERT_TRUST_IS_REVOKED}
  13482. CERT_TRUST_IS_NOT_SIGNATURE_VALID = $00000008;
  13483. {$EXTERNALSYM CERT_TRUST_IS_NOT_SIGNATURE_VALID}
  13484. CERT_TRUST_IS_NOT_VALID_FOR_USAGE = $00000010;
  13485. {$EXTERNALSYM CERT_TRUST_IS_NOT_VALID_FOR_USAGE}
  13486. CERT_TRUST_IS_UNTRUSTED_ROOT = $00000020;
  13487. {$EXTERNALSYM CERT_TRUST_IS_UNTRUSTED_ROOT}
  13488. CERT_TRUST_REVOCATION_STATUS_UNKNOWN = $00000040;
  13489. {$EXTERNALSYM CERT_TRUST_REVOCATION_STATUS_UNKNOWN}
  13490. CERT_TRUST_IS_CYCLIC = $00000080;
  13491. {$EXTERNALSYM CERT_TRUST_IS_CYCLIC}
  13492. // These can be applied to chains only
  13493. CERT_TRUST_IS_PARTIAL_CHAIN = $00010000;
  13494. {$EXTERNALSYM CERT_TRUST_IS_PARTIAL_CHAIN}
  13495. CERT_TRUST_CTL_IS_NOT_TIME_VALID = $00020000;
  13496. {$EXTERNALSYM CERT_TRUST_CTL_IS_NOT_TIME_VALID}
  13497. CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID = $00040000;
  13498. {$EXTERNALSYM CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID}
  13499. CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE = $00080000;
  13500. {$EXTERNALSYM CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE}
  13501. //
  13502. // The following are info status bits
  13503. //
  13504. // These can be applied to certificates only
  13505. CERT_TRUST_HAS_EXACT_MATCH_ISSUER = $00000001;
  13506. {$EXTERNALSYM CERT_TRUST_HAS_EXACT_MATCH_ISSUER}
  13507. CERT_TRUST_HAS_KEY_MATCH_ISSUER = $00000002;
  13508. {$EXTERNALSYM CERT_TRUST_HAS_KEY_MATCH_ISSUER}
  13509. CERT_TRUST_HAS_NAME_MATCH_ISSUER = $00000004;
  13510. {$EXTERNALSYM CERT_TRUST_HAS_NAME_MATCH_ISSUER}
  13511. CERT_TRUST_IS_SELF_SIGNED = $00000008;
  13512. {$EXTERNALSYM CERT_TRUST_IS_SELF_SIGNED}
  13513. // These can be applied to chains only
  13514. CERT_TRUST_IS_COMPLEX_CHAIN = $00010000;
  13515. {$EXTERNALSYM CERT_TRUST_IS_COMPLEX_CHAIN}
  13516. //
  13517. // Each certificate context in a simple chain has a corresponding chain element
  13518. // in the simple chain context
  13519. //
  13520. // dwErrorStatus has CERT_TRUST_IS_REVOKED, pRevocationInfo set
  13521. // dwErrorStatus has CERT_TRUST_REVOCATION_STATUS_UNKNOWN, pRevocationInfo set
  13522. //
  13523. // BUGBUG: Note that the post processing revocation supported in the first
  13524. // version only sets cbSize and dwRevocationResult. Everything else
  13525. // is NULL
  13526. //
  13527. //
  13528. // Revocation Information
  13529. //
  13530. type
  13531. PCERT_REVOCATION_INFO = ^CERT_REVOCATION_INFO;
  13532. {$EXTERNALSYM PCERT_REVOCATION_INFO}
  13533. _CERT_REVOCATION_INFO = record
  13534. cbSize: DWORD;
  13535. dwRevocationResult: DWORD;
  13536. pszRevocationOid: LPCSTR;
  13537. pvOidSpecificInfo: LPVOID;
  13538. end;
  13539. {$EXTERNALSYM _CERT_REVOCATION_INFO}
  13540. CERT_REVOCATION_INFO = _CERT_REVOCATION_INFO;
  13541. {$EXTERNALSYM CERT_REVOCATION_INFO}
  13542. TCertRevocationInfo = CERT_REVOCATION_INFO;
  13543. PCertRevocationInfo = PCERT_REVOCATION_INFO;
  13544. //
  13545. // Trust List Information
  13546. //
  13547. PCERT_TRUST_LIST_INFO = ^CERT_TRUST_LIST_INFO;
  13548. {$EXTERNALSYM PCERT_TRUST_LIST_INFO}
  13549. _CERT_TRUST_LIST_INFO = record
  13550. cbSize: DWORD;
  13551. pCtlEntry: PCTL_ENTRY;
  13552. pCtlContext: PCCTL_CONTEXT;
  13553. end;
  13554. {$EXTERNALSYM _CERT_TRUST_LIST_INFO}
  13555. CERT_TRUST_LIST_INFO = _CERT_TRUST_LIST_INFO;
  13556. {$EXTERNALSYM CERT_TRUST_LIST_INFO}
  13557. TCertTrustListInfo = CERT_TRUST_LIST_INFO;
  13558. PCertTrustListInfo = PCERT_TRUST_LIST_INFO;
  13559. //
  13560. // Chain Element
  13561. //
  13562. PCERT_CHAIN_ELEMENT = ^CERT_CHAIN_ELEMENT;
  13563. {$EXTERNALSYM PCERT_CHAIN_ELEMENT}
  13564. _CERT_CHAIN_ELEMENT = record
  13565. cbSize: DWORD;
  13566. pCertContext: PCCERT_CONTEXT;
  13567. TrustStatus: CERT_TRUST_STATUS;
  13568. pRevocationInfo: PCERT_REVOCATION_INFO;
  13569. end;
  13570. {$EXTERNALSYM _CERT_CHAIN_ELEMENT}
  13571. CERT_CHAIN_ELEMENT = _CERT_CHAIN_ELEMENT;
  13572. {$EXTERNALSYM CERT_CHAIN_ELEMENT}
  13573. TCertChainElement = CERT_CHAIN_ELEMENT;
  13574. PCertChainElement = PCERT_CHAIN_ELEMENT;
  13575. //
  13576. // The simple chain is an array of chain elements and a summary trust status
  13577. // for the chain
  13578. //
  13579. // rgpElements[0] is the end certificate chain element
  13580. //
  13581. // rgpElements[cElement-1] is the self-signed "root" certificate chain element
  13582. //
  13583. PCERT_SIMPLE_CHAIN = ^CERT_SIMPLE_CHAIN;
  13584. {$EXTERNALSYM PCERT_SIMPLE_CHAIN}
  13585. _CERT_SIMPLE_CHAIN = record
  13586. cbSize: DWORD;
  13587. TrustStatus: CERT_TRUST_STATUS;
  13588. cElement: DWORD;
  13589. rgpElement: PCERT_CHAIN_ELEMENT;
  13590. pTrustListInfo: PCERT_TRUST_LIST_INFO;
  13591. end;
  13592. {$EXTERNALSYM _CERT_SIMPLE_CHAIN}
  13593. CERT_SIMPLE_CHAIN = _CERT_SIMPLE_CHAIN;
  13594. {$EXTERNALSYM CERT_SIMPLE_CHAIN}
  13595. TCertSimpleChain = CERT_SIMPLE_CHAIN;
  13596. PCertSimpleChain = PCERT_SIMPLE_CHAIN;
  13597. //
  13598. // And the chain context contains an array of simple chains and summary trust
  13599. // status for all the connected simple chains
  13600. //
  13601. // rgpChains[0] is the end certificate simple chain
  13602. //
  13603. // rgpChains[cChain-1] is the final (possibly trust list signer) chain which
  13604. // ends in a certificate which is contained in the root store
  13605. //
  13606. PCERT_CHAIN_CONTEXT = ^CERT_CHAIN_CONTEXT;
  13607. {$EXTERNALSYM PCERT_CHAIN_CONTEXT}
  13608. _CERT_CHAIN_CONTEXT = record
  13609. cbSize: DWORD;
  13610. TrustStatus: CERT_TRUST_STATUS;
  13611. cChain: DWORD;
  13612. rgpChain: PCERT_SIMPLE_CHAIN;
  13613. end;
  13614. {$EXTERNALSYM _CERT_CHAIN_CONTEXT}
  13615. CERT_CHAIN_CONTEXT = _CERT_CHAIN_CONTEXT;
  13616. {$EXTERNALSYM CERT_CHAIN_CONTEXT}
  13617. TCertChainContext = CERT_CHAIN_CONTEXT;
  13618. PCertChainContext = PCERT_CHAIN_CONTEXT;
  13619. PCCERT_CHAIN_CONTEXT = ^CERT_CHAIN_CONTEXT;
  13620. {$EXTERNALSYM PCCERT_CHAIN_CONTEXT}
  13621. PPCCERT_CHAIN_CONTEXT = ^PCERT_CHAIN_CONTEXT;
  13622. {$NODEFINE PPCCERT_CHAIN_CONTEXT}
  13623. //
  13624. // When building a chain, the there are various parameters used for finding
  13625. // issuing certificates and trust lists. They are identified in the
  13626. // following structure
  13627. //
  13628. // Default usage match type is AND with value zero
  13629. const
  13630. USAGE_MATCH_TYPE_AND = $00000000;
  13631. {$EXTERNALSYM USAGE_MATCH_TYPE_AND}
  13632. USAGE_MATCH_TYPE_OR = $00000001;
  13633. {$EXTERNALSYM USAGE_MATCH_TYPE_OR}
  13634. type
  13635. PCERT_USAGE_MATCH = ^CERT_USAGE_MATCH;
  13636. {$EXTERNALSYM PCERT_USAGE_MATCH}
  13637. _CERT_USAGE_MATCH = record
  13638. dwType: DWORD;
  13639. Usage: CERT_ENHKEY_USAGE;
  13640. end;
  13641. {$EXTERNALSYM _CERT_USAGE_MATCH}
  13642. CERT_USAGE_MATCH = _CERT_USAGE_MATCH;
  13643. {$EXTERNALSYM CERT_USAGE_MATCH}
  13644. TCertUsageMatch = CERT_USAGE_MATCH;
  13645. PCertUsageMatch = PCERT_USAGE_MATCH;
  13646. PCTL_USAGE_MATCH = ^CTL_USAGE_MATCH;
  13647. {$EXTERNALSYM PCTL_USAGE_MATCH}
  13648. _CTL_USAGE_MATCH = record
  13649. dwType: DWORD;
  13650. Usage: CTL_USAGE;
  13651. end;
  13652. {$EXTERNALSYM _CTL_USAGE_MATCH}
  13653. CTL_USAGE_MATCH = _CTL_USAGE_MATCH;
  13654. {$EXTERNALSYM CTL_USAGE_MATCH}
  13655. TCtlUsageMatch = CTL_USAGE_MATCH;
  13656. PCtlUsageMatch = PCTL_USAGE_MATCH;
  13657. PCERT_CHAIN_PARA = ^CERT_CHAIN_PARA;
  13658. {$EXTERNALSYM PCERT_CHAIN_PARA}
  13659. _CERT_CHAIN_PARA = record
  13660. cbSize: DWORD;
  13661. RequestedUsage: CERT_USAGE_MATCH;
  13662. end;
  13663. {$EXTERNALSYM _CERT_CHAIN_PARA}
  13664. CERT_CHAIN_PARA = _CERT_CHAIN_PARA;
  13665. {$EXTERNALSYM CERT_CHAIN_PARA}
  13666. TCertChainPara = CERT_CHAIN_PARA;
  13667. PCertChainPara = PCERT_CHAIN_PARA;
  13668. //
  13669. // The following API is used for retrieving certificate chains
  13670. //
  13671. // Parameters:
  13672. //
  13673. // hChainEngine - the chain engine (namespace and cache) to use, NULL
  13674. // mean use the default chain engine
  13675. //
  13676. // pCertContext - the context we are retrieving the chain for, it
  13677. // will be the zero index element in the chain
  13678. //
  13679. // pTime - the point in time that we want the chain validated
  13680. // for. Note that the time does not affect trust list,
  13681. // revocation, or root store checking. NULL means use
  13682. // the current system time
  13683. //
  13684. // hAdditionalStore - additional store to use when looking up objects
  13685. //
  13686. // pChainPara - parameters for chain building
  13687. //
  13688. // dwFlags - flags such as should revocation checking be done
  13689. // on the chain?
  13690. //
  13691. // pvReserved - reserved parameter, must be NULL
  13692. //
  13693. // ppChainContext - chain context returned
  13694. //
  13695. // CERT_CHAIN_CACHE_END_CERT can be used here as well
  13696. // Revocation flags are in the high nibble
  13697. const
  13698. CERT_CHAIN_REVOCATION_CHECK_END_CERT = $10000000;
  13699. {$EXTERNALSYM CERT_CHAIN_REVOCATION_CHECK_END_CERT}
  13700. CERT_CHAIN_REVOCATION_CHECK_CHAIN = $20000000;
  13701. {$EXTERNALSYM CERT_CHAIN_REVOCATION_CHECK_CHAIN}
  13702. CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT = $40000000;
  13703. {$EXTERNALSYM CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT}
  13704. CERT_CHAIN_REVOCATION_CHECK_CACHE_ONLY = DWORD($80000000);
  13705. {$EXTERNALSYM CERT_CHAIN_REVOCATION_CHECK_CACHE_ONLY}
  13706. function CertGetCertificateChain(hChainEngine: HCERTCHAINENGINE;
  13707. pCertContext: PCCERT_CONTEXT; pTime: LPFILETIME; hAdditionalStore: HCERTSTORE;
  13708. pChainPara: PCERT_CHAIN_PARA; dwFlags: DWORD; pvReserved: LPVOID;
  13709. ppChainContext: PPCCERT_CHAIN_CONTEXT): BOOL; stdcall;
  13710. {$EXTERNALSYM CertGetCertificateChain}
  13711. //
  13712. // Free a certificate chain
  13713. //
  13714. procedure CertFreeCertificateChain(pChainContext: PCCERT_CHAIN_CONTEXT); stdcall;
  13715. {$EXTERNALSYM CertFreeCertificateChain}
  13716. //
  13717. // Duplicate (add a reference to) a certificate chain
  13718. //
  13719. function CertDuplicateCertificateChain(pChainContext: PCCERT_CHAIN_CONTEXT): PCCERT_CHAIN_CONTEXT; stdcall;
  13720. {$EXTERNALSYM CertDuplicateCertificateChain}
  13721. //
  13722. // Specific Revocation Type OID and structure definitions
  13723. //
  13724. //
  13725. // CRL Revocation OID
  13726. //
  13727. const
  13728. REVOCATION_OID_CRL_REVOCATION = LPCSTR(1);
  13729. {$EXTERNALSYM REVOCATION_OID_CRL_REVOCATION}
  13730. //
  13731. // For the CRL revocation OID the pvRevocationPara is NULL
  13732. //
  13733. //
  13734. // CRL Revocation Info
  13735. //
  13736. type
  13737. PCRL_REVOCATION_INFO = ^CRL_REVOCATION_INFO;
  13738. {$EXTERNALSYM PCRL_REVOCATION_INFO}
  13739. _CRL_REVOCATION_INFO = record
  13740. pCrlEntry: PCRL_ENTRY;
  13741. pCrlContext: PCCRL_CONTEXT;
  13742. pCrlIssuerChain: PCCERT_CHAIN_CONTEXT;
  13743. end;
  13744. {$EXTERNALSYM _CRL_REVOCATION_INFO}
  13745. CRL_REVOCATION_INFO = _CRL_REVOCATION_INFO;
  13746. {$EXTERNALSYM CRL_REVOCATION_INFO}
  13747. TCrlRevocationInfo = CRL_REVOCATION_INFO;
  13748. PCrlRevocationInfo = PCRL_REVOCATION_INFO;
  13749. //+-------------------------------------------------------------------------
  13750. // Find the first or next certificate chain context in the store.
  13751. //
  13752. // The chain context is found according to the dwFindFlags, dwFindType and
  13753. // its pvFindPara. See below for a list of the find types and its parameters.
  13754. //
  13755. // If the first or next chain context isn't found, NULL is returned.
  13756. // Otherwise, a pointer to a read only CERT_CHAIN_CONTEXT is returned.
  13757. // CERT_CHAIN_CONTEXT must be freed by calling CertFreeCertificateChain
  13758. // or is freed when passed as the
  13759. // pPrevChainContext on a subsequent call. CertDuplicateCertificateChain
  13760. // can be called to make a duplicate.
  13761. //
  13762. // pPrevChainContext MUST BE NULL on the first
  13763. // call to find the chain context. To find the next chain context, the
  13764. // pPrevChainContext is set to the CERT_CHAIN_CONTEXT returned by a previous
  13765. // call.
  13766. //
  13767. // NOTE: a NON-NULL pPrevChainContext is always CertFreeCertificateChain'ed by
  13768. // this function, even for an error.
  13769. //--------------------------------------------------------------------------
  13770. function CertFindChainInStore(hCertStore: HCERTSTORE; dwCertEncodingType: DWORD;
  13771. dwFindFlags: DWORD; dwFindType: DWORD; pvFindPara: Pointer;
  13772. pPrevChainContext: PCCERT_CHAIN_CONTEXT): PCCERT_CHAIN_CONTEXT; stdcall;
  13773. {$EXTERNALSYM CertFindChainInStore}
  13774. const
  13775. CERT_CHAIN_FIND_BY_ISSUER = 1;
  13776. {$EXTERNALSYM CERT_CHAIN_FIND_BY_ISSUER}
  13777. //+-------------------------------------------------------------------------
  13778. // CERT_CHAIN_FIND_BY_ISSUER
  13779. //
  13780. // Find a certificate chain having a private key for the end certificate and
  13781. // matching one of the given issuer names. A matching dwKeySpec and
  13782. // enhanced key usage can also be specified. Additionally a callback can
  13783. // be provided for even more caller provided filtering before building the
  13784. // chain.
  13785. //
  13786. // By default, only the issuers in the first simple chain are compared
  13787. // for a name match. CERT_CHAIN_FIND_BY_ISSUER_COMPLEX_CHAIN_FLAG can
  13788. // be set in dwFindFlags to match issuers in all the simple chains.
  13789. //
  13790. // CERT_CHAIN_FIND_BY_ISSUER_NO_KEY_FLAG can be set in dwFindFlags to
  13791. // not check if the end certificate has a private key.
  13792. //
  13793. // CERT_CHAIN_FIND_BY_ISSUER_COMPARE_KEY_FLAG can be set in dwFindFlags
  13794. // to compare the public key in the end certificate with the crypto
  13795. // provider's public key. The dwAcquirePrivateKeyFlags can be set
  13796. // in CERT_CHAIN_FIND_BY_ISSUER_PARA to enable caching of the private key's
  13797. // HKEY returned by the CSP.
  13798. //
  13799. // If dwCertEncodingType == 0, defaults to X509_ASN_ENCODING for the
  13800. // array of encoded issuer names.
  13801. //
  13802. // By default, the hCertStore passed to CertFindChainInStore, is passed
  13803. // as an additional store to CertGetCertificateChain.
  13804. // CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_FLAG can be set in dwFindFlags
  13805. // to improve performance by only searching the cached system stores
  13806. // (root, my, ca, trust) to find the issuer certificates. If you are doing
  13807. // a find in the "my" system store, than, this flag should be set to
  13808. // improve performance.
  13809. //
  13810. // Setting CERT_CHAIN_FIND_BY_ISSUER_LOCAL_MACHINE_FLAG in dwFindFlags
  13811. // restricts CertGetCertificateChain to search the Local Machine
  13812. // cached system stores instead of the Current User's.
  13813. //
  13814. // Setting CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_URL_FLAG in dwFindFlags
  13815. // restricts CertGetCertificateChain to only search the URL cache
  13816. // and not hit the wire.
  13817. //--------------------------------------------------------------------------
  13818. // Returns FALSE to skip this certificate. Otherwise, returns TRUE to
  13819. // build a chain for this certificate.
  13820. type
  13821. PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK = function(pCert: PCCERT_CONTEXT;
  13822. pvFindArg: Pointer): BOOL; stdcall;
  13823. {$EXTERNALSYM PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK}
  13824. PFnCertChainFindByIssuerCallback = PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK;
  13825. PCERT_CHAIN_FIND_BY_ISSUER_PARA = ^CERT_CHAIN_FIND_BY_ISSUER_PARA;
  13826. {$EXTERNALSYM PCERT_CHAIN_FIND_BY_ISSUER_PARA}
  13827. _CERT_CHAIN_FIND_BY_ISSUER_PARA = record
  13828. cbSize: DWORD;
  13829. // If pszUsageIdentifier == NULL, matches any usage.
  13830. pszUsageIdentifier: LPCSTR;
  13831. // If dwKeySpec == 0, matches any KeySpec
  13832. dwKeySpec: DWORD;
  13833. // When CERT_CHAIN_FIND_BY_ISSUER_COMPARE_KEY_FLAG is set in dwFindFlags,
  13834. // CryptAcquireCertificatePrivateKey is called to do the public key
  13835. // comparison. The following flags can be set to enable caching
  13836. // of the acquired private key. See the API for more details on these
  13837. // flags.
  13838. dwAcquirePrivateKeyFlags: DWORD;
  13839. // Pointer to an array of X509, ASN.1 encoded issuer name blobs. If
  13840. // cIssuer == 0, matches any issuer
  13841. cIssuer: DWORD;
  13842. rgIssuer: PCERT_NAME_BLOB;
  13843. // If NULL or Callback returns TRUE, builds the chain for the end
  13844. // certificate having a private key with the specified KeySpec and
  13845. // enhanced key usage.
  13846. pfnFindCallback: PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK;
  13847. pvFindArg: Pointer;
  13848. end;
  13849. {$EXTERNALSYM _CERT_CHAIN_FIND_BY_ISSUER_PARA}
  13850. CERT_CHAIN_FIND_BY_ISSUER_PARA = _CERT_CHAIN_FIND_BY_ISSUER_PARA;
  13851. {$EXTERNALSYM CERT_CHAIN_FIND_BY_ISSUER_PARA}
  13852. TCertChainFindByIssuerPara = CERT_CHAIN_FIND_BY_ISSUER_PARA;
  13853. PCertChainFindByIssuerPara = PCERT_CHAIN_FIND_BY_ISSUER_PARA;
  13854. // The following dwFindFlags can be set for CERT_CHAIN_FIND_BY_ISSUER
  13855. // If set, compares the public key in the end certificate with the crypto
  13856. // provider's public key. This comparison is the last check made on the
  13857. // build chain.
  13858. const
  13859. CERT_CHAIN_FIND_BY_ISSUER_COMPARE_KEY_FLAG = $0001;
  13860. {$EXTERNALSYM CERT_CHAIN_FIND_BY_ISSUER_COMPARE_KEY_FLAG}
  13861. // If not set, only checks the first simple chain for an issuer name match.
  13862. // When set, also checks second and subsequent simple chains.
  13863. CERT_CHAIN_FIND_BY_ISSUER_COMPLEX_CHAIN_FLAG = $0002;
  13864. {$EXTERNALSYM CERT_CHAIN_FIND_BY_ISSUER_COMPLEX_CHAIN_FLAG}
  13865. // If set, CertGetCertificateChain only searches the URL cache and
  13866. // doesn't hit the wire.
  13867. CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_URL_FLAG = $0004;
  13868. {$EXTERNALSYM CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_URL_FLAG}
  13869. // If set, CertGetCertificateChain only opens the Local Machine
  13870. // certificate stores instead of the Current User's.
  13871. CERT_CHAIN_FIND_BY_ISSUER_LOCAL_MACHINE_FLAG = $0008;
  13872. {$EXTERNALSYM CERT_CHAIN_FIND_BY_ISSUER_LOCAL_MACHINE_FLAG}
  13873. // If set, no check is made to see if the end certificate has a private
  13874. // key associated with it.
  13875. CERT_CHAIN_FIND_BY_ISSUER_NO_KEY_FLAG = $4000;
  13876. {$EXTERNALSYM CERT_CHAIN_FIND_BY_ISSUER_NO_KEY_FLAG}
  13877. // By default, the hCertStore passed to CertFindChainInStore, is passed
  13878. // as the additional store to CertGetCertificateChain. This flag can be
  13879. // set to improve performance by only searching the cached system stores
  13880. // (root, my, ca, trust) to find the issuer certificates. If not set, then,
  13881. // the hCertStore is always searched in addition to the cached system
  13882. // stores.
  13883. CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_FLAG = $8000;
  13884. {$EXTERNALSYM CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_FLAG}
  13885. //+=========================================================================
  13886. // Certificate Chain Policy Data Structures and APIs
  13887. //==========================================================================
  13888. type
  13889. PCERT_CHAIN_POLICY_PARA = ^CERT_CHAIN_POLICY_PARA;
  13890. {$EXTERNALSYM PCERT_CHAIN_POLICY_PARA}
  13891. _CERT_CHAIN_POLICY_PARA = record
  13892. cbSize: DWORD;
  13893. dwFlags: DWORD;
  13894. pvExtraPolicyPara: Pointer; // pszPolicyOID specific
  13895. end;
  13896. {$EXTERNALSYM _CERT_CHAIN_POLICY_PARA}
  13897. CERT_CHAIN_POLICY_PARA = _CERT_CHAIN_POLICY_PARA;
  13898. {$EXTERNALSYM CERT_CHAIN_POLICY_PARA}
  13899. TCertChainPolicyPara = CERT_CHAIN_POLICY_PARA;
  13900. PCertChainPolicyPara = PCERT_CHAIN_POLICY_PARA;
  13901. // If both lChainIndex and lElementIndex are set to -1, the dwError applies
  13902. // to the whole chain context. If only lElementIndex is set to -1, the
  13903. // dwError applies to the lChainIndex'ed chain. Otherwise, the dwError applies
  13904. // to the certificate element at
  13905. // pChainContext->rgpChain[lChainIndex]->rgpElement[lElementIndex].
  13906. PCERT_CHAIN_POLICY_STATUS = ^CERT_CHAIN_POLICY_STATUS;
  13907. {$EXTERNALSYM PCERT_CHAIN_POLICY_STATUS}
  13908. _CERT_CHAIN_POLICY_STATUS = record
  13909. cbSize: DWORD;
  13910. dwError: DWORD;
  13911. lChainIndex: LONG;
  13912. lElementIndex: LONG;
  13913. pvExtraPolicyStatus: Pointer; // pszPolicyOID specific
  13914. end;
  13915. {$EXTERNALSYM _CERT_CHAIN_POLICY_STATUS}
  13916. CERT_CHAIN_POLICY_STATUS = _CERT_CHAIN_POLICY_STATUS;
  13917. {$EXTERNALSYM CERT_CHAIN_POLICY_STATUS}
  13918. TCertChainPolicyStatus = CERT_CHAIN_POLICY_STATUS;
  13919. PCertChainPolicyStatus = PCERT_CHAIN_POLICY_STATUS;
  13920. // Common chain policy flags
  13921. const
  13922. CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG = $00000001;
  13923. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG}
  13924. CERT_CHAIN_POLICY_IGNORE_CTL_NOT_TIME_VALID_FLAG = $00000002;
  13925. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_CTL_NOT_TIME_VALID_FLAG}
  13926. CERT_CHAIN_POLICY_IGNORE_NOT_TIME_NESTED_FLAG = $00000004;
  13927. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_NOT_TIME_NESTED_FLAG}
  13928. CERT_CHAIN_POLICY_IGNORE_ALL_NOT_TIME_VALID_FLAGS = (
  13929. CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG or
  13930. CERT_CHAIN_POLICY_IGNORE_CTL_NOT_TIME_VALID_FLAG or
  13931. CERT_CHAIN_POLICY_IGNORE_NOT_TIME_NESTED_FLAG);
  13932. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_ALL_NOT_TIME_VALID_FLAGS}
  13933. CERT_CHAIN_POLICY_ALLOW_UNKNOWN_CA_FLAG = $00000010;
  13934. {$EXTERNALSYM CERT_CHAIN_POLICY_ALLOW_UNKNOWN_CA_FLAG}
  13935. CERT_CHAIN_POLICY_IGNORE_WRONG_USAGE_FLAG = $00000020;
  13936. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_WRONG_USAGE_FLAG}
  13937. CERT_CHAIN_POLICY_IGNORE_END_REV_UNKNOWN_FLAG = $00000100;
  13938. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_END_REV_UNKNOWN_FLAG}
  13939. CERT_CHAIN_POLICY_IGNORE_CTL_SIGNER_REV_UNKNOWN_FLAG = $00000200;
  13940. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_CTL_SIGNER_REV_UNKNOWN_FLAG}
  13941. CERT_CHAIN_POLICY_IGNORE_CA_REV_UNKNOWN_FLAG = $00000400;
  13942. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_CA_REV_UNKNOWN_FLAG}
  13943. CERT_CHAIN_POLICY_IGNORE_ROOT_REV_UNKNOWN_FLAG = $00000800;
  13944. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_ROOT_REV_UNKNOWN_FLAG}
  13945. CERT_CHAIN_POLICY_IGNORE_ALL_REV_UNKNOWN_FLAGS = (
  13946. CERT_CHAIN_POLICY_IGNORE_END_REV_UNKNOWN_FLAG or
  13947. CERT_CHAIN_POLICY_IGNORE_CTL_SIGNER_REV_UNKNOWN_FLAG or
  13948. CERT_CHAIN_POLICY_IGNORE_CA_REV_UNKNOWN_FLAG or
  13949. CERT_CHAIN_POLICY_IGNORE_ROOT_REV_UNKNOWN_FLAG);
  13950. {$EXTERNALSYM CERT_CHAIN_POLICY_IGNORE_ALL_REV_UNKNOWN_FLAGS}
  13951. CERT_CHAIN_POLICY_ALLOW_TESTROOT_FLAG = $00008000;
  13952. {$EXTERNALSYM CERT_CHAIN_POLICY_ALLOW_TESTROOT_FLAG}
  13953. CERT_CHAIN_POLICY_TRUST_TESTROOT_FLAG = $00004000;
  13954. {$EXTERNALSYM CERT_CHAIN_POLICY_TRUST_TESTROOT_FLAG}
  13955. //+-------------------------------------------------------------------------
  13956. // Verify that the certificate chain satisfies the specified policy
  13957. // requirements. If we were able to verify the chain policy, TRUE is returned
  13958. // and the dwError field of the pPolicyStatus is updated. A dwError of 0
  13959. // (ERROR_SUCCESS, S_OK) indicates the chain satisfies the specified policy.
  13960. //
  13961. // If dwError applies to the entire chain context, both lChainIndex and
  13962. // lElementIndex are set to -1. If dwError applies to a simple chain,
  13963. // lElementIndex is set to -1 and lChainIndex is set to the index of the
  13964. // first offending chain having the error. If dwError applies to a
  13965. // certificate element, lChainIndex and lElementIndex are updated to
  13966. // index the first offending certificate having the error, where, the
  13967. // the certificate element is at:
  13968. // pChainContext->rgpChain[lChainIndex]->rgpElement[lElementIndex].
  13969. //
  13970. // The dwFlags in pPolicyPara can be set to change the default policy checking
  13971. // behaviour. In addition, policy specific parameters can be passed in
  13972. // the pvExtraPolicyPara field of pPolicyPara.
  13973. //
  13974. // In addition to returning dwError, in pPolicyStatus, policy OID specific
  13975. // extra status may be returned via pvExtraPolicyStatus.
  13976. //--------------------------------------------------------------------------
  13977. function CertVerifyCertificateChainPolicy(pszPolicyOID: LPCSTR;
  13978. pChainContext: PCCERT_CHAIN_CONTEXT; pPolicyPara: PCERT_CHAIN_POLICY_PARA;
  13979. pPolicyStatus: PCERT_CHAIN_POLICY_STATUS): BOOL; stdcall;
  13980. {$EXTERNALSYM CertVerifyCertificateChainPolicy}
  13981. // Predefined OID Function Names
  13982. const
  13983. CRYPT_OID_VERIFY_CERTIFICATE_CHAIN_POLICY_FUNC = 'CertDllVerifyCertificateChainPolicy';
  13984. {$EXTERNALSYM CRYPT_OID_VERIFY_CERTIFICATE_CHAIN_POLICY_FUNC}
  13985. // CertDllVerifyCertificateChainPolicy has same function signature as
  13986. // CertVerifyCertificateChainPolicy.
  13987. //+-------------------------------------------------------------------------
  13988. // Predefined verify chain policies
  13989. //--------------------------------------------------------------------------
  13990. CERT_CHAIN_POLICY_BASE = LPCSTR(1);
  13991. {$EXTERNALSYM CERT_CHAIN_POLICY_BASE}
  13992. CERT_CHAIN_POLICY_AUTHENTICODE = LPCSTR(2);
  13993. {$EXTERNALSYM CERT_CHAIN_POLICY_AUTHENTICODE}
  13994. CERT_CHAIN_POLICY_AUTHENTICODE_TS = LPCSTR(3);
  13995. {$EXTERNALSYM CERT_CHAIN_POLICY_AUTHENTICODE_TS}
  13996. CERT_CHAIN_POLICY_SSL = LPCSTR(4);
  13997. {$EXTERNALSYM CERT_CHAIN_POLICY_SSL}
  13998. CERT_CHAIN_POLICY_BASIC_CONSTRAINTS = LPCSTR(5);
  13999. {$EXTERNALSYM CERT_CHAIN_POLICY_BASIC_CONSTRAINTS}
  14000. CERT_CHAIN_POLICY_NT_AUTH = LPCSTR(6);
  14001. {$EXTERNALSYM CERT_CHAIN_POLICY_NT_AUTH}
  14002. //+-------------------------------------------------------------------------
  14003. // CERT_CHAIN_POLICY_BASE
  14004. //
  14005. // Implements the base chain policy verification checks. dwFlags can
  14006. // be set in pPolicyPara to alter the default policy checking behaviour.
  14007. //--------------------------------------------------------------------------
  14008. //+-------------------------------------------------------------------------
  14009. // CERT_CHAIN_POLICY_AUTHENTICODE
  14010. //
  14011. // Implements the Authenticode chain policy verification checks.
  14012. //
  14013. // pvExtraPolicyPara may optionally be set to point to the following
  14014. // AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA.
  14015. //
  14016. // pvExtraPolicyStatus may optionally be set to point to the following
  14017. // AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS.
  14018. //--------------------------------------------------------------------------
  14019. // dwRegPolicySettings are defined in wintrust.h
  14020. type
  14021. PAUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA = ^AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA;
  14022. {$EXTERNALSYM PAUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA}
  14023. _AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA = record
  14024. cbSize: DWORD;
  14025. dwRegPolicySettings: DWORD;
  14026. pSignerInfo: PCMSG_SIGNER_INFO; // optional
  14027. end;
  14028. {$EXTERNALSYM _AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA}
  14029. AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA = _AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA;
  14030. {$EXTERNALSYM AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA}
  14031. TAuthenticodeExtraCertChainPolicyPara = AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA;
  14032. PAuthenticodeExtraCertChainPolicyPara = PAUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA;
  14033. PAUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS = ^AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS;
  14034. {$EXTERNALSYM PAUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS}
  14035. _AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS = record
  14036. cbSize: DWORD;
  14037. fCommercial: BOOL; // obtained from signer statement
  14038. end;
  14039. {$EXTERNALSYM _AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS}
  14040. AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS = _AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS;
  14041. {$EXTERNALSYM AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS}
  14042. TAuthenticodeExtraCertChainPolicyStatus = AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS;
  14043. PAuthenticodeExtraCertChainPolicyStatus = PAUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS;
  14044. //+-------------------------------------------------------------------------
  14045. // CERT_CHAIN_POLICY_AUTHENTICODE_TS
  14046. //
  14047. // Implements the Authenticode Time Stamp chain policy verification checks.
  14048. //
  14049. // pvExtraPolicyPara may optionally be set to point to the following
  14050. // AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA.
  14051. //
  14052. // pvExtraPolicyStatus isn't used and must be set to NULL.
  14053. //--------------------------------------------------------------------------
  14054. // dwRegPolicySettings are defined in wintrust.h
  14055. PAUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA = ^AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA;
  14056. {$EXTERNALSYM PAUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA}
  14057. _AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA = record
  14058. cbSize: DWORD;
  14059. dwRegPolicySettings: DWORD;
  14060. fCommercial: BOOL;
  14061. end;
  14062. {$EXTERNALSYM _AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA}
  14063. AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA = _AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA;
  14064. {$EXTERNALSYM AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA}
  14065. TAuthenticodeTsExtraCertChainPolicyPara = AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA;
  14066. PAuthenticodeTsExtraCertChainPolicyPara = PAUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA;
  14067. //+-------------------------------------------------------------------------
  14068. // CERT_CHAIN_POLICY_SSL
  14069. //
  14070. // Implements the SSL client/server chain policy verification checks.
  14071. //
  14072. // pvExtraPolicyPara may optionally be set to point to the following
  14073. // SSL_EXTRA_CERT_CHAIN_POLICY_PARA data structure
  14074. //--------------------------------------------------------------------------
  14075. // fdwChecks flags are defined in wininet.h
  14076. const
  14077. AUTHTYPE_CLIENT = 1;
  14078. {$EXTERNALSYM AUTHTYPE_CLIENT}
  14079. AUTHTYPE_SERVER = 2;
  14080. {$EXTERNALSYM AUTHTYPE_SERVER}
  14081. type
  14082. PHTTPSPolicyCallbackData = ^HTTPSPolicyCallbackData;
  14083. {$EXTERNALSYM PHTTPSPolicyCallbackData}
  14084. _HTTPSPolicyCallbackData = record
  14085. //union {
  14086. //cbStruct: DWORD; // sizeof(HTTPSPolicyCallbackData);
  14087. cbSize: DWORD; // sizeof(HTTPSPolicyCallbackData);
  14088. //};
  14089. dwAuthType: DWORD;
  14090. fdwChecks: DWORD;
  14091. pwszServerName: PWCHAR; // used to check against CN=xxxx
  14092. end;
  14093. {$EXTERNALSYM _HTTPSPolicyCallbackData}
  14094. HTTPSPolicyCallbackData = _HTTPSPolicyCallbackData;
  14095. {$EXTERNALSYM HTTPSPolicyCallbackData}
  14096. THttpsPolicyCallbackData = HTTPSPolicyCallbackData;
  14097. SSL_EXTRA_CERT_CHAIN_POLICY_PARA = HTTPSPolicyCallbackData;
  14098. {$EXTERNALSYM SSL_EXTRA_CERT_CHAIN_POLICY_PARA}
  14099. PSSL_EXTRA_CERT_CHAIN_POLICY_PARA = PHTTPSPolicyCallbackData;
  14100. {$EXTERNALSYM PSSL_EXTRA_CERT_CHAIN_POLICY_PARA}
  14101. TSSLExtraCertChainPolicyPara = SSL_EXTRA_CERT_CHAIN_POLICY_PARA;
  14102. PSSLExtraCertChainPolicyPara = PSSL_EXTRA_CERT_CHAIN_POLICY_PARA;
  14103. //+-------------------------------------------------------------------------
  14104. // CERT_CHAIN_POLICY_BASIC_CONSTRAINTS
  14105. //
  14106. // Implements the basic constraints chain policy.
  14107. //
  14108. // Iterates through all the certificates in the chain checking for either
  14109. // a szOID_BASIC_CONSTRAINTS or a szOID_BASIC_CONSTRAINTS2 extension. If
  14110. // neither extension is present, the certificate is assumed to have
  14111. // valid policy. Otherwise, for the first certificate element, checks if
  14112. // it matches the expected CA_FLAG or END_ENTITY_FLAG specified in
  14113. // pPolicyPara->dwFlags. If neither or both flags are set, then, the first
  14114. // element can be either a CA or END_ENTITY. All other elements must be
  14115. // a CA. If the PathLenConstraint is present in the extension, its
  14116. // checked.
  14117. //
  14118. // The first elements in the remaining simple chains (ie, the certificate
  14119. // used to sign the CTL) are checked to be an END_ENTITY.
  14120. //
  14121. // If this verification fails, dwError will be set to
  14122. // TRUST_E_BASIC_CONSTRAINTS.
  14123. //--------------------------------------------------------------------------
  14124. const
  14125. BASIC_CONSTRAINTS_CERT_CHAIN_POLICY_CA_FLAG = DWORD($80000000);
  14126. {$EXTERNALSYM BASIC_CONSTRAINTS_CERT_CHAIN_POLICY_CA_FLAG}
  14127. BASIC_CONSTRAINTS_CERT_CHAIN_POLICY_END_ENTITY_FLAG = $40000000;
  14128. {$EXTERNALSYM BASIC_CONSTRAINTS_CERT_CHAIN_POLICY_END_ENTITY_FLAG}
  14129. //+-------------------------------------------------------------------------
  14130. // CERT_CHAIN_POLICY_NT_AUTH
  14131. //
  14132. // Implements the NT Authentication chain policy.
  14133. //
  14134. // The NT Authentication chain policy consists of 3 distinct chain
  14135. // verifications in the following order:
  14136. // [1] CERT_CHAIN_POLICY_BASE - Implements the base chain policy
  14137. // verification checks. The LOWORD of dwFlags can be set in
  14138. // pPolicyPara to alter the default policy checking behaviour. See
  14139. // CERT_CHAIN_POLICY_BASE for more details.
  14140. //
  14141. // [2] CERT_CHAIN_POLICY_BASIC_CONSTRAINTS - Implements the basic
  14142. // constraints chain policy. The HIWORD of dwFlags can be set
  14143. // to specify if the first element must be either a CA or END_ENTITY.
  14144. // See CERT_CHAIN_POLICY_BASIC_CONSTRAINTS for more details.
  14145. //
  14146. // [3] Checks if the second element in the chain, the CA that issued
  14147. // the end certificate, is a trusted CA for NT
  14148. // Authentication. A CA is considered to be trusted if it exists in
  14149. // the "NTAuth" system registry store found in the
  14150. // CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE store location.
  14151. // If this verification fails, whereby the CA isn't trusted,
  14152. // dwError is set to CERT_E_UNTRUSTEDCA.
  14153. //--------------------------------------------------------------------------
  14154. implementation
  14155. const
  14156. crypt32 = 'crypt32.dll';
  14157. advapi32 = 'advapi32.dll';
  14158. softpub = 'softpub.dll';
  14159. {$IFDEF UNICODE}
  14160. AWSuffix = 'W';
  14161. {$ELSE}
  14162. AWSuffix = 'A';
  14163. {$ENDIF UNICODE}
  14164. function GET_ALG_CLASS(x: DWORD): DWORD;
  14165. begin
  14166. Result := (x and (7 shl 13));
  14167. end;
  14168. function GET_ALG_TYPE(x: DWORD): DWORD;
  14169. begin
  14170. Result := (x and (15 shl 9));
  14171. end;
  14172. function GET_ALG_SID(x: DWORD): DWORD;
  14173. begin
  14174. Result := x and 511;
  14175. end;
  14176. function RCRYPT_SUCCEEDED(rt: BOOL): BOOL;
  14177. begin
  14178. Result := (rt = CRYPT_SUCCEED);
  14179. end;
  14180. function RCRYPT_FAILED(rt: BOOL): BOOL;
  14181. begin
  14182. Result := (rt = CRYPT_FAILED)
  14183. end;
  14184. function IS_CERT_RDN_CHAR_STRING(X: DWORD): Boolean;
  14185. begin
  14186. Result := (X and CERT_RDN_TYPE_MASK) >= CERT_RDN_NUMERIC_STRING;
  14187. end;
  14188. function GET_CERT_ENCODING_TYPE(X: DWORD): DWORD;
  14189. begin
  14190. Result := X and CERT_ENCODING_TYPE_MASK;
  14191. end;
  14192. function GET_CMSG_ENCODING_TYPE(X: DWORD): DWORD;
  14193. begin
  14194. Result := X and CMSG_ENCODING_TYPE_MASK;
  14195. end;
  14196. function GET_CERT_UNICODE_RDN_ERR_INDEX(X: DWORD): DWORD;
  14197. begin
  14198. Result := (X shr CERT_UNICODE_RDN_ERR_INDEX_SHIFT) and CERT_UNICODE_RDN_ERR_INDEX_MASK;
  14199. end;
  14200. function GET_CERT_UNICODE_ATTR_ERR_INDEX(X: DWORD): DWORD;
  14201. begin
  14202. Result := (X shr CERT_UNICODE_ATTR_ERR_INDEX_SHIFT) and CERT_UNICODE_ATTR_ERR_INDEX_MASK;
  14203. end;
  14204. function GET_CERT_UNICODE_VALUE_ERR_INDEX(X: DWORD): DWORD;
  14205. begin
  14206. Result := X and CERT_UNICODE_VALUE_ERR_INDEX_MASK;
  14207. end;
  14208. function GET_CERT_ALT_NAME_ENTRY_ERR_INDEX(X: DWORD): DWORD;
  14209. begin
  14210. Result := (X shr CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT) and CERT_ALT_NAME_ENTRY_ERR_INDEX_MASK;
  14211. end;
  14212. function GET_CERT_ALT_NAME_VALUE_ERR_INDEX(X: DWORD): DWORD;
  14213. begin
  14214. Result := X and CERT_ALT_NAME_VALUE_ERR_INDEX_MASK;
  14215. end;
  14216. function IS_CRL_DIST_POINT_ERR_CRL_ISSUER(X: DWORD): Boolean;
  14217. begin
  14218. Result := (X and CRL_DIST_POINT_ERR_CRL_ISSUER_BIT) <> 0;
  14219. end;
  14220. function GET_CRL_DIST_POINT_ERR_INDEX(X: DWORD): DWORD;
  14221. begin
  14222. Result := ((X shr CRL_DIST_POINT_ERR_INDEX_SHIFT) and CRL_DIST_POINT_ERR_INDEX_MASK);
  14223. end;
  14224. function IS_CERT_HASH_PROP_ID(X: DWORD): Boolean;
  14225. begin
  14226. Result := (CERT_SHA1_HASH_PROP_ID = X) or (CERT_MD5_HASH_PROP_ID = X) or
  14227. (CERT_SIGNATURE_HASH_PROP_ID = X);
  14228. end;
  14229. {$IFDEF DYNAMIC_LINK}
  14230. var
  14231. _CryptAcquireContextA: Pointer;
  14232. function CryptAcquireContextA;
  14233. begin
  14234. GetProcedureAddress(_CryptAcquireContextA, advapi32, 'CryptAcquireContextA');
  14235. asm
  14236. MOV ESP, EBP
  14237. POP EBP
  14238. JMP [_CryptAcquireContextA]
  14239. end;
  14240. end;
  14241. var
  14242. _CryptAcquireContextW: Pointer;
  14243. function CryptAcquireContextW;
  14244. begin
  14245. GetProcedureAddress(_CryptAcquireContextW, advapi32, 'CryptAcquireContextW');
  14246. asm
  14247. MOV ESP, EBP
  14248. POP EBP
  14249. JMP [_CryptAcquireContextW]
  14250. end;
  14251. end;
  14252. var
  14253. _CryptAcquireContext: Pointer;
  14254. function CryptAcquireContext;
  14255. begin
  14256. GetProcedureAddress(_CryptAcquireContext, advapi32, 'CryptAcquireContext' + AWSuffix);
  14257. asm
  14258. MOV ESP, EBP
  14259. POP EBP
  14260. JMP [_CryptAcquireContext]
  14261. end;
  14262. end;
  14263. var
  14264. _CryptReleaseContext: Pointer;
  14265. function CryptReleaseContext;
  14266. begin
  14267. GetProcedureAddress(_CryptReleaseContext, advapi32, 'CryptReleaseContext');
  14268. asm
  14269. MOV ESP, EBP
  14270. POP EBP
  14271. JMP [_CryptReleaseContext]
  14272. end;
  14273. end;
  14274. var
  14275. _CryptGenKey: Pointer;
  14276. function CryptGenKey;
  14277. begin
  14278. GetProcedureAddress(_CryptGenKey, advapi32, 'CryptGenKey');
  14279. asm
  14280. MOV ESP, EBP
  14281. POP EBP
  14282. JMP [_CryptGenKey]
  14283. end;
  14284. end;
  14285. var
  14286. _CryptDeriveKey: Pointer;
  14287. function CryptDeriveKey;
  14288. begin
  14289. GetProcedureAddress(_CryptDeriveKey, advapi32, 'CryptDeriveKey');
  14290. asm
  14291. MOV ESP, EBP
  14292. POP EBP
  14293. JMP [_CryptDeriveKey]
  14294. end;
  14295. end;
  14296. var
  14297. _CryptDestroyKey: Pointer;
  14298. function CryptDestroyKey;
  14299. begin
  14300. GetProcedureAddress(_CryptDestroyKey, advapi32, 'CryptDestroyKey');
  14301. asm
  14302. MOV ESP, EBP
  14303. POP EBP
  14304. JMP [_CryptDestroyKey]
  14305. end;
  14306. end;
  14307. var
  14308. _CryptSetKeyParam: Pointer;
  14309. function CryptSetKeyParam;
  14310. begin
  14311. GetProcedureAddress(_CryptSetKeyParam, crypt32, 'CryptSetKeyParam');
  14312. asm
  14313. MOV ESP, EBP
  14314. POP EBP
  14315. JMP [_CryptSetKeyParam]
  14316. end;
  14317. end;
  14318. var
  14319. _CryptGetKeyParam: Pointer;
  14320. function CryptGetKeyParam;
  14321. begin
  14322. GetProcedureAddress(_CryptGetKeyParam, advapi32, 'CryptGetKeyParam');
  14323. asm
  14324. MOV ESP, EBP
  14325. POP EBP
  14326. JMP [_CryptGetKeyParam]
  14327. end;
  14328. end;
  14329. var
  14330. _CryptSetHashParam: Pointer;
  14331. function CryptSetHashParam;
  14332. begin
  14333. GetProcedureAddress(_CryptSetHashParam, advapi32, 'CryptSetHashParam');
  14334. asm
  14335. MOV ESP, EBP
  14336. POP EBP
  14337. JMP [_CryptSetHashParam]
  14338. end;
  14339. end;
  14340. var
  14341. _CryptGetHashParam: Pointer;
  14342. function CryptGetHashParam;
  14343. begin
  14344. GetProcedureAddress(_CryptGetHashParam, advapi32, 'CryptGetHashParam');
  14345. asm
  14346. MOV ESP, EBP
  14347. POP EBP
  14348. JMP [_CryptGetHashParam]
  14349. end;
  14350. end;
  14351. var
  14352. _CryptSetProvParam: Pointer;
  14353. function CryptSetProvParam;
  14354. begin
  14355. GetProcedureAddress(_CryptSetProvParam, advapi32, 'CryptSetProvParam');
  14356. asm
  14357. MOV ESP, EBP
  14358. POP EBP
  14359. JMP [_CryptSetProvParam]
  14360. end;
  14361. end;
  14362. var
  14363. _CryptGetProvParam: Pointer;
  14364. function CryptGetProvParam;
  14365. begin
  14366. GetProcedureAddress(_CryptGetProvParam, advapi32, 'CryptGetProvParam');
  14367. asm
  14368. MOV ESP, EBP
  14369. POP EBP
  14370. JMP [_CryptGetProvParam]
  14371. end;
  14372. end;
  14373. var
  14374. _CryptGenRandom: Pointer;
  14375. function CryptGenRandom;
  14376. begin
  14377. GetProcedureAddress(_CryptGenRandom, advapi32, 'CryptGenRandom');
  14378. asm
  14379. MOV ESP, EBP
  14380. POP EBP
  14381. JMP [_CryptGenRandom]
  14382. end;
  14383. end;
  14384. var
  14385. _CryptGetUserKey: Pointer;
  14386. function CryptGetUserKey;
  14387. begin
  14388. GetProcedureAddress(_CryptGetUserKey, advapi32, 'CryptGetUserKey');
  14389. asm
  14390. MOV ESP, EBP
  14391. POP EBP
  14392. JMP [_CryptGetUserKey]
  14393. end;
  14394. end;
  14395. var
  14396. _CryptExportKey: Pointer;
  14397. function CryptExportKey;
  14398. begin
  14399. GetProcedureAddress(_CryptExportKey, advapi32, 'CryptExportKey');
  14400. asm
  14401. MOV ESP, EBP
  14402. POP EBP
  14403. JMP [_CryptExportKey]
  14404. end;
  14405. end;
  14406. var
  14407. _CryptImportKey: Pointer;
  14408. function CryptImportKey;
  14409. begin
  14410. GetProcedureAddress(_CryptImportKey, advapi32, 'CryptImportKey');
  14411. asm
  14412. MOV ESP, EBP
  14413. POP EBP
  14414. JMP [_CryptImportKey]
  14415. end;
  14416. end;
  14417. var
  14418. _CryptEncrypt: Pointer;
  14419. function CryptEncrypt;
  14420. begin
  14421. GetProcedureAddress(_CryptEncrypt, advapi32, 'CryptEncrypt');
  14422. asm
  14423. MOV ESP, EBP
  14424. POP EBP
  14425. JMP [_CryptEncrypt]
  14426. end;
  14427. end;
  14428. var
  14429. _CryptDecrypt: Pointer;
  14430. function CryptDecrypt;
  14431. begin
  14432. GetProcedureAddress(_CryptDecrypt, advapi32, 'CryptDecrypt');
  14433. asm
  14434. MOV ESP, EBP
  14435. POP EBP
  14436. JMP [_CryptDecrypt]
  14437. end;
  14438. end;
  14439. var
  14440. _CryptCreateHash: Pointer;
  14441. function CryptCreateHash;
  14442. begin
  14443. GetProcedureAddress(_CryptCreateHash, advapi32, 'CryptCreateHash');
  14444. asm
  14445. MOV ESP, EBP
  14446. POP EBP
  14447. JMP [_CryptCreateHash]
  14448. end;
  14449. end;
  14450. var
  14451. _CryptHashData: Pointer;
  14452. function CryptHashData;
  14453. begin
  14454. GetProcedureAddress(_CryptHashData, advapi32, 'CryptHashData');
  14455. asm
  14456. MOV ESP, EBP
  14457. POP EBP
  14458. JMP [_CryptHashData]
  14459. end;
  14460. end;
  14461. var
  14462. _CryptHashSessionKey: Pointer;
  14463. function CryptHashSessionKey;
  14464. begin
  14465. GetProcedureAddress(_CryptHashSessionKey, advapi32, 'CryptHashSessionKey');
  14466. asm
  14467. MOV ESP, EBP
  14468. POP EBP
  14469. JMP [_CryptHashSessionKey]
  14470. end;
  14471. end;
  14472. var
  14473. _CryptDestroyHash: Pointer;
  14474. function CryptDestroyHash;
  14475. begin
  14476. GetProcedureAddress(_CryptDestroyHash, advapi32, 'CryptDestroyHash');
  14477. asm
  14478. MOV ESP, EBP
  14479. POP EBP
  14480. JMP [_CryptDestroyHash]
  14481. end;
  14482. end;
  14483. var
  14484. _CryptSignHashA: Pointer;
  14485. function CryptSignHashA;
  14486. begin
  14487. GetProcedureAddress(_CryptSignHashA, advapi32, 'CryptSignHashA');
  14488. asm
  14489. MOV ESP, EBP
  14490. POP EBP
  14491. JMP [_CryptSignHashA]
  14492. end;
  14493. end;
  14494. var
  14495. _CryptSignHashW: Pointer;
  14496. function CryptSignHashW;
  14497. begin
  14498. GetProcedureAddress(_CryptSignHashW, advapi32, 'CryptSignHashW');
  14499. asm
  14500. MOV ESP, EBP
  14501. POP EBP
  14502. JMP [_CryptSignHashW]
  14503. end;
  14504. end;
  14505. var
  14506. _CryptSignHash: Pointer;
  14507. function CryptSignHash;
  14508. begin
  14509. GetProcedureAddress(_CryptSignHash, advapi32, 'CryptSignHash' + AWSuffix);
  14510. asm
  14511. MOV ESP, EBP
  14512. POP EBP
  14513. JMP [_CryptSignHash]
  14514. end;
  14515. end;
  14516. var
  14517. _CryptVerifySignatureA: Pointer;
  14518. function CryptVerifySignatureA;
  14519. begin
  14520. GetProcedureAddress(_CryptVerifySignatureA, advapi32, 'CryptVerifySignatureA');
  14521. asm
  14522. MOV ESP, EBP
  14523. POP EBP
  14524. JMP [_CryptVerifySignatureA]
  14525. end;
  14526. end;
  14527. var
  14528. _CryptVerifySignatureW: Pointer;
  14529. function CryptVerifySignatureW;
  14530. begin
  14531. GetProcedureAddress(_CryptVerifySignatureW, advapi32, 'CryptVerifySignatureW');
  14532. asm
  14533. MOV ESP, EBP
  14534. POP EBP
  14535. JMP [_CryptVerifySignatureW]
  14536. end;
  14537. end;
  14538. var
  14539. _CryptVerifySignature: Pointer;
  14540. function CryptVerifySignature;
  14541. begin
  14542. GetProcedureAddress(_CryptVerifySignature, advapi32, 'CryptVerifySignature' + AWSuffix);
  14543. asm
  14544. MOV ESP, EBP
  14545. POP EBP
  14546. JMP [_CryptVerifySignature]
  14547. end;
  14548. end;
  14549. var
  14550. _CryptSetProviderA: Pointer;
  14551. function CryptSetProviderA;
  14552. begin
  14553. GetProcedureAddress(_CryptSetProviderA, advapi32, 'CryptSetProviderA');
  14554. asm
  14555. MOV ESP, EBP
  14556. POP EBP
  14557. JMP [_CryptSetProviderA]
  14558. end;
  14559. end;
  14560. var
  14561. _CryptSetProviderW: Pointer;
  14562. function CryptSetProviderW;
  14563. begin
  14564. GetProcedureAddress(_CryptSetProviderW, advapi32, 'CryptSetProviderW');
  14565. asm
  14566. MOV ESP, EBP
  14567. POP EBP
  14568. JMP [_CryptSetProviderW]
  14569. end;
  14570. end;
  14571. var
  14572. _CryptSetProvider: Pointer;
  14573. function CryptSetProvider;
  14574. begin
  14575. GetProcedureAddress(_CryptSetProvider, advapi32, 'CryptSetProvider' + AWSuffix);
  14576. asm
  14577. MOV ESP, EBP
  14578. POP EBP
  14579. JMP [_CryptSetProvider]
  14580. end;
  14581. end;
  14582. var
  14583. _CryptSetProviderExA: Pointer;
  14584. function CryptSetProviderExA;
  14585. begin
  14586. GetProcedureAddress(_CryptSetProviderExA, advapi32, 'CryptSetProviderExA');
  14587. asm
  14588. MOV ESP, EBP
  14589. POP EBP
  14590. JMP [_CryptSetProviderExA]
  14591. end;
  14592. end;
  14593. var
  14594. _CryptSetProviderExW: Pointer;
  14595. function CryptSetProviderExW;
  14596. begin
  14597. GetProcedureAddress(_CryptSetProviderExW, advapi32, 'CryptSetProviderExW');
  14598. asm
  14599. MOV ESP, EBP
  14600. POP EBP
  14601. JMP [_CryptSetProviderExW]
  14602. end;
  14603. end;
  14604. var
  14605. _CryptSetProviderEx: Pointer;
  14606. function CryptSetProviderEx;
  14607. begin
  14608. GetProcedureAddress(_CryptSetProviderEx, advapi32, 'CryptSetProviderEx' + AWSuffix);
  14609. asm
  14610. MOV ESP, EBP
  14611. POP EBP
  14612. JMP [_CryptSetProviderEx]
  14613. end;
  14614. end;
  14615. var
  14616. _CryptGetDefaultProviderA: Pointer;
  14617. function CryptGetDefaultProviderA;
  14618. begin
  14619. GetProcedureAddress(_CryptGetDefaultProviderA, advapi32, 'CryptGetDefaultProviderA');
  14620. asm
  14621. MOV ESP, EBP
  14622. POP EBP
  14623. JMP [_CryptGetDefaultProviderA]
  14624. end;
  14625. end;
  14626. var
  14627. _CryptGetDefaultProviderW: Pointer;
  14628. function CryptGetDefaultProviderW;
  14629. begin
  14630. GetProcedureAddress(_CryptGetDefaultProviderW, advapi32, 'CryptGetDefaultProviderW');
  14631. asm
  14632. MOV ESP, EBP
  14633. POP EBP
  14634. JMP [_CryptGetDefaultProviderW]
  14635. end;
  14636. end;
  14637. var
  14638. _CryptGetDefaultProvider: Pointer;
  14639. function CryptGetDefaultProvider;
  14640. begin
  14641. GetProcedureAddress(_CryptGetDefaultProvider, advapi32, 'CryptGetDefaultProvider' + AWSuffix);
  14642. asm
  14643. MOV ESP, EBP
  14644. POP EBP
  14645. JMP [_CryptGetDefaultProvider]
  14646. end;
  14647. end;
  14648. var
  14649. _CryptEnumProviderTypesA: Pointer;
  14650. function CryptEnumProviderTypesA;
  14651. begin
  14652. GetProcedureAddress(_CryptEnumProviderTypesA, advapi32, 'CryptEnumProviderTypesA');
  14653. asm
  14654. MOV ESP, EBP
  14655. POP EBP
  14656. JMP [_CryptEnumProviderTypesA]
  14657. end;
  14658. end;
  14659. var
  14660. _CryptEnumProviderTypesW: Pointer;
  14661. function CryptEnumProviderTypesW;
  14662. begin
  14663. GetProcedureAddress(_CryptEnumProviderTypesW, advapi32, 'CryptEnumProviderTypesW');
  14664. asm
  14665. MOV ESP, EBP
  14666. POP EBP
  14667. JMP [_CryptEnumProviderTypesW]
  14668. end;
  14669. end;
  14670. var
  14671. _CryptEnumProviderTypes: Pointer;
  14672. function CryptEnumProviderTypes;
  14673. begin
  14674. GetProcedureAddress(_CryptEnumProviderTypes, advapi32, 'CryptEnumProviderTypes' + AWSuffix);
  14675. asm
  14676. MOV ESP, EBP
  14677. POP EBP
  14678. JMP [_CryptEnumProviderTypes]
  14679. end;
  14680. end;
  14681. var
  14682. _CryptEnumProvidersA: Pointer;
  14683. function CryptEnumProvidersA;
  14684. begin
  14685. GetProcedureAddress(_CryptEnumProvidersA, advapi32, 'CryptEnumProvidersA');
  14686. asm
  14687. MOV ESP, EBP
  14688. POP EBP
  14689. JMP [_CryptEnumProvidersA]
  14690. end;
  14691. end;
  14692. var
  14693. _CryptEnumProvidersW: Pointer;
  14694. function CryptEnumProvidersW;
  14695. begin
  14696. GetProcedureAddress(_CryptEnumProvidersW, advapi32, 'CryptEnumProvidersW');
  14697. asm
  14698. MOV ESP, EBP
  14699. POP EBP
  14700. JMP [_CryptEnumProvidersW]
  14701. end;
  14702. end;
  14703. var
  14704. _CryptEnumProviders: Pointer;
  14705. function CryptEnumProviders;
  14706. begin
  14707. GetProcedureAddress(_CryptEnumProviders, advapi32, 'CryptEnumProviders' + AWSuffix);
  14708. asm
  14709. MOV ESP, EBP
  14710. POP EBP
  14711. JMP [_CryptEnumProviders]
  14712. end;
  14713. end;
  14714. var
  14715. _CryptContextAddRef: Pointer;
  14716. function CryptContextAddRef;
  14717. begin
  14718. GetProcedureAddress(_CryptContextAddRef, advapi32, 'CryptContextAddRef');
  14719. asm
  14720. MOV ESP, EBP
  14721. POP EBP
  14722. JMP [_CryptContextAddRef]
  14723. end;
  14724. end;
  14725. var
  14726. _CryptDuplicateKey: Pointer;
  14727. function CryptDuplicateKey;
  14728. begin
  14729. GetProcedureAddress(_CryptDuplicateKey, advapi32, 'CryptDuplicateKey');
  14730. asm
  14731. MOV ESP, EBP
  14732. POP EBP
  14733. JMP [_CryptDuplicateKey]
  14734. end;
  14735. end;
  14736. var
  14737. _CryptDuplicateHash: Pointer;
  14738. function CryptDuplicateHash;
  14739. begin
  14740. GetProcedureAddress(_CryptDuplicateHash, advapi32, 'CryptDuplicateHash');
  14741. asm
  14742. MOV ESP, EBP
  14743. POP EBP
  14744. JMP [_CryptDuplicateHash]
  14745. end;
  14746. end;
  14747. var
  14748. _CryptFormatObject: Pointer;
  14749. function CryptFormatObject;
  14750. begin
  14751. GetProcedureAddress(_CryptFormatObject, crypt32, 'CryptFormatObject');
  14752. asm
  14753. MOV ESP, EBP
  14754. POP EBP
  14755. JMP [_CryptFormatObject]
  14756. end;
  14757. end;
  14758. var
  14759. _CryptEncodeObjectEx: Pointer;
  14760. function CryptEncodeObjectEx;
  14761. begin
  14762. GetProcedureAddress(_CryptEncodeObjectEx, crypt32, 'CryptEncodeObjectEx');
  14763. asm
  14764. MOV ESP, EBP
  14765. POP EBP
  14766. JMP [_CryptEncodeObjectEx]
  14767. end;
  14768. end;
  14769. var
  14770. _CryptEncodeObject: Pointer;
  14771. function CryptEncodeObject;
  14772. begin
  14773. GetProcedureAddress(_CryptEncodeObject, crypt32, 'CryptEncodeObject');
  14774. asm
  14775. MOV ESP, EBP
  14776. POP EBP
  14777. JMP [_CryptEncodeObject]
  14778. end;
  14779. end;
  14780. var
  14781. _CryptDecodeObjectEx: Pointer;
  14782. function CryptDecodeObjectEx;
  14783. begin
  14784. GetProcedureAddress(_CryptDecodeObjectEx, crypt32, 'CryptDecodeObjectEx');
  14785. asm
  14786. MOV ESP, EBP
  14787. POP EBP
  14788. JMP [_CryptDecodeObjectEx]
  14789. end;
  14790. end;
  14791. var
  14792. _CryptDecodeObject: Pointer;
  14793. function CryptDecodeObject;
  14794. begin
  14795. GetProcedureAddress(_CryptDecodeObject, crypt32, 'CryptDecodeObject');
  14796. asm
  14797. MOV ESP, EBP
  14798. POP EBP
  14799. JMP [_CryptDecodeObject]
  14800. end;
  14801. end;
  14802. var
  14803. _CryptInstallOIDFunctionAddress: Pointer;
  14804. function CryptInstallOIDFunctionAddress;
  14805. begin
  14806. GetProcedureAddress(_CryptInstallOIDFunctionAddress, crypt32, 'CryptInstallOIDFunctionAddress');
  14807. asm
  14808. MOV ESP, EBP
  14809. POP EBP
  14810. JMP [_CryptInstallOIDFunctionAddress]
  14811. end;
  14812. end;
  14813. var
  14814. _CryptInitOIDFunctionSet: Pointer;
  14815. function CryptInitOIDFunctionSet;
  14816. begin
  14817. GetProcedureAddress(_CryptInitOIDFunctionSet, crypt32, 'CryptInitOIDFunctionSet');
  14818. asm
  14819. MOV ESP, EBP
  14820. POP EBP
  14821. JMP [_CryptInitOIDFunctionSet]
  14822. end;
  14823. end;
  14824. var
  14825. _CryptGetOIDFunctionAddress: Pointer;
  14826. function CryptGetOIDFunctionAddress;
  14827. begin
  14828. GetProcedureAddress(_CryptGetOIDFunctionAddress, crypt32, 'CryptGetOIDFunctionAddress');
  14829. asm
  14830. MOV ESP, EBP
  14831. POP EBP
  14832. JMP [_CryptGetOIDFunctionAddress]
  14833. end;
  14834. end;
  14835. var
  14836. _CryptGetDefaultOIDDllList: Pointer;
  14837. function CryptGetDefaultOIDDllList;
  14838. begin
  14839. GetProcedureAddress(_CryptGetDefaultOIDDllList, crypt32, 'CryptGetDefaultOIDDllList');
  14840. asm
  14841. MOV ESP, EBP
  14842. POP EBP
  14843. JMP [_CryptGetDefaultOIDDllList]
  14844. end;
  14845. end;
  14846. var
  14847. _CryptGetDefaultOIDFunctionAddr: Pointer;
  14848. function CryptGetDefaultOIDFunctionAddress;
  14849. begin
  14850. GetProcedureAddress(_CryptGetDefaultOIDFunctionAddr, crypt32, 'CryptGetDefaultOIDFunctionAddress');
  14851. asm
  14852. MOV ESP, EBP
  14853. POP EBP
  14854. JMP [_CryptGetDefaultOIDFunctionAddr]
  14855. end;
  14856. end;
  14857. var
  14858. _CryptFreeOIDFunctionAddress: Pointer;
  14859. function CryptFreeOIDFunctionAddress;
  14860. begin
  14861. GetProcedureAddress(_CryptFreeOIDFunctionAddress, crypt32, 'CryptFreeOIDFunctionAddress');
  14862. asm
  14863. MOV ESP, EBP
  14864. POP EBP
  14865. JMP [_CryptFreeOIDFunctionAddress]
  14866. end;
  14867. end;
  14868. var
  14869. _CryptRegisterOIDFunction: Pointer;
  14870. function CryptRegisterOIDFunction;
  14871. begin
  14872. GetProcedureAddress(_CryptRegisterOIDFunction, crypt32, 'CryptRegisterOIDFunction');
  14873. asm
  14874. MOV ESP, EBP
  14875. POP EBP
  14876. JMP [_CryptRegisterOIDFunction]
  14877. end;
  14878. end;
  14879. var
  14880. _CryptUnregisterOIDFunction: Pointer;
  14881. function CryptUnregisterOIDFunction;
  14882. begin
  14883. GetProcedureAddress(_CryptUnregisterOIDFunction, crypt32, 'CryptUnregisterOIDFunction');
  14884. asm
  14885. MOV ESP, EBP
  14886. POP EBP
  14887. JMP [_CryptUnregisterOIDFunction]
  14888. end;
  14889. end;
  14890. var
  14891. _CryptRegisterDefaultOIDFunction: Pointer;
  14892. function CryptRegisterDefaultOIDFunction;
  14893. begin
  14894. GetProcedureAddress(_CryptRegisterDefaultOIDFunction, crypt32, 'CryptRegisterDefaultOIDFunction');
  14895. asm
  14896. MOV ESP, EBP
  14897. POP EBP
  14898. JMP [_CryptRegisterDefaultOIDFunction]
  14899. end;
  14900. end;
  14901. var
  14902. _CryptUnregisterDefaultOIDFunc: Pointer;
  14903. function CryptUnregisterDefaultOIDFunction;
  14904. begin
  14905. GetProcedureAddress(_CryptUnregisterDefaultOIDFunc, crypt32, 'CryptUnregisterDefaultOIDFunction');
  14906. asm
  14907. MOV ESP, EBP
  14908. POP EBP
  14909. JMP [_CryptUnregisterDefaultOIDFunc]
  14910. end;
  14911. end;
  14912. var
  14913. _CryptSetOIDFunctionValue: Pointer;
  14914. function CryptSetOIDFunctionValue;
  14915. begin
  14916. GetProcedureAddress(_CryptSetOIDFunctionValue, crypt32, 'CryptSetOIDFunctionValue');
  14917. asm
  14918. MOV ESP, EBP
  14919. POP EBP
  14920. JMP [_CryptSetOIDFunctionValue]
  14921. end;
  14922. end;
  14923. var
  14924. _CryptGetOIDFunctionValue: Pointer;
  14925. function CryptGetOIDFunctionValue;
  14926. begin
  14927. GetProcedureAddress(_CryptGetOIDFunctionValue, crypt32, 'CryptGetOIDFunctionValue');
  14928. asm
  14929. MOV ESP, EBP
  14930. POP EBP
  14931. JMP [_CryptGetOIDFunctionValue]
  14932. end;
  14933. end;
  14934. var
  14935. _CryptEnumOIDFunction: Pointer;
  14936. function CryptEnumOIDFunction;
  14937. begin
  14938. GetProcedureAddress(_CryptEnumOIDFunction, crypt32, 'CryptEnumOIDFunction');
  14939. asm
  14940. MOV ESP, EBP
  14941. POP EBP
  14942. JMP [_CryptEnumOIDFunction]
  14943. end;
  14944. end;
  14945. var
  14946. _CryptFindOIDInfo: Pointer;
  14947. function CryptFindOIDInfo;
  14948. begin
  14949. GetProcedureAddress(_CryptFindOIDInfo, crypt32, 'CryptFindOIDInfo');
  14950. asm
  14951. MOV ESP, EBP
  14952. POP EBP
  14953. JMP [_CryptFindOIDInfo]
  14954. end;
  14955. end;
  14956. var
  14957. _CryptRegisterOIDInfo: Pointer;
  14958. function CryptRegisterOIDInfo;
  14959. begin
  14960. GetProcedureAddress(_CryptRegisterOIDInfo, crypt32, 'CryptRegisterOIDInfo');
  14961. asm
  14962. MOV ESP, EBP
  14963. POP EBP
  14964. JMP [_CryptRegisterOIDInfo]
  14965. end;
  14966. end;
  14967. var
  14968. _CryptUnregisterOIDInfo: Pointer;
  14969. function CryptUnregisterOIDInfo;
  14970. begin
  14971. GetProcedureAddress(_CryptUnregisterOIDInfo, crypt32, 'CryptUnregisterOIDInfo');
  14972. asm
  14973. MOV ESP, EBP
  14974. POP EBP
  14975. JMP [_CryptUnregisterOIDInfo]
  14976. end;
  14977. end;
  14978. var
  14979. _CryptEnumOIDInfo: Pointer;
  14980. function CryptEnumOIDInfo;
  14981. begin
  14982. GetProcedureAddress(_CryptEnumOIDInfo, crypt32, 'CryptEnumOIDInfo');
  14983. asm
  14984. MOV ESP, EBP
  14985. POP EBP
  14986. JMP [_CryptEnumOIDInfo]
  14987. end;
  14988. end;
  14989. var
  14990. _CryptFindLocalizedName: Pointer;
  14991. function CryptFindLocalizedName;
  14992. begin
  14993. GetProcedureAddress(_CryptFindLocalizedName, crypt32, 'CryptFindLocalizedName');
  14994. asm
  14995. MOV ESP, EBP
  14996. POP EBP
  14997. JMP [_CryptFindLocalizedName]
  14998. end;
  14999. end;
  15000. var
  15001. _CryptMsgOpenToEncode: Pointer;
  15002. function CryptMsgOpenToEncode;
  15003. begin
  15004. GetProcedureAddress(_CryptMsgOpenToEncode, crypt32, 'CryptMsgOpenToEncode');
  15005. asm
  15006. MOV ESP, EBP
  15007. POP EBP
  15008. JMP [_CryptMsgOpenToEncode]
  15009. end;
  15010. end;
  15011. var
  15012. _CryptMsgCalculateEncodedLength: Pointer;
  15013. function CryptMsgCalculateEncodedLength;
  15014. begin
  15015. GetProcedureAddress(_CryptMsgCalculateEncodedLength, crypt32, 'CryptMsgCalculateEncodedLength');
  15016. asm
  15017. MOV ESP, EBP
  15018. POP EBP
  15019. JMP [_CryptMsgCalculateEncodedLength]
  15020. end;
  15021. end;
  15022. var
  15023. _CryptMsgOpenToDecode: Pointer;
  15024. function CryptMsgOpenToDecode;
  15025. begin
  15026. GetProcedureAddress(_CryptMsgOpenToDecode, crypt32, 'CryptMsgOpenToDecode');
  15027. asm
  15028. MOV ESP, EBP
  15029. POP EBP
  15030. JMP [_CryptMsgOpenToDecode]
  15031. end;
  15032. end;
  15033. var
  15034. _CryptMsgDuplicate: Pointer;
  15035. function CryptMsgDuplicate;
  15036. begin
  15037. GetProcedureAddress(_CryptMsgDuplicate, crypt32, 'CryptMsgDuplicate');
  15038. asm
  15039. MOV ESP, EBP
  15040. POP EBP
  15041. JMP [_CryptMsgDuplicate]
  15042. end;
  15043. end;
  15044. var
  15045. _CryptMsgClose: Pointer;
  15046. function CryptMsgClose;
  15047. begin
  15048. GetProcedureAddress(_CryptMsgClose, crypt32, 'CryptMsgClose');
  15049. asm
  15050. MOV ESP, EBP
  15051. POP EBP
  15052. JMP [_CryptMsgClose]
  15053. end;
  15054. end;
  15055. var
  15056. _CryptMsgUpdate: Pointer;
  15057. function CryptMsgUpdate;
  15058. begin
  15059. GetProcedureAddress(_CryptMsgUpdate, crypt32, 'CryptMsgUpdate');
  15060. asm
  15061. MOV ESP, EBP
  15062. POP EBP
  15063. JMP [_CryptMsgUpdate]
  15064. end;
  15065. end;
  15066. var
  15067. _CryptMsgGetParam: Pointer;
  15068. function CryptMsgGetParam;
  15069. begin
  15070. GetProcedureAddress(_CryptMsgGetParam, crypt32, 'CryptMsgGetParam');
  15071. asm
  15072. MOV ESP, EBP
  15073. POP EBP
  15074. JMP [_CryptMsgGetParam]
  15075. end;
  15076. end;
  15077. var
  15078. _CryptMsgControl: Pointer;
  15079. function CryptMsgControl;
  15080. begin
  15081. GetProcedureAddress(_CryptMsgControl, crypt32, 'CryptMsgControl');
  15082. asm
  15083. MOV ESP, EBP
  15084. POP EBP
  15085. JMP [_CryptMsgControl]
  15086. end;
  15087. end;
  15088. var
  15089. _CryptMsgVerifyCountersigEnc: Pointer;
  15090. function CryptMsgVerifyCountersignatureEncoded;
  15091. begin
  15092. GetProcedureAddress(_CryptMsgVerifyCountersigEnc, crypt32, 'CryptMsgVerifyCountersignatureEncoded');
  15093. asm
  15094. MOV ESP, EBP
  15095. POP EBP
  15096. JMP [_CryptMsgVerifyCountersigEnc]
  15097. end;
  15098. end;
  15099. var
  15100. _CryptMsgVerifyCountersigEncEx: Pointer;
  15101. function CryptMsgVerifyCountersignatureEncodedEx;
  15102. begin
  15103. GetProcedureAddress(_CryptMsgVerifyCountersigEncEx, crypt32, 'CryptMsgVerifyCountersignatureEncodedEx');
  15104. asm
  15105. MOV ESP, EBP
  15106. POP EBP
  15107. JMP [_CryptMsgVerifyCountersigEncEx]
  15108. end;
  15109. end;
  15110. var
  15111. _CryptMsgCountersign: Pointer;
  15112. function CryptMsgCountersign;
  15113. begin
  15114. GetProcedureAddress(_CryptMsgCountersign, crypt32, 'CryptMsgCountersign');
  15115. asm
  15116. MOV ESP, EBP
  15117. POP EBP
  15118. JMP [_CryptMsgCountersign]
  15119. end;
  15120. end;
  15121. var
  15122. _CryptMsgCountersignEncoded: Pointer;
  15123. function CryptMsgCountersignEncoded;
  15124. begin
  15125. GetProcedureAddress(_CryptMsgCountersignEncoded, crypt32, 'CryptMsgCountersignEncoded');
  15126. asm
  15127. MOV ESP, EBP
  15128. POP EBP
  15129. JMP [_CryptMsgCountersignEncoded]
  15130. end;
  15131. end;
  15132. var
  15133. _CertOpenStore: Pointer;
  15134. function CertOpenStore;
  15135. begin
  15136. GetProcedureAddress(_CertOpenStore, crypt32, 'CertOpenStore');
  15137. asm
  15138. MOV ESP, EBP
  15139. POP EBP
  15140. JMP [_CertOpenStore]
  15141. end;
  15142. end;
  15143. var
  15144. _CertDuplicateStore: Pointer;
  15145. function CertDuplicateStore;
  15146. begin
  15147. GetProcedureAddress(_CertDuplicateStore, crypt32, 'CertDuplicateStore');
  15148. asm
  15149. MOV ESP, EBP
  15150. POP EBP
  15151. JMP [_CertDuplicateStore]
  15152. end;
  15153. end;
  15154. var
  15155. _CertSaveStore: Pointer;
  15156. function CertSaveStore;
  15157. begin
  15158. GetProcedureAddress(_CertSaveStore, crypt32, 'CertSaveStore');
  15159. asm
  15160. MOV ESP, EBP
  15161. POP EBP
  15162. JMP [_CertSaveStore]
  15163. end;
  15164. end;
  15165. var
  15166. _CertCloseStore: Pointer;
  15167. function CertCloseStore;
  15168. begin
  15169. GetProcedureAddress(_CertCloseStore, crypt32, 'CertCloseStore');
  15170. asm
  15171. MOV ESP, EBP
  15172. POP EBP
  15173. JMP [_CertCloseStore]
  15174. end;
  15175. end;
  15176. var
  15177. _CertGetSubjectCertFromStore: Pointer;
  15178. function CertGetSubjectCertificateFromStore;
  15179. begin
  15180. GetProcedureAddress(_CertGetSubjectCertFromStore, crypt32, 'CertGetSubjectCertificateFromStore');
  15181. asm
  15182. MOV ESP, EBP
  15183. POP EBP
  15184. JMP [_CertGetSubjectCertFromStore]
  15185. end;
  15186. end;
  15187. var
  15188. _CertEnumCertificatesInStore: Pointer;
  15189. function CertEnumCertificatesInStore;
  15190. begin
  15191. GetProcedureAddress(_CertEnumCertificatesInStore, crypt32, 'CertEnumCertificatesInStore');
  15192. asm
  15193. MOV ESP, EBP
  15194. POP EBP
  15195. JMP [_CertEnumCertificatesInStore]
  15196. end;
  15197. end;
  15198. var
  15199. _CertFindCertificateInStore: Pointer;
  15200. function CertFindCertificateInStore;
  15201. begin
  15202. GetProcedureAddress(_CertFindCertificateInStore, crypt32, 'CertFindCertificateInStore');
  15203. asm
  15204. MOV ESP, EBP
  15205. POP EBP
  15206. JMP [_CertFindCertificateInStore]
  15207. end;
  15208. end;
  15209. var
  15210. _CertGetIssuerCertFromStore: Pointer;
  15211. function CertGetIssuerCertificateFromStore;
  15212. begin
  15213. GetProcedureAddress(_CertGetIssuerCertFromStore, crypt32, 'CertGetIssuerCertificateFromStore');
  15214. asm
  15215. MOV ESP, EBP
  15216. POP EBP
  15217. JMP [_CertGetIssuerCertFromStore]
  15218. end;
  15219. end;
  15220. var
  15221. _CertVerifySubjectCertContext: Pointer;
  15222. function CertVerifySubjectCertificateContext;
  15223. begin
  15224. GetProcedureAddress(_CertVerifySubjectCertContext, crypt32, 'CertVerifySubjectCertificateContext');
  15225. asm
  15226. MOV ESP, EBP
  15227. POP EBP
  15228. JMP [_CertVerifySubjectCertContext]
  15229. end;
  15230. end;
  15231. var
  15232. _CertDuplicateCertificateContext: Pointer;
  15233. function CertDuplicateCertificateContext;
  15234. begin
  15235. GetProcedureAddress(_CertDuplicateCertificateContext, crypt32, 'CertDuplicateCertificateContext');
  15236. asm
  15237. MOV ESP, EBP
  15238. POP EBP
  15239. JMP [_CertDuplicateCertificateContext]
  15240. end;
  15241. end;
  15242. var
  15243. _CertCreateCertificateContext: Pointer;
  15244. function CertCreateCertificateContext;
  15245. begin
  15246. GetProcedureAddress(_CertCreateCertificateContext, crypt32, 'CertCreateCertificateContext');
  15247. asm
  15248. MOV ESP, EBP
  15249. POP EBP
  15250. JMP [_CertCreateCertificateContext]
  15251. end;
  15252. end;
  15253. var
  15254. _CertFreeCertificateContext: Pointer;
  15255. function CertFreeCertificateContext;
  15256. begin
  15257. GetProcedureAddress(_CertFreeCertificateContext, crypt32, 'CertFreeCertificateContext');
  15258. asm
  15259. MOV ESP, EBP
  15260. POP EBP
  15261. JMP [_CertFreeCertificateContext]
  15262. end;
  15263. end;
  15264. var
  15265. _CertSetCertContextProperty: Pointer;
  15266. function CertSetCertificateContextProperty;
  15267. begin
  15268. GetProcedureAddress(_CertSetCertContextProperty, crypt32, 'CertSetCertificateContextProperty');
  15269. asm
  15270. MOV ESP, EBP
  15271. POP EBP
  15272. JMP [_CertSetCertContextProperty]
  15273. end;
  15274. end;
  15275. var
  15276. _CertGetCertContextProperty: Pointer;
  15277. function CertGetCertificateContextProperty;
  15278. begin
  15279. GetProcedureAddress(_CertGetCertContextProperty, crypt32, 'CertGetCertificateContextProperty');
  15280. asm
  15281. MOV ESP, EBP
  15282. POP EBP
  15283. JMP [_CertGetCertContextProperty]
  15284. end;
  15285. end;
  15286. var
  15287. _CertEnumCertContextProperties: Pointer;
  15288. function CertEnumCertificateContextProperties;
  15289. begin
  15290. GetProcedureAddress(_CertEnumCertContextProperties, crypt32, 'CertEnumCertificateContextProperties');
  15291. asm
  15292. MOV ESP, EBP
  15293. POP EBP
  15294. JMP [_CertEnumCertContextProperties]
  15295. end;
  15296. end;
  15297. var
  15298. _CertGetCRLFromStore: Pointer;
  15299. function CertGetCRLFromStore;
  15300. begin
  15301. GetProcedureAddress(_CertGetCRLFromStore, crypt32, 'CertGetCRLFromStore');
  15302. asm
  15303. MOV ESP, EBP
  15304. POP EBP
  15305. JMP [_CertGetCRLFromStore]
  15306. end;
  15307. end;
  15308. var
  15309. _CertEnumCRLsInStore: Pointer;
  15310. function CertEnumCRLsInStore;
  15311. begin
  15312. GetProcedureAddress(_CertEnumCRLsInStore, crypt32, 'CertEnumCRLsInStore');
  15313. asm
  15314. MOV ESP, EBP
  15315. POP EBP
  15316. JMP [_CertEnumCRLsInStore]
  15317. end;
  15318. end;
  15319. var
  15320. _CertFindCRLInStore: Pointer;
  15321. function CertFindCRLInStore;
  15322. begin
  15323. GetProcedureAddress(_CertFindCRLInStore, crypt32, 'CertFindCRLInStore');
  15324. asm
  15325. MOV ESP, EBP
  15326. POP EBP
  15327. JMP [_CertFindCRLInStore]
  15328. end;
  15329. end;
  15330. var
  15331. _CertDuplicateCRLContext: Pointer;
  15332. function CertDuplicateCRLContext;
  15333. begin
  15334. GetProcedureAddress(_CertDuplicateCRLContext, crypt32, 'CertDuplicateCRLContext');
  15335. asm
  15336. MOV ESP, EBP
  15337. POP EBP
  15338. JMP [_CertDuplicateCRLContext]
  15339. end;
  15340. end;
  15341. var
  15342. _CertCreateCRLContext: Pointer;
  15343. function CertCreateCRLContext;
  15344. begin
  15345. GetProcedureAddress(_CertCreateCRLContext, crypt32, 'CertCreateCRLContext');
  15346. asm
  15347. MOV ESP, EBP
  15348. POP EBP
  15349. JMP [_CertCreateCRLContext]
  15350. end;
  15351. end;
  15352. var
  15353. _CertFreeCRLContext: Pointer;
  15354. function CertFreeCRLContext;
  15355. begin
  15356. GetProcedureAddress(_CertFreeCRLContext, crypt32, 'CertFreeCRLContext');
  15357. asm
  15358. MOV ESP, EBP
  15359. POP EBP
  15360. JMP [_CertFreeCRLContext]
  15361. end;
  15362. end;
  15363. var
  15364. _CertSetCRLContextProperty: Pointer;
  15365. function CertSetCRLContextProperty;
  15366. begin
  15367. GetProcedureAddress(_CertSetCRLContextProperty, crypt32, 'CertSetCRLContextProperty');
  15368. asm
  15369. MOV ESP, EBP
  15370. POP EBP
  15371. JMP [_CertSetCRLContextProperty]
  15372. end;
  15373. end;
  15374. var
  15375. _CertGetCRLContextProperty: Pointer;
  15376. function CertGetCRLContextProperty;
  15377. begin
  15378. GetProcedureAddress(_CertGetCRLContextProperty, crypt32, 'CertGetCRLContextProperty');
  15379. asm
  15380. MOV ESP, EBP
  15381. POP EBP
  15382. JMP [_CertGetCRLContextProperty]
  15383. end;
  15384. end;
  15385. var
  15386. _CertEnumCRLContextProperties: Pointer;
  15387. function CertEnumCRLContextProperties;
  15388. begin
  15389. GetProcedureAddress(_CertEnumCRLContextProperties, crypt32, 'CertEnumCRLContextProperties');
  15390. asm
  15391. MOV ESP, EBP
  15392. POP EBP
  15393. JMP [_CertEnumCRLContextProperties]
  15394. end;
  15395. end;
  15396. var
  15397. _CertFindCertificateInCRL: Pointer;
  15398. function CertFindCertificateInCRL;
  15399. begin
  15400. GetProcedureAddress(_CertFindCertificateInCRL, crypt32, 'CertFindCertificateInCRL');
  15401. asm
  15402. MOV ESP, EBP
  15403. POP EBP
  15404. JMP [_CertFindCertificateInCRL]
  15405. end;
  15406. end;
  15407. var
  15408. _CertAddEncodedCertToStore: Pointer;
  15409. function CertAddEncodedCertificateToStore;
  15410. begin
  15411. GetProcedureAddress(_CertAddEncodedCertToStore, crypt32, 'CertAddEncodedCertificateToStore');
  15412. asm
  15413. MOV ESP, EBP
  15414. POP EBP
  15415. JMP [_CertAddEncodedCertToStore]
  15416. end;
  15417. end;
  15418. var
  15419. _CertAddCertContextToStore: Pointer;
  15420. function CertAddCertificateContextToStore;
  15421. begin
  15422. GetProcedureAddress(_CertAddCertContextToStore, crypt32, 'CertAddCertificateContextToStore');
  15423. asm
  15424. MOV ESP, EBP
  15425. POP EBP
  15426. JMP [_CertAddCertContextToStore]
  15427. end;
  15428. end;
  15429. var
  15430. _CertAddSerializedElementToStore: Pointer;
  15431. function CertAddSerializedElementToStore;
  15432. begin
  15433. GetProcedureAddress(_CertAddSerializedElementToStore, crypt32, 'CertAddSerializedElementToStore');
  15434. asm
  15435. MOV ESP, EBP
  15436. POP EBP
  15437. JMP [_CertAddSerializedElementToStore]
  15438. end;
  15439. end;
  15440. var
  15441. _CertDeleteCertificateFromStore: Pointer;
  15442. function CertDeleteCertificateFromStore;
  15443. begin
  15444. GetProcedureAddress(_CertDeleteCertificateFromStore, crypt32, 'CertDeleteCertificateFromStore');
  15445. asm
  15446. MOV ESP, EBP
  15447. POP EBP
  15448. JMP [_CertDeleteCertificateFromStore]
  15449. end;
  15450. end;
  15451. var
  15452. _CertAddEncodedCRLToStore: Pointer;
  15453. function CertAddEncodedCRLToStore;
  15454. begin
  15455. GetProcedureAddress(_CertAddEncodedCRLToStore, crypt32, 'CertAddEncodedCRLToStore');
  15456. asm
  15457. MOV ESP, EBP
  15458. POP EBP
  15459. JMP [_CertAddEncodedCRLToStore]
  15460. end;
  15461. end;
  15462. var
  15463. _CertAddCRLContextToStore: Pointer;
  15464. function CertAddCRLContextToStore;
  15465. begin
  15466. GetProcedureAddress(_CertAddCRLContextToStore, crypt32, 'CertAddCRLContextToStore');
  15467. asm
  15468. MOV ESP, EBP
  15469. POP EBP
  15470. JMP [_CertAddCRLContextToStore]
  15471. end;
  15472. end;
  15473. var
  15474. _CertDeleteCRLFromStore: Pointer;
  15475. function CertDeleteCRLFromStore;
  15476. begin
  15477. GetProcedureAddress(_CertDeleteCRLFromStore, crypt32, 'CertDeleteCRLFromStore');
  15478. asm
  15479. MOV ESP, EBP
  15480. POP EBP
  15481. JMP [_CertDeleteCRLFromStore]
  15482. end;
  15483. end;
  15484. var
  15485. _CertSerializeCertStoreElement: Pointer;
  15486. function CertSerializeCertificateStoreElement;
  15487. begin
  15488. GetProcedureAddress(_CertSerializeCertStoreElement, crypt32, 'CertSerializeCertificateStoreElement');
  15489. asm
  15490. MOV ESP, EBP
  15491. POP EBP
  15492. JMP [_CertSerializeCertStoreElement]
  15493. end;
  15494. end;
  15495. var
  15496. _CertSerializeCRLStoreElement: Pointer;
  15497. function CertSerializeCRLStoreElement;
  15498. begin
  15499. GetProcedureAddress(_CertSerializeCRLStoreElement, crypt32, 'CertSerializeCRLStoreElement');
  15500. asm
  15501. MOV ESP, EBP
  15502. POP EBP
  15503. JMP [_CertSerializeCRLStoreElement]
  15504. end;
  15505. end;
  15506. var
  15507. _CertDuplicateCTLContext: Pointer;
  15508. function CertDuplicateCTLContext;
  15509. begin
  15510. GetProcedureAddress(_CertDuplicateCTLContext, crypt32, 'CertDuplicateCTLContext');
  15511. asm
  15512. MOV ESP, EBP
  15513. POP EBP
  15514. JMP [_CertDuplicateCTLContext]
  15515. end;
  15516. end;
  15517. var
  15518. _CertCreateCTLContext: Pointer;
  15519. function CertCreateCTLContext;
  15520. begin
  15521. GetProcedureAddress(_CertCreateCTLContext, crypt32, 'CertCreateCTLContext');
  15522. asm
  15523. MOV ESP, EBP
  15524. POP EBP
  15525. JMP [_CertCreateCTLContext]
  15526. end;
  15527. end;
  15528. var
  15529. _CertFreeCTLContext: Pointer;
  15530. function CertFreeCTLContext;
  15531. begin
  15532. GetProcedureAddress(_CertFreeCTLContext, crypt32, 'CertFreeCTLContext');
  15533. asm
  15534. MOV ESP, EBP
  15535. POP EBP
  15536. JMP [_CertFreeCTLContext]
  15537. end;
  15538. end;
  15539. var
  15540. _CertSetCTLContextProperty: Pointer;
  15541. function CertSetCTLContextProperty;
  15542. begin
  15543. GetProcedureAddress(_CertSetCTLContextProperty, crypt32, 'CertSetCTLContextProperty');
  15544. asm
  15545. MOV ESP, EBP
  15546. POP EBP
  15547. JMP [_CertSetCTLContextProperty]
  15548. end;
  15549. end;
  15550. var
  15551. _CertGetCTLContextProperty: Pointer;
  15552. function CertGetCTLContextProperty;
  15553. begin
  15554. GetProcedureAddress(_CertGetCTLContextProperty, crypt32, 'CertGetCTLContextProperty');
  15555. asm
  15556. MOV ESP, EBP
  15557. POP EBP
  15558. JMP [_CertGetCTLContextProperty]
  15559. end;
  15560. end;
  15561. var
  15562. _CertEnumCTLContextProperties: Pointer;
  15563. function CertEnumCTLContextProperties;
  15564. begin
  15565. GetProcedureAddress(_CertEnumCTLContextProperties, crypt32, 'CertEnumCTLContextProperties');
  15566. asm
  15567. MOV ESP, EBP
  15568. POP EBP
  15569. JMP [_CertEnumCTLContextProperties]
  15570. end;
  15571. end;
  15572. var
  15573. _CertEnumCTLsInStore: Pointer;
  15574. function CertEnumCTLsInStore;
  15575. begin
  15576. GetProcedureAddress(_CertEnumCTLsInStore, crypt32, 'CertEnumCTLsInStore');
  15577. asm
  15578. MOV ESP, EBP
  15579. POP EBP
  15580. JMP [_CertEnumCTLsInStore]
  15581. end;
  15582. end;
  15583. var
  15584. _CertFindSubjectInCTL: Pointer;
  15585. function CertFindSubjectInCTL;
  15586. begin
  15587. GetProcedureAddress(_CertFindSubjectInCTL, crypt32, 'CertFindSubjectInCTL');
  15588. asm
  15589. MOV ESP, EBP
  15590. POP EBP
  15591. JMP [_CertFindSubjectInCTL]
  15592. end;
  15593. end;
  15594. var
  15595. _CertFindCTLInStore: Pointer;
  15596. function CertFindCTLInStore;
  15597. begin
  15598. GetProcedureAddress(_CertFindCTLInStore, crypt32, 'CertFindCTLInStore');
  15599. asm
  15600. MOV ESP, EBP
  15601. POP EBP
  15602. JMP [_CertFindCTLInStore]
  15603. end;
  15604. end;
  15605. var
  15606. _CertAddEncodedCTLToStore: Pointer;
  15607. function CertAddEncodedCTLToStore;
  15608. begin
  15609. GetProcedureAddress(_CertAddEncodedCTLToStore, crypt32, 'CertAddEncodedCTLToStore');
  15610. asm
  15611. MOV ESP, EBP
  15612. POP EBP
  15613. JMP [_CertAddEncodedCTLToStore]
  15614. end;
  15615. end;
  15616. var
  15617. _CertAddCTLContextToStore: Pointer;
  15618. function CertAddCTLContextToStore;
  15619. begin
  15620. GetProcedureAddress(_CertAddCTLContextToStore, crypt32, 'CertAddCTLContextToStore');
  15621. asm
  15622. MOV ESP, EBP
  15623. POP EBP
  15624. JMP [_CertAddCTLContextToStore]
  15625. end;
  15626. end;
  15627. var
  15628. _CertSerializeCTLStoreElement: Pointer;
  15629. function CertSerializeCTLStoreElement;
  15630. begin
  15631. GetProcedureAddress(_CertSerializeCTLStoreElement, crypt32, 'CertSerializeCTLStoreElement');
  15632. asm
  15633. MOV ESP, EBP
  15634. POP EBP
  15635. JMP [_CertSerializeCTLStoreElement]
  15636. end;
  15637. end;
  15638. var
  15639. _CertDeleteCTLFromStore: Pointer;
  15640. function CertDeleteCTLFromStore;
  15641. begin
  15642. GetProcedureAddress(_CertDeleteCTLFromStore, crypt32, 'CertDeleteCTLFromStore');
  15643. asm
  15644. MOV ESP, EBP
  15645. POP EBP
  15646. JMP [_CertDeleteCTLFromStore]
  15647. end;
  15648. end;
  15649. var
  15650. _CertAddCertificateLinkToStore: Pointer;
  15651. function CertAddCertificateLinkToStore;
  15652. begin
  15653. GetProcedureAddress(_CertAddCertificateLinkToStore, crypt32, 'CertAddCertificateLinkToStore');
  15654. asm
  15655. MOV ESP, EBP
  15656. POP EBP
  15657. JMP [_CertAddCertificateLinkToStore]
  15658. end;
  15659. end;
  15660. var
  15661. _CertAddCRLLinkToStore: Pointer;
  15662. function CertAddCRLLinkToStore;
  15663. begin
  15664. GetProcedureAddress(_CertAddCRLLinkToStore, crypt32, 'CertAddCRLLinkToStore');
  15665. asm
  15666. MOV ESP, EBP
  15667. POP EBP
  15668. JMP [_CertAddCRLLinkToStore]
  15669. end;
  15670. end;
  15671. var
  15672. _CertAddCTLLinkToStore: Pointer;
  15673. function CertAddCTLLinkToStore;
  15674. begin
  15675. GetProcedureAddress(_CertAddCTLLinkToStore, crypt32, 'CertAddCTLLinkToStore');
  15676. asm
  15677. MOV ESP, EBP
  15678. POP EBP
  15679. JMP [_CertAddCTLLinkToStore]
  15680. end;
  15681. end;
  15682. var
  15683. _CertAddStoreToCollection: Pointer;
  15684. function CertAddStoreToCollection;
  15685. begin
  15686. GetProcedureAddress(_CertAddStoreToCollection, crypt32, 'CertAddStoreToCollection');
  15687. asm
  15688. MOV ESP, EBP
  15689. POP EBP
  15690. JMP [_CertAddStoreToCollection]
  15691. end;
  15692. end;
  15693. var
  15694. _CertRemoveStoreFromCollection: Pointer;
  15695. procedure CertRemoveStoreFromCollection;
  15696. begin
  15697. GetProcedureAddress(_CertRemoveStoreFromCollection, crypt32, 'CertRemoveStoreFromCollection');
  15698. asm
  15699. MOV ESP, EBP
  15700. POP EBP
  15701. JMP [_CertRemoveStoreFromCollection]
  15702. end;
  15703. end;
  15704. var
  15705. _CertControlStore: Pointer;
  15706. function CertControlStore;
  15707. begin
  15708. GetProcedureAddress(_CertControlStore, crypt32, 'CertControlStore');
  15709. asm
  15710. MOV ESP, EBP
  15711. POP EBP
  15712. JMP [_CertControlStore]
  15713. end;
  15714. end;
  15715. var
  15716. _CertSetStoreProperty: Pointer;
  15717. function CertSetStoreProperty;
  15718. begin
  15719. GetProcedureAddress(_CertSetStoreProperty, crypt32, 'CertSetStoreProperty');
  15720. asm
  15721. MOV ESP, EBP
  15722. POP EBP
  15723. JMP [_CertSetStoreProperty]
  15724. end;
  15725. end;
  15726. var
  15727. _CertGetStoreProperty: Pointer;
  15728. function CertGetStoreProperty;
  15729. begin
  15730. GetProcedureAddress(_CertGetStoreProperty, crypt32, 'CertGetStoreProperty');
  15731. asm
  15732. MOV ESP, EBP
  15733. POP EBP
  15734. JMP [_CertGetStoreProperty]
  15735. end;
  15736. end;
  15737. var
  15738. _CertCreateContext: Pointer;
  15739. function CertCreateContext;
  15740. begin
  15741. GetProcedureAddress(_CertCreateContext, crypt32, 'CertCreateContext');
  15742. asm
  15743. MOV ESP, EBP
  15744. POP EBP
  15745. JMP [_CertCreateContext]
  15746. end;
  15747. end;
  15748. var
  15749. _CertRegisterSystemStore: Pointer;
  15750. function CertRegisterSystemStore;
  15751. begin
  15752. GetProcedureAddress(_CertRegisterSystemStore, crypt32, 'CertRegisterSystemStore');
  15753. asm
  15754. MOV ESP, EBP
  15755. POP EBP
  15756. JMP [_CertRegisterSystemStore]
  15757. end;
  15758. end;
  15759. var
  15760. _CertRegisterPhysicalStore: Pointer;
  15761. function CertRegisterPhysicalStore;
  15762. begin
  15763. GetProcedureAddress(_CertRegisterPhysicalStore, crypt32, 'CertRegisterPhysicalStore');
  15764. asm
  15765. MOV ESP, EBP
  15766. POP EBP
  15767. JMP [_CertRegisterPhysicalStore]
  15768. end;
  15769. end;
  15770. var
  15771. _CertUnregisterSystemStore: Pointer;
  15772. function CertUnregisterSystemStore;
  15773. begin
  15774. GetProcedureAddress(_CertUnregisterSystemStore, crypt32, 'CertUnregisterSystemStore');
  15775. asm
  15776. MOV ESP, EBP
  15777. POP EBP
  15778. JMP [_CertUnregisterSystemStore]
  15779. end;
  15780. end;
  15781. var
  15782. _CertUnregisterPhysicalStore: Pointer;
  15783. function CertUnregisterPhysicalStore;
  15784. begin
  15785. GetProcedureAddress(_CertUnregisterPhysicalStore, crypt32, 'CertUnregisterPhysicalStore');
  15786. asm
  15787. MOV ESP, EBP
  15788. POP EBP
  15789. JMP [_CertUnregisterPhysicalStore]
  15790. end;
  15791. end;
  15792. var
  15793. _CertEnumSystemStoreLocation: Pointer;
  15794. function CertEnumSystemStoreLocation;
  15795. begin
  15796. GetProcedureAddress(_CertEnumSystemStoreLocation, crypt32, 'CertEnumSystemStoreLocation');
  15797. asm
  15798. MOV ESP, EBP
  15799. POP EBP
  15800. JMP [_CertEnumSystemStoreLocation]
  15801. end;
  15802. end;
  15803. var
  15804. _CertEnumSystemStore: Pointer;
  15805. function CertEnumSystemStore;
  15806. begin
  15807. GetProcedureAddress(_CertEnumSystemStore, crypt32, 'CertEnumSystemStore');
  15808. asm
  15809. MOV ESP, EBP
  15810. POP EBP
  15811. JMP [_CertEnumSystemStore]
  15812. end;
  15813. end;
  15814. var
  15815. _CertEnumPhysicalStore: Pointer;
  15816. function CertEnumPhysicalStore;
  15817. begin
  15818. GetProcedureAddress(_CertEnumPhysicalStore, crypt32, 'CertEnumPhysicalStore');
  15819. asm
  15820. MOV ESP, EBP
  15821. POP EBP
  15822. JMP [_CertEnumPhysicalStore]
  15823. end;
  15824. end;
  15825. var
  15826. _CertGetEnhancedKeyUsage: Pointer;
  15827. function CertGetEnhancedKeyUsage;
  15828. begin
  15829. GetProcedureAddress(_CertGetEnhancedKeyUsage, crypt32, 'CertGetEnhancedKeyUsage');
  15830. asm
  15831. MOV ESP, EBP
  15832. POP EBP
  15833. JMP [_CertGetEnhancedKeyUsage]
  15834. end;
  15835. end;
  15836. var
  15837. _CertSetEnhancedKeyUsage: Pointer;
  15838. function CertSetEnhancedKeyUsage;
  15839. begin
  15840. GetProcedureAddress(_CertSetEnhancedKeyUsage, crypt32, 'CertSetEnhancedKeyUsage');
  15841. asm
  15842. MOV ESP, EBP
  15843. POP EBP
  15844. JMP [_CertSetEnhancedKeyUsage]
  15845. end;
  15846. end;
  15847. var
  15848. _CertAddEnhKeyUsageIdentifier: Pointer;
  15849. function CertAddEnhancedKeyUsageIdentifier;
  15850. begin
  15851. GetProcedureAddress(_CertAddEnhKeyUsageIdentifier, crypt32, 'CertAddEnhancedKeyUsageIdentifier');
  15852. asm
  15853. MOV ESP, EBP
  15854. POP EBP
  15855. JMP [_CertAddEnhKeyUsageIdentifier]
  15856. end;
  15857. end;
  15858. var
  15859. _CertRemoveEnhKeyUsageIdent: Pointer;
  15860. function CertRemoveEnhancedKeyUsageIdentifier;
  15861. begin
  15862. GetProcedureAddress(_CertRemoveEnhKeyUsageIdent, crypt32, 'CertRemoveEnhancedKeyUsageIdentifier');
  15863. asm
  15864. MOV ESP, EBP
  15865. POP EBP
  15866. JMP [_CertRemoveEnhKeyUsageIdent]
  15867. end;
  15868. end;
  15869. var
  15870. _CertGetValidUsages: Pointer;
  15871. function CertGetValidUsages;
  15872. begin
  15873. GetProcedureAddress(_CertGetValidUsages, crypt32, 'CertGetValidUsages');
  15874. asm
  15875. MOV ESP, EBP
  15876. POP EBP
  15877. JMP [_CertGetValidUsages]
  15878. end;
  15879. end;
  15880. var
  15881. _CryptMsgGetAndVerifySigner: Pointer;
  15882. function CryptMsgGetAndVerifySigner;
  15883. begin
  15884. GetProcedureAddress(_CryptMsgGetAndVerifySigner, crypt32, 'CryptMsgGetAndVerifySigner');
  15885. asm
  15886. MOV ESP, EBP
  15887. POP EBP
  15888. JMP [_CryptMsgGetAndVerifySigner]
  15889. end;
  15890. end;
  15891. var
  15892. _CryptMsgSignCTL: Pointer;
  15893. function CryptMsgSignCTL;
  15894. begin
  15895. GetProcedureAddress(_CryptMsgSignCTL, crypt32, 'CryptMsgSignCTL');
  15896. asm
  15897. MOV ESP, EBP
  15898. POP EBP
  15899. JMP [_CryptMsgSignCTL]
  15900. end;
  15901. end;
  15902. var
  15903. _CryptMsgEncodeAndSignCTL: Pointer;
  15904. function CryptMsgEncodeAndSignCTL;
  15905. begin
  15906. GetProcedureAddress(_CryptMsgEncodeAndSignCTL, crypt32, 'CryptMsgEncodeAndSignCTL');
  15907. asm
  15908. MOV ESP, EBP
  15909. POP EBP
  15910. JMP [_CryptMsgEncodeAndSignCTL]
  15911. end;
  15912. end;
  15913. var
  15914. _CertFindSubjectInSortedCTL: Pointer;
  15915. function CertFindSubjectInSortedCTL;
  15916. begin
  15917. GetProcedureAddress(_CertFindSubjectInSortedCTL, crypt32, 'CertFindSubjectInSortedCTL');
  15918. asm
  15919. MOV ESP, EBP
  15920. POP EBP
  15921. JMP [_CertFindSubjectInSortedCTL]
  15922. end;
  15923. end;
  15924. var
  15925. _CertEnumSubjectInSortedCTL: Pointer;
  15926. function CertEnumSubjectInSortedCTL;
  15927. begin
  15928. GetProcedureAddress(_CertEnumSubjectInSortedCTL, crypt32, 'CertEnumSubjectInSortedCTL');
  15929. asm
  15930. MOV ESP, EBP
  15931. POP EBP
  15932. JMP [_CertEnumSubjectInSortedCTL]
  15933. end;
  15934. end;
  15935. var
  15936. _CertVerifyCTLUsage: Pointer;
  15937. function CertVerifyCTLUsage;
  15938. begin
  15939. GetProcedureAddress(_CertVerifyCTLUsage, crypt32, 'CertVerifyCTLUsage');
  15940. asm
  15941. MOV ESP, EBP
  15942. POP EBP
  15943. JMP [_CertVerifyCTLUsage]
  15944. end;
  15945. end;
  15946. var
  15947. _CertVerifyRevocation: Pointer;
  15948. function CertVerifyRevocation;
  15949. begin
  15950. GetProcedureAddress(_CertVerifyRevocation, crypt32, 'CertVerifyRevocation');
  15951. asm
  15952. MOV ESP, EBP
  15953. POP EBP
  15954. JMP [_CertVerifyRevocation]
  15955. end;
  15956. end;
  15957. var
  15958. _CertCompareIntegerBlob: Pointer;
  15959. function CertCompareIntegerBlob;
  15960. begin
  15961. GetProcedureAddress(_CertCompareIntegerBlob, crypt32, 'CertCompareIntegerBlob');
  15962. asm
  15963. MOV ESP, EBP
  15964. POP EBP
  15965. JMP [_CertCompareIntegerBlob]
  15966. end;
  15967. end;
  15968. var
  15969. _CertCompareCertificate: Pointer;
  15970. function CertCompareCertificate;
  15971. begin
  15972. GetProcedureAddress(_CertCompareCertificate, crypt32, 'CertCompareCertificate');
  15973. asm
  15974. MOV ESP, EBP
  15975. POP EBP
  15976. JMP [_CertCompareCertificate]
  15977. end;
  15978. end;
  15979. var
  15980. _CertCompareCertificateName: Pointer;
  15981. function CertCompareCertificateName;
  15982. begin
  15983. GetProcedureAddress(_CertCompareCertificateName, crypt32, 'CertCompareCertificateName');
  15984. asm
  15985. MOV ESP, EBP
  15986. POP EBP
  15987. JMP [_CertCompareCertificateName]
  15988. end;
  15989. end;
  15990. var
  15991. _CertIsRDNAttrsInCertificateName: Pointer;
  15992. function CertIsRDNAttrsInCertificateName;
  15993. begin
  15994. GetProcedureAddress(_CertIsRDNAttrsInCertificateName, crypt32, 'CertIsRDNAttrsInCertificateName');
  15995. asm
  15996. MOV ESP, EBP
  15997. POP EBP
  15998. JMP [_CertIsRDNAttrsInCertificateName]
  15999. end;
  16000. end;
  16001. var
  16002. _CertComparePublicKeyInfo: Pointer;
  16003. function CertComparePublicKeyInfo;
  16004. begin
  16005. GetProcedureAddress(_CertComparePublicKeyInfo, crypt32, 'CertComparePublicKeyInfo');
  16006. asm
  16007. MOV ESP, EBP
  16008. POP EBP
  16009. JMP [_CertComparePublicKeyInfo]
  16010. end;
  16011. end;
  16012. var
  16013. _CertGetPublicKeyLength: Pointer;
  16014. function CertGetPublicKeyLength;
  16015. begin
  16016. GetProcedureAddress(_CertGetPublicKeyLength, crypt32, 'CertGetPublicKeyLength');
  16017. asm
  16018. MOV ESP, EBP
  16019. POP EBP
  16020. JMP [_CertGetPublicKeyLength]
  16021. end;
  16022. end;
  16023. var
  16024. _CryptVerifyCertificateSignature: Pointer;
  16025. function CryptVerifyCertificateSignature;
  16026. begin
  16027. GetProcedureAddress(_CryptVerifyCertificateSignature, crypt32, 'CryptVerifyCertificateSignature');
  16028. asm
  16029. MOV ESP, EBP
  16030. POP EBP
  16031. JMP [_CryptVerifyCertificateSignature]
  16032. end;
  16033. end;
  16034. var
  16035. _CryptVerifyCertSignatureEx: Pointer;
  16036. function CryptVerifyCertificateSignatureEx;
  16037. begin
  16038. GetProcedureAddress(_CryptVerifyCertSignatureEx, crypt32, 'CryptVerifyCertificateSignatureEx');
  16039. asm
  16040. MOV ESP, EBP
  16041. POP EBP
  16042. JMP [_CryptVerifyCertSignatureEx]
  16043. end;
  16044. end;
  16045. var
  16046. _CryptHashToBeSigned: Pointer;
  16047. function CryptHashToBeSigned;
  16048. begin
  16049. GetProcedureAddress(_CryptHashToBeSigned, crypt32, 'CryptHashToBeSigned');
  16050. asm
  16051. MOV ESP, EBP
  16052. POP EBP
  16053. JMP [_CryptHashToBeSigned]
  16054. end;
  16055. end;
  16056. var
  16057. _CryptHashCertificate: Pointer;
  16058. function CryptHashCertificate;
  16059. begin
  16060. GetProcedureAddress(_CryptHashCertificate, crypt32, 'CryptHashCertificate');
  16061. asm
  16062. MOV ESP, EBP
  16063. POP EBP
  16064. JMP [_CryptHashCertificate]
  16065. end;
  16066. end;
  16067. var
  16068. _CryptSignCertificate: Pointer;
  16069. function CryptSignCertificate;
  16070. begin
  16071. GetProcedureAddress(_CryptSignCertificate, crypt32, 'CryptSignCertificate');
  16072. asm
  16073. MOV ESP, EBP
  16074. POP EBP
  16075. JMP [_CryptSignCertificate]
  16076. end;
  16077. end;
  16078. var
  16079. _CryptSignAndEncodeCertificate: Pointer;
  16080. function CryptSignAndEncodeCertificate;
  16081. begin
  16082. GetProcedureAddress(_CryptSignAndEncodeCertificate, crypt32, 'CryptSignAndEncodeCertificate');
  16083. asm
  16084. MOV ESP, EBP
  16085. POP EBP
  16086. JMP [_CryptSignAndEncodeCertificate]
  16087. end;
  16088. end;
  16089. var
  16090. _CertVerifyTimeValidity: Pointer;
  16091. function CertVerifyTimeValidity;
  16092. begin
  16093. GetProcedureAddress(_CertVerifyTimeValidity, crypt32, 'CertVerifyTimeValidity');
  16094. asm
  16095. MOV ESP, EBP
  16096. POP EBP
  16097. JMP [_CertVerifyTimeValidity]
  16098. end;
  16099. end;
  16100. var
  16101. _CertVerifyCRLTimeValidity: Pointer;
  16102. function CertVerifyCRLTimeValidity;
  16103. begin
  16104. GetProcedureAddress(_CertVerifyCRLTimeValidity, crypt32, 'CertVerifyCRLTimeValidity');
  16105. asm
  16106. MOV ESP, EBP
  16107. POP EBP
  16108. JMP [_CertVerifyCRLTimeValidity]
  16109. end;
  16110. end;
  16111. var
  16112. _CertVerifyValidityNesting: Pointer;
  16113. function CertVerifyValidityNesting;
  16114. begin
  16115. GetProcedureAddress(_CertVerifyValidityNesting, crypt32, 'CertVerifyValidityNesting');
  16116. asm
  16117. MOV ESP, EBP
  16118. POP EBP
  16119. JMP [_CertVerifyValidityNesting]
  16120. end;
  16121. end;
  16122. var
  16123. _CertVerifyCRLRevocation: Pointer;
  16124. function CertVerifyCRLRevocation;
  16125. begin
  16126. GetProcedureAddress(_CertVerifyCRLRevocation, crypt32, 'CertVerifyCRLRevocation');
  16127. asm
  16128. MOV ESP, EBP
  16129. POP EBP
  16130. JMP [_CertVerifyCRLRevocation]
  16131. end;
  16132. end;
  16133. var
  16134. _CertAlgIdToOID: Pointer;
  16135. function CertAlgIdToOID;
  16136. begin
  16137. GetProcedureAddress(_CertAlgIdToOID, crypt32, 'CertAlgIdToOID');
  16138. asm
  16139. MOV ESP, EBP
  16140. POP EBP
  16141. JMP [_CertAlgIdToOID]
  16142. end;
  16143. end;
  16144. var
  16145. _CertOIDToAlgId: Pointer;
  16146. function CertOIDToAlgId;
  16147. begin
  16148. GetProcedureAddress(_CertOIDToAlgId, crypt32, 'CertOIDToAlgId');
  16149. asm
  16150. MOV ESP, EBP
  16151. POP EBP
  16152. JMP [_CertOIDToAlgId]
  16153. end;
  16154. end;
  16155. var
  16156. _CertFindExtension: Pointer;
  16157. function CertFindExtension;
  16158. begin
  16159. GetProcedureAddress(_CertFindExtension, crypt32, 'CertFindExtension');
  16160. asm
  16161. MOV ESP, EBP
  16162. POP EBP
  16163. JMP [_CertFindExtension]
  16164. end;
  16165. end;
  16166. var
  16167. _CertFindAttribute: Pointer;
  16168. function CertFindAttribute;
  16169. begin
  16170. GetProcedureAddress(_CertFindAttribute, crypt32, 'CertFindAttribute');
  16171. asm
  16172. MOV ESP, EBP
  16173. POP EBP
  16174. JMP [_CertFindAttribute]
  16175. end;
  16176. end;
  16177. var
  16178. _CertFindRDNAttr: Pointer;
  16179. function CertFindRDNAttr;
  16180. begin
  16181. GetProcedureAddress(_CertFindRDNAttr, crypt32, 'CertFindRDNAttr');
  16182. asm
  16183. MOV ESP, EBP
  16184. POP EBP
  16185. JMP [_CertFindRDNAttr]
  16186. end;
  16187. end;
  16188. var
  16189. _CertGetIntendedKeyUsage: Pointer;
  16190. function CertGetIntendedKeyUsage;
  16191. begin
  16192. GetProcedureAddress(_CertGetIntendedKeyUsage, crypt32, 'CertGetIntendedKeyUsage');
  16193. asm
  16194. MOV ESP, EBP
  16195. POP EBP
  16196. JMP [_CertGetIntendedKeyUsage]
  16197. end;
  16198. end;
  16199. var
  16200. _CryptInstallDefaultContext: Pointer;
  16201. function CryptInstallDefaultContext;
  16202. begin
  16203. GetProcedureAddress(_CryptInstallDefaultContext, crypt32, 'CryptInstallDefaultContext');
  16204. asm
  16205. MOV ESP, EBP
  16206. POP EBP
  16207. JMP [_CryptInstallDefaultContext]
  16208. end;
  16209. end;
  16210. var
  16211. _CryptUninstallDefaultContext: Pointer;
  16212. function CryptUninstallDefaultContext;
  16213. begin
  16214. GetProcedureAddress(_CryptUninstallDefaultContext, crypt32, 'CryptUninstallDefaultContext');
  16215. asm
  16216. MOV ESP, EBP
  16217. POP EBP
  16218. JMP [_CryptUninstallDefaultContext]
  16219. end;
  16220. end;
  16221. var
  16222. _CryptExportPublicKeyInfo: Pointer;
  16223. function CryptExportPublicKeyInfo;
  16224. begin
  16225. GetProcedureAddress(_CryptExportPublicKeyInfo, crypt32, 'CryptExportPublicKeyInfo');
  16226. asm
  16227. MOV ESP, EBP
  16228. POP EBP
  16229. JMP [_CryptExportPublicKeyInfo]
  16230. end;
  16231. end;
  16232. var
  16233. _CryptExportPublicKeyInfoEx: Pointer;
  16234. function CryptExportPublicKeyInfoEx;
  16235. begin
  16236. GetProcedureAddress(_CryptExportPublicKeyInfoEx, crypt32, 'CryptExportPublicKeyInfoEx');
  16237. asm
  16238. MOV ESP, EBP
  16239. POP EBP
  16240. JMP [_CryptExportPublicKeyInfoEx]
  16241. end;
  16242. end;
  16243. var
  16244. _CryptImportPublicKeyInfo: Pointer;
  16245. function CryptImportPublicKeyInfo;
  16246. begin
  16247. GetProcedureAddress(_CryptImportPublicKeyInfo, crypt32, 'CryptImportPublicKeyInfo');
  16248. asm
  16249. MOV ESP, EBP
  16250. POP EBP
  16251. JMP [_CryptImportPublicKeyInfo]
  16252. end;
  16253. end;
  16254. var
  16255. _CryptImportPublicKeyInfoEx: Pointer;
  16256. function CryptImportPublicKeyInfoEx;
  16257. begin
  16258. GetProcedureAddress(_CryptImportPublicKeyInfoEx, crypt32, 'CryptImportPublicKeyInfoEx');
  16259. asm
  16260. MOV ESP, EBP
  16261. POP EBP
  16262. JMP [_CryptImportPublicKeyInfoEx]
  16263. end;
  16264. end;
  16265. var
  16266. _CryptAcquireCertPrivateKey: Pointer;
  16267. function CryptAcquireCertificatePrivateKey;
  16268. begin
  16269. GetProcedureAddress(_CryptAcquireCertPrivateKey, crypt32, 'CryptAcquireCertificatePrivateKey');
  16270. asm
  16271. MOV ESP, EBP
  16272. POP EBP
  16273. JMP [_CryptAcquireCertPrivateKey]
  16274. end;
  16275. end;
  16276. var
  16277. _CryptFindCertificateKeyProvInfo: Pointer;
  16278. function CryptFindCertificateKeyProvInfo;
  16279. begin
  16280. GetProcedureAddress(_CryptFindCertificateKeyProvInfo, crypt32, 'CryptFindCertificateKeyProvInfo');
  16281. asm
  16282. MOV ESP, EBP
  16283. POP EBP
  16284. JMP [_CryptFindCertificateKeyProvInfo]
  16285. end;
  16286. end;
  16287. var
  16288. _CryptImportPKCS8: Pointer;
  16289. function CryptImportPKCS8;
  16290. begin
  16291. GetProcedureAddress(_CryptImportPKCS8, crypt32, 'CryptImportPKCS8');
  16292. asm
  16293. MOV ESP, EBP
  16294. POP EBP
  16295. JMP [_CryptImportPKCS8]
  16296. end;
  16297. end;
  16298. var
  16299. _CryptExportPKCS8: Pointer;
  16300. function CryptExportPKCS8;
  16301. begin
  16302. GetProcedureAddress(_CryptExportPKCS8, crypt32, 'CryptExportPKCS8');
  16303. asm
  16304. MOV ESP, EBP
  16305. POP EBP
  16306. JMP [_CryptExportPKCS8]
  16307. end;
  16308. end;
  16309. var
  16310. _CryptExportPKCS8Ex: Pointer;
  16311. function CryptExportPKCS8Ex;
  16312. begin
  16313. GetProcedureAddress(_CryptExportPKCS8Ex, crypt32, 'CryptExportPKCS8Ex');
  16314. asm
  16315. MOV ESP, EBP
  16316. POP EBP
  16317. JMP [_CryptExportPKCS8Ex]
  16318. end;
  16319. end;
  16320. var
  16321. _CryptHashPublicKeyInfo: Pointer;
  16322. function CryptHashPublicKeyInfo;
  16323. begin
  16324. GetProcedureAddress(_CryptHashPublicKeyInfo, crypt32, 'CryptHashPublicKeyInfo');
  16325. asm
  16326. MOV ESP, EBP
  16327. POP EBP
  16328. JMP [_CryptHashPublicKeyInfo]
  16329. end;
  16330. end;
  16331. var
  16332. _CertRDNValueToStrA: Pointer;
  16333. function CertRDNValueToStrA;
  16334. begin
  16335. GetProcedureAddress(_CertRDNValueToStrA, crypt32, 'CertRDNValueToStrA');
  16336. asm
  16337. MOV ESP, EBP
  16338. POP EBP
  16339. JMP [_CertRDNValueToStrA]
  16340. end;
  16341. end;
  16342. var
  16343. _CertRDNValueToStrW: Pointer;
  16344. function CertRDNValueToStrW;
  16345. begin
  16346. GetProcedureAddress(_CertRDNValueToStrW, crypt32, 'CertRDNValueToStrW');
  16347. asm
  16348. MOV ESP, EBP
  16349. POP EBP
  16350. JMP [_CertRDNValueToStrW]
  16351. end;
  16352. end;
  16353. var
  16354. _CertRDNValueToStr: Pointer;
  16355. function CertRDNValueToStr;
  16356. begin
  16357. GetProcedureAddress(_CertRDNValueToStr, crypt32, 'CertRDNValueToStr' + AWSuffix);
  16358. asm
  16359. MOV ESP, EBP
  16360. POP EBP
  16361. JMP [_CertRDNValueToStr]
  16362. end;
  16363. end;
  16364. var
  16365. _CertNameToStrA: Pointer;
  16366. function CertNameToStrA;
  16367. begin
  16368. GetProcedureAddress(_CertNameToStrA, crypt32, 'CertNameToStrA');
  16369. asm
  16370. MOV ESP, EBP
  16371. POP EBP
  16372. JMP [_CertNameToStrA]
  16373. end;
  16374. end;
  16375. var
  16376. _CertNameToStrW: Pointer;
  16377. function CertNameToStrW;
  16378. begin
  16379. GetProcedureAddress(_CertNameToStrW, crypt32, 'CertNameToStrW');
  16380. asm
  16381. MOV ESP, EBP
  16382. POP EBP
  16383. JMP [_CertNameToStrW]
  16384. end;
  16385. end;
  16386. var
  16387. _CertNameToStr: Pointer;
  16388. function CertNameToStr;
  16389. begin
  16390. GetProcedureAddress(_CertNameToStr, crypt32, 'CertNameToStr' + AWSuffix);
  16391. asm
  16392. MOV ESP, EBP
  16393. POP EBP
  16394. JMP [_CertNameToStr]
  16395. end;
  16396. end;
  16397. var
  16398. _CertStrToNameA: Pointer;
  16399. function CertStrToNameA;
  16400. begin
  16401. GetProcedureAddress(_CertStrToNameA, crypt32, 'CertStrToNameA');
  16402. asm
  16403. MOV ESP, EBP
  16404. POP EBP
  16405. JMP [_CertStrToNameA]
  16406. end;
  16407. end;
  16408. var
  16409. _CertStrToNameW: Pointer;
  16410. function CertStrToNameW;
  16411. begin
  16412. GetProcedureAddress(_CertStrToNameW, crypt32, 'CertStrToNameW');
  16413. asm
  16414. MOV ESP, EBP
  16415. POP EBP
  16416. JMP [_CertStrToNameW]
  16417. end;
  16418. end;
  16419. var
  16420. _CertStrToName: Pointer;
  16421. function CertStrToName;
  16422. begin
  16423. GetProcedureAddress(_CertStrToName, crypt32, 'CertStrToName' + AWSuffix);
  16424. asm
  16425. MOV ESP, EBP
  16426. POP EBP
  16427. JMP [_CertStrToName]
  16428. end;
  16429. end;
  16430. var
  16431. _CertGetNameStringA: Pointer;
  16432. function CertGetNameStringA;
  16433. begin
  16434. GetProcedureAddress(_CertGetNameStringA, crypt32, 'CertGetNameStringA');
  16435. asm
  16436. MOV ESP, EBP
  16437. POP EBP
  16438. JMP [_CertGetNameStringA]
  16439. end;
  16440. end;
  16441. var
  16442. _CertGetNameStringW: Pointer;
  16443. function CertGetNameStringW;
  16444. begin
  16445. GetProcedureAddress(_CertGetNameStringW, crypt32, 'CertGetNameStringW');
  16446. asm
  16447. MOV ESP, EBP
  16448. POP EBP
  16449. JMP [_CertGetNameStringW]
  16450. end;
  16451. end;
  16452. var
  16453. _CertGetNameString: Pointer;
  16454. function CertGetNameString;
  16455. begin
  16456. GetProcedureAddress(_CertGetNameString, crypt32, 'CertGetNameString' + AWSuffix);
  16457. asm
  16458. MOV ESP, EBP
  16459. POP EBP
  16460. JMP [_CertGetNameString]
  16461. end;
  16462. end;
  16463. var
  16464. _CryptSignMessage: Pointer;
  16465. function CryptSignMessage;
  16466. begin
  16467. GetProcedureAddress(_CryptSignMessage, crypt32, 'CryptSignMessage');
  16468. asm
  16469. MOV ESP, EBP
  16470. POP EBP
  16471. JMP [_CryptSignMessage]
  16472. end;
  16473. end;
  16474. var
  16475. _CryptVerifyMessageSignature: Pointer;
  16476. function CryptVerifyMessageSignature;
  16477. begin
  16478. GetProcedureAddress(_CryptVerifyMessageSignature, crypt32, 'CryptVerifyMessageSignature');
  16479. asm
  16480. MOV ESP, EBP
  16481. POP EBP
  16482. JMP [_CryptVerifyMessageSignature]
  16483. end;
  16484. end;
  16485. var
  16486. _CryptGetMessageSignerCount: Pointer;
  16487. function CryptGetMessageSignerCount;
  16488. begin
  16489. GetProcedureAddress(_CryptGetMessageSignerCount, crypt32, 'CryptGetMessageSignerCount');
  16490. asm
  16491. MOV ESP, EBP
  16492. POP EBP
  16493. JMP [_CryptGetMessageSignerCount]
  16494. end;
  16495. end;
  16496. var
  16497. _CryptGetMessageCertificates: Pointer;
  16498. function CryptGetMessageCertificates;
  16499. begin
  16500. GetProcedureAddress(_CryptGetMessageCertificates, crypt32, 'CryptGetMessageCertificates');
  16501. asm
  16502. MOV ESP, EBP
  16503. POP EBP
  16504. JMP [_CryptGetMessageCertificates]
  16505. end;
  16506. end;
  16507. var
  16508. _CryptVerDetachedMsgSignature: Pointer;
  16509. function CryptVerifyDetachedMessageSignature;
  16510. begin
  16511. GetProcedureAddress(_CryptVerDetachedMsgSignature, crypt32, 'CryptVerifyDetachedMessageSignature');
  16512. asm
  16513. MOV ESP, EBP
  16514. POP EBP
  16515. JMP [_CryptVerDetachedMsgSignature]
  16516. end;
  16517. end;
  16518. var
  16519. _CryptEncryptMessage: Pointer;
  16520. function CryptEncryptMessage;
  16521. begin
  16522. GetProcedureAddress(_CryptEncryptMessage, crypt32, 'CryptEncryptMessage');
  16523. asm
  16524. MOV ESP, EBP
  16525. POP EBP
  16526. JMP [_CryptEncryptMessage]
  16527. end;
  16528. end;
  16529. var
  16530. _CryptDecryptMessage: Pointer;
  16531. function CryptDecryptMessage;
  16532. begin
  16533. GetProcedureAddress(_CryptDecryptMessage, crypt32, 'CryptDecryptMessage');
  16534. asm
  16535. MOV ESP, EBP
  16536. POP EBP
  16537. JMP [_CryptDecryptMessage]
  16538. end;
  16539. end;
  16540. var
  16541. _CryptSignAndEncryptMessage: Pointer;
  16542. function CryptSignAndEncryptMessage;
  16543. begin
  16544. GetProcedureAddress(_CryptSignAndEncryptMessage, crypt32, 'CryptSignAndEncryptMessage');
  16545. asm
  16546. MOV ESP, EBP
  16547. POP EBP
  16548. JMP [_CryptSignAndEncryptMessage]
  16549. end;
  16550. end;
  16551. var
  16552. _CryptDecryptAndVerMsgSig: Pointer;
  16553. function CryptDecryptAndVerifyMessageSignature;
  16554. begin
  16555. GetProcedureAddress(_CryptDecryptAndVerMsgSig, crypt32, 'CryptDecryptAndVerifyMessageSignature');
  16556. asm
  16557. MOV ESP, EBP
  16558. POP EBP
  16559. JMP [_CryptDecryptAndVerMsgSig]
  16560. end;
  16561. end;
  16562. var
  16563. _CryptDecodeMessage: Pointer;
  16564. function CryptDecodeMessage;
  16565. begin
  16566. GetProcedureAddress(_CryptDecodeMessage, crypt32, 'CryptDecodeMessage');
  16567. asm
  16568. MOV ESP, EBP
  16569. POP EBP
  16570. JMP [_CryptDecodeMessage]
  16571. end;
  16572. end;
  16573. var
  16574. _CryptHashMessage: Pointer;
  16575. function CryptHashMessage;
  16576. begin
  16577. GetProcedureAddress(_CryptHashMessage, crypt32, 'CryptHashMessage');
  16578. asm
  16579. MOV ESP, EBP
  16580. POP EBP
  16581. JMP [_CryptHashMessage]
  16582. end;
  16583. end;
  16584. var
  16585. _CryptVerifyMessageHash: Pointer;
  16586. function CryptVerifyMessageHash;
  16587. begin
  16588. GetProcedureAddress(_CryptVerifyMessageHash, crypt32, 'CryptVerifyMessageHash');
  16589. asm
  16590. MOV ESP, EBP
  16591. POP EBP
  16592. JMP [_CryptVerifyMessageHash]
  16593. end;
  16594. end;
  16595. var
  16596. _CryptVerifyDetachedMessageHash: Pointer;
  16597. function CryptVerifyDetachedMessageHash;
  16598. begin
  16599. GetProcedureAddress(_CryptVerifyDetachedMessageHash, crypt32, 'CryptVerifyDetachedMessageHash');
  16600. asm
  16601. MOV ESP, EBP
  16602. POP EBP
  16603. JMP [_CryptVerifyDetachedMessageHash]
  16604. end;
  16605. end;
  16606. var
  16607. _CryptSignMessageWithKey: Pointer;
  16608. function CryptSignMessageWithKey;
  16609. begin
  16610. GetProcedureAddress(_CryptSignMessageWithKey, crypt32, 'CryptSignMessageWithKey');
  16611. asm
  16612. MOV ESP, EBP
  16613. POP EBP
  16614. JMP [_CryptSignMessageWithKey]
  16615. end;
  16616. end;
  16617. var
  16618. _CryptVerifyMsgSigWithKey: Pointer;
  16619. function CryptVerifyMessageSignatureWithKey;
  16620. begin
  16621. GetProcedureAddress(_CryptVerifyMsgSigWithKey, crypt32, 'CryptVerifyMessageSignatureWithKey');
  16622. asm
  16623. MOV ESP, EBP
  16624. POP EBP
  16625. JMP [_CryptVerifyMsgSigWithKey]
  16626. end;
  16627. end;
  16628. var
  16629. _CertOpenSystemStoreA: Pointer;
  16630. function CertOpenSystemStoreA;
  16631. begin
  16632. GetProcedureAddress(_CertOpenSystemStoreA, crypt32, 'CertOpenSystemStoreA');
  16633. asm
  16634. MOV ESP, EBP
  16635. POP EBP
  16636. JMP [_CertOpenSystemStoreA]
  16637. end;
  16638. end;
  16639. var
  16640. _CertOpenSystemStoreW: Pointer;
  16641. function CertOpenSystemStoreW;
  16642. begin
  16643. GetProcedureAddress(_CertOpenSystemStoreW, crypt32, 'CertOpenSystemStoreW');
  16644. asm
  16645. MOV ESP, EBP
  16646. POP EBP
  16647. JMP [_CertOpenSystemStoreW]
  16648. end;
  16649. end;
  16650. var
  16651. _CertOpenSystemStore: Pointer;
  16652. function CertOpenSystemStore;
  16653. begin
  16654. GetProcedureAddress(_CertOpenSystemStore, crypt32, 'CertOpenSystemStore' + AWSuffix);
  16655. asm
  16656. MOV ESP, EBP
  16657. POP EBP
  16658. JMP [_CertOpenSystemStore]
  16659. end;
  16660. end;
  16661. var
  16662. _CertAddEncodedCertToSysStoreA: Pointer;
  16663. function CertAddEncodedCertificateToSystemStoreA;
  16664. begin
  16665. GetProcedureAddress(_CertAddEncodedCertToSysStoreA, crypt32, 'CertAddEncodedCertificateToSystemStoreA');
  16666. asm
  16667. MOV ESP, EBP
  16668. POP EBP
  16669. JMP [_CertAddEncodedCertToSysStoreA]
  16670. end;
  16671. end;
  16672. var
  16673. _CertAddEncodedCertToSysStoreW: Pointer;
  16674. function CertAddEncodedCertificateToSystemStoreW;
  16675. begin
  16676. GetProcedureAddress(_CertAddEncodedCertToSysStoreW, crypt32, 'CertAddEncodedCertificateToSystemStoreW');
  16677. asm
  16678. MOV ESP, EBP
  16679. POP EBP
  16680. JMP [_CertAddEncodedCertToSysStoreW]
  16681. end;
  16682. end;
  16683. var
  16684. _CertAddEncodedCertToSysStore: Pointer;
  16685. function CertAddEncodedCertificateToSystemStore;
  16686. begin
  16687. GetProcedureAddress(_CertAddEncodedCertToSysStore, crypt32, 'CertAddEncodedCertificateToSystemStore' + AWSuffix);
  16688. asm
  16689. MOV ESP, EBP
  16690. POP EBP
  16691. JMP [_CertAddEncodedCertToSysStore]
  16692. end;
  16693. end;
  16694. var
  16695. _FindCertsByIssuer: Pointer;
  16696. function FindCertsByIssuer;
  16697. begin
  16698. GetProcedureAddress(_FindCertsByIssuer, softpub, 'FindCertsByIssuer');
  16699. asm
  16700. MOV ESP, EBP
  16701. POP EBP
  16702. JMP [_FindCertsByIssuer]
  16703. end;
  16704. end;
  16705. var
  16706. _CryptQueryObject: Pointer;
  16707. function CryptQueryObject;
  16708. begin
  16709. GetProcedureAddress(_CryptQueryObject, crypt32, 'CryptQueryObject');
  16710. asm
  16711. MOV ESP, EBP
  16712. POP EBP
  16713. JMP [_CryptQueryObject]
  16714. end;
  16715. end;
  16716. var
  16717. _CryptMemAlloc: Pointer;
  16718. function CryptMemAlloc;
  16719. begin
  16720. GetProcedureAddress(_CryptMemAlloc, crypt32, 'CryptMemAlloc');
  16721. asm
  16722. MOV ESP, EBP
  16723. POP EBP
  16724. JMP [_CryptMemAlloc]
  16725. end;
  16726. end;
  16727. var
  16728. _CryptMemRealloc: Pointer;
  16729. function CryptMemRealloc;
  16730. begin
  16731. GetProcedureAddress(_CryptMemRealloc, crypt32, 'CryptMemRealloc');
  16732. asm
  16733. MOV ESP, EBP
  16734. POP EBP
  16735. JMP [_CryptMemRealloc]
  16736. end;
  16737. end;
  16738. var
  16739. _CryptMemFree: Pointer;
  16740. procedure CryptMemFree;
  16741. begin
  16742. GetProcedureAddress(_CryptMemFree, crypt32, 'CryptMemFree');
  16743. asm
  16744. MOV ESP, EBP
  16745. POP EBP
  16746. JMP [_CryptMemFree]
  16747. end;
  16748. end;
  16749. var
  16750. _CryptCreateAsyncHandle: Pointer;
  16751. function CryptCreateAsyncHandle;
  16752. begin
  16753. GetProcedureAddress(_CryptCreateAsyncHandle, crypt32, 'CryptCreateAsyncHandle');
  16754. asm
  16755. MOV ESP, EBP
  16756. POP EBP
  16757. JMP [_CryptCreateAsyncHandle]
  16758. end;
  16759. end;
  16760. var
  16761. _CryptSetAsyncParam: Pointer;
  16762. function CryptSetAsyncParam;
  16763. begin
  16764. GetProcedureAddress(_CryptSetAsyncParam, crypt32, 'CryptSetAsyncParam');
  16765. asm
  16766. MOV ESP, EBP
  16767. POP EBP
  16768. JMP [_CryptSetAsyncParam]
  16769. end;
  16770. end;
  16771. var
  16772. _CryptGetAsyncParam: Pointer;
  16773. function CryptGetAsyncParam;
  16774. begin
  16775. GetProcedureAddress(_CryptGetAsyncParam, crypt32, 'CryptGetAsyncParam');
  16776. asm
  16777. MOV ESP, EBP
  16778. POP EBP
  16779. JMP [_CryptGetAsyncParam]
  16780. end;
  16781. end;
  16782. var
  16783. _CryptCloseAsyncHandle: Pointer;
  16784. function CryptCloseAsyncHandle;
  16785. begin
  16786. GetProcedureAddress(_CryptCloseAsyncHandle, crypt32, 'CryptCloseAsyncHandle');
  16787. asm
  16788. MOV ESP, EBP
  16789. POP EBP
  16790. JMP [_CryptCloseAsyncHandle]
  16791. end;
  16792. end;
  16793. var
  16794. _CryptRetrieveObjectByUrlA: Pointer;
  16795. function CryptRetrieveObjectByUrlA;
  16796. begin
  16797. GetProcedureAddress(_CryptRetrieveObjectByUrlA, crypt32, 'CryptRetrieveObjectByUrlA');
  16798. asm
  16799. MOV ESP, EBP
  16800. POP EBP
  16801. JMP [_CryptRetrieveObjectByUrlA]
  16802. end;
  16803. end;
  16804. var
  16805. _CryptRetrieveObjectByUrlW: Pointer;
  16806. function CryptRetrieveObjectByUrlW;
  16807. begin
  16808. GetProcedureAddress(_CryptRetrieveObjectByUrlW, crypt32, 'CryptRetrieveObjectByUrlW');
  16809. asm
  16810. MOV ESP, EBP
  16811. POP EBP
  16812. JMP [_CryptRetrieveObjectByUrlW]
  16813. end;
  16814. end;
  16815. var
  16816. _CryptRetrieveObjectByUrl: Pointer;
  16817. function CryptRetrieveObjectByUrl;
  16818. begin
  16819. GetProcedureAddress(_CryptRetrieveObjectByUrl, crypt32, 'CryptRetrieveObjectByUrl' + AWSuffix);
  16820. asm
  16821. MOV ESP, EBP
  16822. POP EBP
  16823. JMP [_CryptRetrieveObjectByUrl]
  16824. end;
  16825. end;
  16826. var
  16827. _CryptInstallCancelRetrieval: Pointer;
  16828. function CryptInstallCancelRetrieval;
  16829. begin
  16830. GetProcedureAddress(_CryptInstallCancelRetrieval, crypt32, 'CryptInstallCancelRetrieval');
  16831. asm
  16832. MOV ESP, EBP
  16833. POP EBP
  16834. JMP [_CryptInstallCancelRetrieval]
  16835. end;
  16836. end;
  16837. var
  16838. _CryptUninstallCancelRetrieval: Pointer;
  16839. function CryptUninstallCancelRetrieval;
  16840. begin
  16841. GetProcedureAddress(_CryptUninstallCancelRetrieval, crypt32, 'CryptUninstallCancelRetrieval');
  16842. asm
  16843. MOV ESP, EBP
  16844. POP EBP
  16845. JMP [_CryptUninstallCancelRetrieval]
  16846. end;
  16847. end;
  16848. var
  16849. _CryptCancelAsyncRetrieval: Pointer;
  16850. function CryptCancelAsyncRetrieval;
  16851. begin
  16852. GetProcedureAddress(_CryptCancelAsyncRetrieval, crypt32, 'CryptCancelAsyncRetrieval');
  16853. asm
  16854. MOV ESP, EBP
  16855. POP EBP
  16856. JMP [_CryptCancelAsyncRetrieval]
  16857. end;
  16858. end;
  16859. var
  16860. _CryptGetObjectUrl: Pointer;
  16861. function CryptGetObjectUrl;
  16862. begin
  16863. GetProcedureAddress(_CryptGetObjectUrl, crypt32, 'CryptGetObjectUrl');
  16864. asm
  16865. MOV ESP, EBP
  16866. POP EBP
  16867. JMP [_CryptGetObjectUrl]
  16868. end;
  16869. end;
  16870. var
  16871. _CryptGetTimeValidObject: Pointer;
  16872. function CryptGetTimeValidObject;
  16873. begin
  16874. GetProcedureAddress(_CryptGetTimeValidObject, crypt32, 'CryptGetTimeValidObject');
  16875. asm
  16876. MOV ESP, EBP
  16877. POP EBP
  16878. JMP [_CryptGetTimeValidObject]
  16879. end;
  16880. end;
  16881. var
  16882. _CryptFlushTimeValidObject: Pointer;
  16883. function CryptFlushTimeValidObject;
  16884. begin
  16885. GetProcedureAddress(_CryptFlushTimeValidObject, crypt32, 'CryptFlushTimeValidObject');
  16886. asm
  16887. MOV ESP, EBP
  16888. POP EBP
  16889. JMP [_CryptFlushTimeValidObject]
  16890. end;
  16891. end;
  16892. var
  16893. _CryptProtectData: Pointer;
  16894. function CryptProtectData;
  16895. begin
  16896. GetProcedureAddress(_CryptProtectData, crypt32, 'CryptProtectData');
  16897. asm
  16898. MOV ESP, EBP
  16899. POP EBP
  16900. JMP [_CryptProtectData]
  16901. end;
  16902. end;
  16903. var
  16904. _CryptUnprotectData: Pointer;
  16905. function CryptUnprotectData;
  16906. begin
  16907. GetProcedureAddress(_CryptUnprotectData, crypt32, 'CryptUnprotectData');
  16908. asm
  16909. MOV ESP, EBP
  16910. POP EBP
  16911. JMP [_CryptUnprotectData]
  16912. end;
  16913. end;
  16914. var
  16915. _CertCreateSelfSignCertificate: Pointer;
  16916. function CertCreateSelfSignCertificate;
  16917. begin
  16918. GetProcedureAddress(_CertCreateSelfSignCertificate, crypt32, 'CertCreateSelfSignCertificate');
  16919. asm
  16920. MOV ESP, EBP
  16921. POP EBP
  16922. JMP [_CertCreateSelfSignCertificate]
  16923. end;
  16924. end;
  16925. var
  16926. _CryptGetKeyIdentifierProperty: Pointer;
  16927. function CryptGetKeyIdentifierProperty;
  16928. begin
  16929. GetProcedureAddress(_CryptGetKeyIdentifierProperty, crypt32, 'CryptGetKeyIdentifierProperty');
  16930. asm
  16931. MOV ESP, EBP
  16932. POP EBP
  16933. JMP [_CryptGetKeyIdentifierProperty]
  16934. end;
  16935. end;
  16936. var
  16937. _CryptSetKeyIdentifierProperty: Pointer;
  16938. function CryptSetKeyIdentifierProperty;
  16939. begin
  16940. GetProcedureAddress(_CryptSetKeyIdentifierProperty, crypt32, 'CryptSetKeyIdentifierProperty');
  16941. asm
  16942. MOV ESP, EBP
  16943. POP EBP
  16944. JMP [_CryptSetKeyIdentifierProperty]
  16945. end;
  16946. end;
  16947. var
  16948. _CryptEnumKeyIdentProperties: Pointer;
  16949. function CryptEnumKeyIdentifierProperties;
  16950. begin
  16951. GetProcedureAddress(_CryptEnumKeyIdentProperties, crypt32, 'CryptEnumKeyIdentifierProperties');
  16952. asm
  16953. MOV ESP, EBP
  16954. POP EBP
  16955. JMP [_CryptEnumKeyIdentProperties]
  16956. end;
  16957. end;
  16958. var
  16959. _CryptCreateKeyIdentifierFromCSP: Pointer;
  16960. function CryptCreateKeyIdentifierFromCSP;
  16961. begin
  16962. GetProcedureAddress(_CryptCreateKeyIdentifierFromCSP, crypt32, 'CryptCreateKeyIdentifierFromCSP');
  16963. asm
  16964. MOV ESP, EBP
  16965. POP EBP
  16966. JMP [_CryptCreateKeyIdentifierFromCSP]
  16967. end;
  16968. end;
  16969. var
  16970. _CertCreateCertChainEngine: Pointer;
  16971. function CertCreateCertificateChainEngine;
  16972. begin
  16973. GetProcedureAddress(_CertCreateCertChainEngine, crypt32, 'CertCreateCertificateChainEngine');
  16974. asm
  16975. MOV ESP, EBP
  16976. POP EBP
  16977. JMP [_CertCreateCertChainEngine]
  16978. end;
  16979. end;
  16980. var
  16981. _CertFreeCertificateChainEngine: Pointer;
  16982. procedure CertFreeCertificateChainEngine;
  16983. begin
  16984. GetProcedureAddress(_CertFreeCertificateChainEngine, crypt32, 'CertFreeCertificateChainEngine');
  16985. asm
  16986. MOV ESP, EBP
  16987. POP EBP
  16988. JMP [_CertFreeCertificateChainEngine]
  16989. end;
  16990. end;
  16991. var
  16992. _CertResyncCertChainEngine: Pointer;
  16993. function CertResyncCertificateChainEngine;
  16994. begin
  16995. GetProcedureAddress(_CertResyncCertChainEngine, crypt32, 'CertResyncCertificateChainEngine');
  16996. asm
  16997. MOV ESP, EBP
  16998. POP EBP
  16999. JMP [_CertResyncCertChainEngine]
  17000. end;
  17001. end;
  17002. var
  17003. _CertGetCertificateChain: Pointer;
  17004. function CertGetCertificateChain;
  17005. begin
  17006. GetProcedureAddress(_CertGetCertificateChain, crypt32, 'CertGetCertificateChain');
  17007. asm
  17008. MOV ESP, EBP
  17009. POP EBP
  17010. JMP [_CertGetCertificateChain]
  17011. end;
  17012. end;
  17013. var
  17014. _CertFreeCertificateChain: Pointer;
  17015. procedure CertFreeCertificateChain;
  17016. begin
  17017. GetProcedureAddress(_CertFreeCertificateChain, crypt32, 'CertFreeCertificateChain');
  17018. asm
  17019. MOV ESP, EBP
  17020. POP EBP
  17021. JMP [_CertFreeCertificateChain]
  17022. end;
  17023. end;
  17024. var
  17025. _CertDuplicateCertificateChain: Pointer;
  17026. function CertDuplicateCertificateChain;
  17027. begin
  17028. GetProcedureAddress(_CertDuplicateCertificateChain, crypt32, 'CertDuplicateCertificateChain');
  17029. asm
  17030. MOV ESP, EBP
  17031. POP EBP
  17032. JMP [_CertDuplicateCertificateChain]
  17033. end;
  17034. end;
  17035. var
  17036. _CertFindChainInStore: Pointer;
  17037. function CertFindChainInStore;
  17038. begin
  17039. GetProcedureAddress(_CertFindChainInStore, crypt32, 'CertFindChainInStore');
  17040. asm
  17041. MOV ESP, EBP
  17042. POP EBP
  17043. JMP [_CertFindChainInStore]
  17044. end;
  17045. end;
  17046. var
  17047. _CertVerifyCertChainPolicy: Pointer;
  17048. function CertVerifyCertificateChainPolicy;
  17049. begin
  17050. GetProcedureAddress(_CertVerifyCertChainPolicy, crypt32, 'CertVerifyCertificateChainPolicy');
  17051. asm
  17052. MOV ESP, EBP
  17053. POP EBP
  17054. JMP [_CertVerifyCertChainPolicy]
  17055. end;
  17056. end;
  17057. {$ELSE}
  17058. function CryptAcquireContextA; external advapi32 name 'CryptAcquireContextA';
  17059. function CryptAcquireContextW; external advapi32 name 'CryptAcquireContextW';
  17060. function CryptAcquireContext; external advapi32 name 'CryptAcquireContext' + AWSuffix;
  17061. function CryptReleaseContext; external advapi32 name 'CryptReleaseContext';
  17062. function CryptGenKey; external advapi32 name 'CryptGenKey';
  17063. function CryptDeriveKey; external advapi32 name 'CryptDeriveKey';
  17064. function CryptDestroyKey; external advapi32 name 'CryptDestroyKey';
  17065. function CryptSetKeyParam; external crypt32 name 'CryptSetKeyParam';
  17066. function CryptGetKeyParam; external advapi32 name 'CryptGetKeyParam';
  17067. function CryptSetHashParam; external advapi32 name 'CryptSetHashParam';
  17068. function CryptGetHashParam; external advapi32 name 'CryptGetHashParam';
  17069. function CryptSetProvParam; external advapi32 name 'CryptSetProvParam';
  17070. function CryptGetProvParam; external advapi32 name 'CryptGetProvParam';
  17071. function CryptGenRandom; external advapi32 name 'CryptGenRandom';
  17072. function CryptGetUserKey; external advapi32 name 'CryptGetUserKey';
  17073. function CryptExportKey; external advapi32 name 'CryptExportKey';
  17074. function CryptImportKey; external advapi32 name 'CryptImportKey';
  17075. function CryptEncrypt; external advapi32 name 'CryptEncrypt';
  17076. function CryptDecrypt; external advapi32 name 'CryptDecrypt';
  17077. function CryptCreateHash; external advapi32 name 'CryptCreateHash';
  17078. function CryptHashData; external advapi32 name 'CryptHashData';
  17079. function CryptHashSessionKey; external advapi32 name 'CryptHashSessionKey';
  17080. function CryptDestroyHash; external advapi32 name 'CryptDestroyHash';
  17081. function CryptSignHashA; external advapi32 name 'CryptSignHashA';
  17082. function CryptSignHashW; external advapi32 name 'CryptSignHashW';
  17083. function CryptSignHash; external advapi32 name 'CryptSignHash' + AWSuffix;
  17084. function CryptVerifySignatureA; external advapi32 name 'CryptVerifySignatureA';
  17085. function CryptVerifySignatureW; external advapi32 name 'CryptVerifySignatureW';
  17086. function CryptVerifySignature; external advapi32 name 'CryptVerifySignature' + AWSuffix;
  17087. function CryptSetProviderA; external advapi32 name 'CryptSetProviderA';
  17088. function CryptSetProviderW; external advapi32 name 'CryptSetProviderW';
  17089. function CryptSetProvider; external advapi32 name 'CryptSetProvider' + AWSuffix;
  17090. function CryptSetProviderExA; external advapi32 name 'CryptSetProviderExA';
  17091. function CryptSetProviderExW; external advapi32 name 'CryptSetProviderExW';
  17092. function CryptSetProviderEx; external advapi32 name 'CryptSetProviderEx' + AWSuffix;
  17093. function CryptGetDefaultProviderA; external advapi32 name 'CryptGetDefaultProviderA';
  17094. function CryptGetDefaultProviderW; external advapi32 name 'CryptGetDefaultProviderW';
  17095. function CryptGetDefaultProvider; external advapi32 name 'CryptGetDefaultProvider' + AWSuffix;
  17096. function CryptEnumProviderTypesA; external advapi32 name 'CryptEnumProviderTypesA';
  17097. function CryptEnumProviderTypesW; external advapi32 name 'CryptEnumProviderTypesW';
  17098. function CryptEnumProviderTypes; external advapi32 name 'CryptEnumProviderTypes' + AWSuffix;
  17099. function CryptEnumProvidersA; external advapi32 name 'CryptEnumProvidersA';
  17100. function CryptEnumProvidersW; external advapi32 name 'CryptEnumProvidersW';
  17101. function CryptEnumProviders; external advapi32 name 'CryptEnumProviders' + AWSuffix;
  17102. function CryptContextAddRef; external advapi32 name 'CryptContextAddRef';
  17103. function CryptDuplicateKey; external advapi32 name 'CryptDuplicateKey';
  17104. function CryptDuplicateHash; external advapi32 name 'CryptDuplicateHash';
  17105. function CryptFormatObject; external crypt32 name 'CryptFormatObject';
  17106. function CryptEncodeObjectEx; external crypt32 name 'CryptEncodeObjectEx';
  17107. function CryptEncodeObject; external crypt32 name 'CryptEncodeObject';
  17108. function CryptDecodeObjectEx; external crypt32 name 'CryptDecodeObjectEx';
  17109. function CryptDecodeObject; external crypt32 name 'CryptDecodeObject';
  17110. function CryptInstallOIDFunctionAddress; external crypt32 name 'CryptInstallOIDFunctionAddress';
  17111. function CryptInitOIDFunctionSet; external crypt32 name 'CryptInitOIDFunctionSet';
  17112. function CryptGetOIDFunctionAddress; external crypt32 name 'CryptGetOIDFunctionAddress';
  17113. function CryptGetDefaultOIDDllList; external crypt32 name 'CryptGetDefaultOIDDllList';
  17114. function CryptGetDefaultOIDFunctionAddress; external crypt32 name 'CryptGetDefaultOIDFunctionAddress';
  17115. function CryptFreeOIDFunctionAddress; external crypt32 name 'CryptFreeOIDFunctionAddress';
  17116. function CryptRegisterOIDFunction; external crypt32 name 'CryptRegisterOIDFunction';
  17117. function CryptUnregisterOIDFunction; external crypt32 name 'CryptUnregisterOIDFunction';
  17118. function CryptRegisterDefaultOIDFunction; external crypt32 name 'CryptRegisterDefaultOIDFunction';
  17119. function CryptUnregisterDefaultOIDFunction; external crypt32 name 'CryptUnregisterDefaultOIDFunction';
  17120. function CryptSetOIDFunctionValue; external crypt32 name 'CryptSetOIDFunctionValue';
  17121. function CryptGetOIDFunctionValue; external crypt32 name 'CryptGetOIDFunctionValue';
  17122. function CryptEnumOIDFunction; external crypt32 name 'CryptEnumOIDFunction';
  17123. function CryptFindOIDInfo; external crypt32 name 'CryptFindOIDInfo';
  17124. function CryptRegisterOIDInfo; external crypt32 name 'CryptRegisterOIDInfo';
  17125. function CryptUnregisterOIDInfo; external crypt32 name 'CryptUnregisterOIDInfo';
  17126. function CryptEnumOIDInfo; external crypt32 name 'CryptEnumOIDInfo';
  17127. function CryptFindLocalizedName; external crypt32 name 'CryptFindLocalizedName';
  17128. function CryptMsgOpenToEncode; external crypt32 name 'CryptMsgOpenToEncode';
  17129. function CryptMsgCalculateEncodedLength; external crypt32 name 'CryptMsgCalculateEncodedLength';
  17130. function CryptMsgOpenToDecode; external crypt32 name 'CryptMsgOpenToDecode';
  17131. function CryptMsgDuplicate; external crypt32 name 'CryptMsgDuplicate';
  17132. function CryptMsgClose; external crypt32 name 'CryptMsgClose';
  17133. function CryptMsgUpdate; external crypt32 name 'CryptMsgUpdate';
  17134. function CryptMsgGetParam; external crypt32 name 'CryptMsgGetParam';
  17135. function CryptMsgControl; external crypt32 name 'CryptMsgControl';
  17136. function CryptMsgVerifyCountersignatureEncoded; external crypt32 name 'CryptMsgVerifyCountersignatureEncoded';
  17137. function CryptMsgVerifyCountersignatureEncodedEx; external crypt32 name 'CryptMsgVerifyCountersignatureEncodedEx';
  17138. function CryptMsgCountersign; external crypt32 name 'CryptMsgCountersign';
  17139. function CryptMsgCountersignEncoded; external crypt32 name 'CryptMsgCountersignEncoded';
  17140. function CertOpenStore; external crypt32 name 'CertOpenStore';
  17141. function CertDuplicateStore; external crypt32 name 'CertDuplicateStore';
  17142. function CertSaveStore; external crypt32 name 'CertSaveStore';
  17143. function CertCloseStore; external crypt32 name 'CertCloseStore';
  17144. function CertGetSubjectCertificateFromStore; external crypt32 name 'CertGetSubjectCertificateFromStore';
  17145. function CertEnumCertificatesInStore; external crypt32 name 'CertEnumCertificatesInStore';
  17146. function CertFindCertificateInStore; external crypt32 name 'CertFindCertificateInStore';
  17147. function CertGetIssuerCertificateFromStore; external crypt32 name 'CertGetIssuerCertificateFromStore';
  17148. function CertVerifySubjectCertificateContext; external crypt32 name 'CertVerifySubjectCertificateContext';
  17149. function CertDuplicateCertificateContext; external crypt32 name 'CertDuplicateCertificateContext';
  17150. function CertCreateCertificateContext; external crypt32 name 'CertCreateCertificateContext';
  17151. function CertFreeCertificateContext; external crypt32 name 'CertFreeCertificateContext';
  17152. function CertSetCertificateContextProperty; external crypt32 name 'CertSetCertificateContextProperty';
  17153. function CertGetCertificateContextProperty; external crypt32 name 'CertGetCertificateContextProperty';
  17154. function CertEnumCertificateContextProperties; external crypt32 name 'CertEnumCertificateContextProperties';
  17155. function CertGetCRLFromStore; external crypt32 name 'CertGetCRLFromStore';
  17156. function CertEnumCRLsInStore; external crypt32 name 'CertEnumCRLsInStore';
  17157. function CertFindCRLInStore; external crypt32 name 'CertFindCRLInStore';
  17158. function CertDuplicateCRLContext; external crypt32 name 'CertDuplicateCRLContext';
  17159. function CertCreateCRLContext; external crypt32 name 'CertCreateCRLContext';
  17160. function CertFreeCRLContext; external crypt32 name 'CertFreeCRLContext';
  17161. function CertSetCRLContextProperty; external crypt32 name 'CertSetCRLContextProperty';
  17162. function CertGetCRLContextProperty; external crypt32 name 'CertGetCRLContextProperty';
  17163. function CertEnumCRLContextProperties; external crypt32 name 'CertEnumCRLContextProperties';
  17164. function CertFindCertificateInCRL; external crypt32 name 'CertFindCertificateInCRL';
  17165. function CertAddEncodedCertificateToStore; external crypt32 name 'CertAddEncodedCertificateToStore';
  17166. function CertAddCertificateContextToStore; external crypt32 name 'CertAddCertificateContextToStore';
  17167. function CertAddSerializedElementToStore; external crypt32 name 'CertAddSerializedElementToStore';
  17168. function CertDeleteCertificateFromStore; external crypt32 name 'CertDeleteCertificateFromStore';
  17169. function CertAddEncodedCRLToStore; external crypt32 name 'CertAddEncodedCRLToStore';
  17170. function CertAddCRLContextToStore; external crypt32 name 'CertAddCRLContextToStore';
  17171. function CertDeleteCRLFromStore; external crypt32 name 'CertDeleteCRLFromStore';
  17172. function CertSerializeCertificateStoreElement; external crypt32 name 'CertSerializeCertificateStoreElement';
  17173. function CertSerializeCRLStoreElement; external crypt32 name 'CertSerializeCRLStoreElement';
  17174. function CertDuplicateCTLContext; external crypt32 name 'CertDuplicateCTLContext';
  17175. function CertCreateCTLContext; external crypt32 name 'CertCreateCTLContext';
  17176. function CertFreeCTLContext; external crypt32 name 'CertFreeCTLContext';
  17177. function CertSetCTLContextProperty; external crypt32 name 'CertSetCTLContextProperty';
  17178. function CertGetCTLContextProperty; external crypt32 name 'CertGetCTLContextProperty';
  17179. function CertEnumCTLContextProperties; external crypt32 name 'CertEnumCTLContextProperties';
  17180. function CertEnumCTLsInStore; external crypt32 name 'CertEnumCTLsInStore';
  17181. function CertFindSubjectInCTL; external crypt32 name 'CertFindSubjectInCTL';
  17182. function CertFindCTLInStore; external crypt32 name 'CertFindCTLInStore';
  17183. function CertAddEncodedCTLToStore; external crypt32 name 'CertAddEncodedCTLToStore';
  17184. function CertAddCTLContextToStore; external crypt32 name 'CertAddCTLContextToStore';
  17185. function CertSerializeCTLStoreElement; external crypt32 name 'CertSerializeCTLStoreElement';
  17186. function CertDeleteCTLFromStore; external crypt32 name 'CertDeleteCTLFromStore';
  17187. function CertAddCertificateLinkToStore; external crypt32 name 'CertAddCertificateLinkToStore';
  17188. function CertAddCRLLinkToStore; external crypt32 name 'CertAddCRLLinkToStore';
  17189. function CertAddCTLLinkToStore; external crypt32 name 'CertAddCTLLinkToStore';
  17190. function CertAddStoreToCollection; external crypt32 name 'CertAddStoreToCollection';
  17191. procedure CertRemoveStoreFromCollection; external crypt32 name 'CertRemoveStoreFromCollection';
  17192. function CertControlStore; external crypt32 name 'CertControlStore';
  17193. function CertSetStoreProperty; external crypt32 name 'CertSetStoreProperty';
  17194. function CertGetStoreProperty; external crypt32 name 'CertGetStoreProperty';
  17195. function CertCreateContext; external crypt32 name 'CertCreateContext';
  17196. function CertRegisterSystemStore; external crypt32 name 'CertRegisterSystemStore';
  17197. function CertRegisterPhysicalStore; external crypt32 name 'CertRegisterPhysicalStore';
  17198. function CertUnregisterSystemStore; external crypt32 name 'CertUnregisterSystemStore';
  17199. function CertUnregisterPhysicalStore; external crypt32 name 'CertUnregisterPhysicalStore';
  17200. function CertEnumSystemStoreLocation; external crypt32 name 'CertEnumSystemStoreLocation';
  17201. function CertEnumSystemStore; external crypt32 name 'CertEnumSystemStore';
  17202. function CertEnumPhysicalStore; external crypt32 name 'CertEnumPhysicalStore';
  17203. function CertGetEnhancedKeyUsage; external crypt32 name 'CertGetEnhancedKeyUsage';
  17204. function CertSetEnhancedKeyUsage; external crypt32 name 'CertSetEnhancedKeyUsage';
  17205. function CertAddEnhancedKeyUsageIdentifier; external crypt32 name 'CertAddEnhancedKeyUsageIdentifier';
  17206. function CertRemoveEnhancedKeyUsageIdentifier; external crypt32 name 'CertRemoveEnhancedKeyUsageIdentifier';
  17207. function CertGetValidUsages; external crypt32 name 'CertGetValidUsages';
  17208. function CryptMsgGetAndVerifySigner; external crypt32 name 'CryptMsgGetAndVerifySigner';
  17209. function CryptMsgSignCTL; external crypt32 name 'CryptMsgSignCTL';
  17210. function CryptMsgEncodeAndSignCTL; external crypt32 name 'CryptMsgEncodeAndSignCTL';
  17211. function CertFindSubjectInSortedCTL; external crypt32 name 'CertFindSubjectInSortedCTL';
  17212. function CertEnumSubjectInSortedCTL; external crypt32 name 'CertEnumSubjectInSortedCTL';
  17213. function CertVerifyCTLUsage; external crypt32 name 'CertVerifyCTLUsage';
  17214. function CertVerifyRevocation; external crypt32 name 'CertVerifyRevocation';
  17215. function CertCompareIntegerBlob; external crypt32 name 'CertCompareIntegerBlob';
  17216. function CertCompareCertificate; external crypt32 name 'CertCompareCertificate';
  17217. function CertCompareCertificateName; external crypt32 name 'CertCompareCertificateName';
  17218. function CertIsRDNAttrsInCertificateName; external crypt32 name 'CertIsRDNAttrsInCertificateName';
  17219. function CertComparePublicKeyInfo; external crypt32 name 'CertComparePublicKeyInfo';
  17220. function CertGetPublicKeyLength; external crypt32 name 'CertGetPublicKeyLength';
  17221. function CryptVerifyCertificateSignature; external crypt32 name 'CryptVerifyCertificateSignature';
  17222. function CryptVerifyCertificateSignatureEx; external crypt32 name 'CryptVerifyCertificateSignatureEx';
  17223. function CryptHashToBeSigned; external crypt32 name 'CryptHashToBeSigned';
  17224. function CryptHashCertificate; external crypt32 name 'CryptHashCertificate';
  17225. function CryptSignCertificate; external crypt32 name 'CryptSignCertificate';
  17226. function CryptSignAndEncodeCertificate; external crypt32 name 'CryptSignAndEncodeCertificate';
  17227. function CertVerifyTimeValidity; external crypt32 name 'CertVerifyTimeValidity';
  17228. function CertVerifyCRLTimeValidity; external crypt32 name 'CertVerifyCRLTimeValidity';
  17229. function CertVerifyValidityNesting; external crypt32 name 'CertVerifyValidityNesting';
  17230. function CertVerifyCRLRevocation; external crypt32 name 'CertVerifyCRLRevocation';
  17231. function CertAlgIdToOID; external crypt32 name 'CertAlgIdToOID';
  17232. function CertOIDToAlgId; external crypt32 name 'CertOIDToAlgId';
  17233. function CertFindExtension; external crypt32 name 'CertFindExtension';
  17234. function CertFindAttribute; external crypt32 name 'CertFindAttribute';
  17235. function CertFindRDNAttr; external crypt32 name 'CertFindRDNAttr';
  17236. function CertGetIntendedKeyUsage; external crypt32 name 'CertGetIntendedKeyUsage';
  17237. function CryptInstallDefaultContext; external crypt32 name 'CryptInstallDefaultContext';
  17238. function CryptUninstallDefaultContext; external crypt32 name 'CryptUninstallDefaultContext';
  17239. function CryptExportPublicKeyInfo; external crypt32 name 'CryptExportPublicKeyInfo';
  17240. function CryptExportPublicKeyInfoEx; external crypt32 name 'CryptExportPublicKeyInfoEx';
  17241. function CryptImportPublicKeyInfo; external crypt32 name 'CryptImportPublicKeyInfo';
  17242. function CryptImportPublicKeyInfoEx; external crypt32 name 'CryptImportPublicKeyInfoEx';
  17243. function CryptAcquireCertificatePrivateKey; external crypt32 name 'CryptAcquireCertificatePrivateKey';
  17244. function CryptFindCertificateKeyProvInfo; external crypt32 name 'CryptFindCertificateKeyProvInfo';
  17245. function CryptImportPKCS8; external crypt32 name 'CryptImportPKCS8';
  17246. function CryptExportPKCS8; external crypt32 name 'CryptExportPKCS8';
  17247. function CryptExportPKCS8Ex; external crypt32 name 'CryptExportPKCS8Ex';
  17248. function CryptHashPublicKeyInfo; external crypt32 name 'CryptHashPublicKeyInfo';
  17249. function CertRDNValueToStrA; external crypt32 name 'CertRDNValueToStrA';
  17250. function CertRDNValueToStrW; external crypt32 name 'CertRDNValueToStrW';
  17251. function CertRDNValueToStr; external crypt32 name 'CertRDNValueToStr' + AWSuffix;
  17252. function CertNameToStrA; external crypt32 name 'CertNameToStrA';
  17253. function CertNameToStrW; external crypt32 name 'CertNameToStrW';
  17254. function CertNameToStr; external crypt32 name 'CertNameToStr' + AWSuffix;
  17255. function CertStrToNameA; external crypt32 name 'CertStrToNameA';
  17256. function CertStrToNameW; external crypt32 name 'CertStrToNameW';
  17257. function CertStrToName; external crypt32 name 'CertStrToName' + AWSuffix;
  17258. function CertGetNameStringA; external crypt32 name 'CertGetNameStringA';
  17259. function CertGetNameStringW; external crypt32 name 'CertGetNameStringW';
  17260. function CertGetNameString; external crypt32 name 'CertGetNameString' + AWSuffix;
  17261. function CryptSignMessage; external crypt32 name 'CryptSignMessage';
  17262. function CryptVerifyMessageSignature; external crypt32 name 'CryptVerifyMessageSignature';
  17263. function CryptGetMessageSignerCount; external crypt32 name 'CryptGetMessageSignerCount';
  17264. function CryptGetMessageCertificates; external crypt32 name 'CryptGetMessageCertificates';
  17265. function CryptVerifyDetachedMessageSignature; external crypt32 name 'CryptVerifyDetachedMessageSignature';
  17266. function CryptEncryptMessage; external crypt32 name 'CryptEncryptMessage';
  17267. function CryptDecryptMessage; external crypt32 name 'CryptDecryptMessage';
  17268. function CryptSignAndEncryptMessage; external crypt32 name 'CryptSignAndEncryptMessage';
  17269. function CryptDecryptAndVerifyMessageSignature; external crypt32 name 'CryptDecryptAndVerifyMessageSignature';
  17270. function CryptDecodeMessage; external crypt32 name 'CryptDecodeMessage';
  17271. function CryptHashMessage; external crypt32 name 'CryptHashMessage';
  17272. function CryptVerifyMessageHash; external crypt32 name 'CryptVerifyMessageHash';
  17273. function CryptVerifyDetachedMessageHash; external crypt32 name 'CryptVerifyDetachedMessageHash';
  17274. function CryptSignMessageWithKey; external crypt32 name 'CryptSignMessageWithKey';
  17275. function CryptVerifyMessageSignatureWithKey; external crypt32 name 'CryptVerifyMessageSignatureWithKey';
  17276. function CertOpenSystemStoreA; external crypt32 name 'CertOpenSystemStoreA';
  17277. function CertOpenSystemStoreW; external crypt32 name 'CertOpenSystemStoreW';
  17278. function CertOpenSystemStore; external crypt32 name 'CertOpenSystemStore' + AWSuffix;
  17279. function CertAddEncodedCertificateToSystemStoreA; external crypt32 name 'CertAddEncodedCertificateToSystemStoreA';
  17280. function CertAddEncodedCertificateToSystemStoreW; external crypt32 name 'CertAddEncodedCertificateToSystemStoreW';
  17281. function CertAddEncodedCertificateToSystemStore; external crypt32 name 'CertAddEncodedCertificateToSystemStore' + AWSuffix;
  17282. function FindCertsByIssuer; external softpub name 'FindCertsByIssuer';
  17283. function CryptQueryObject; external crypt32 name 'CryptQueryObject';
  17284. function CryptMemAlloc; external crypt32 name 'CryptMemAlloc';
  17285. function CryptMemRealloc; external crypt32 name 'CryptMemRealloc';
  17286. procedure CryptMemFree; external crypt32 name 'CryptMemFree';
  17287. function CryptCreateAsyncHandle; external crypt32 name 'CryptCreateAsyncHandle';
  17288. function CryptSetAsyncParam; external crypt32 name 'CryptSetAsyncParam';
  17289. function CryptGetAsyncParam; external crypt32 name 'CryptGetAsyncParam';
  17290. function CryptCloseAsyncHandle; external crypt32 name 'CryptCloseAsyncHandle';
  17291. function CryptRetrieveObjectByUrlA; external crypt32 name 'CryptRetrieveObjectByUrlA';
  17292. function CryptRetrieveObjectByUrlW; external crypt32 name 'CryptRetrieveObjectByUrlW';
  17293. function CryptRetrieveObjectByUrl; external crypt32 name 'CryptRetrieveObjectByUrl' + AWSuffix;
  17294. function CryptInstallCancelRetrieval; external crypt32 name 'CryptInstallCancelRetrieval';
  17295. function CryptUninstallCancelRetrieval; external crypt32 name 'CryptUninstallCancelRetrieval';
  17296. function CryptCancelAsyncRetrieval; external crypt32 name 'CryptCancelAsyncRetrieval';
  17297. function CryptGetObjectUrl; external crypt32 name 'CryptGetObjectUrl';
  17298. function CryptGetTimeValidObject; external crypt32 name 'CryptGetTimeValidObject';
  17299. function CryptFlushTimeValidObject; external crypt32 name 'CryptFlushTimeValidObject';
  17300. function CryptProtectData; external crypt32 name 'CryptProtectData';
  17301. function CryptUnprotectData; external crypt32 name 'CryptUnprotectData';
  17302. function CertCreateSelfSignCertificate; external crypt32 name 'CertCreateSelfSignCertificate';
  17303. function CryptGetKeyIdentifierProperty; external crypt32 name 'CryptGetKeyIdentifierProperty';
  17304. function CryptSetKeyIdentifierProperty; external crypt32 name 'CryptSetKeyIdentifierProperty';
  17305. function CryptEnumKeyIdentifierProperties; external crypt32 name 'CryptEnumKeyIdentifierProperties';
  17306. function CryptCreateKeyIdentifierFromCSP; external crypt32 name 'CryptCreateKeyIdentifierFromCSP';
  17307. function CertCreateCertificateChainEngine; external crypt32 name 'CertCreateCertificateChainEngine';
  17308. procedure CertFreeCertificateChainEngine; external crypt32 name 'CertFreeCertificateChainEngine';
  17309. function CertResyncCertificateChainEngine; external crypt32 name 'CertResyncCertificateChainEngine';
  17310. function CertGetCertificateChain; external crypt32 name 'CertGetCertificateChain';
  17311. procedure CertFreeCertificateChain; external crypt32 name 'CertFreeCertificateChain';
  17312. function CertDuplicateCertificateChain; external crypt32 name 'CertDuplicateCertificateChain';
  17313. function CertFindChainInStore; external crypt32 name 'CertFindChainInStore';
  17314. function CertVerifyCertificateChainPolicy; external crypt32 name 'CertVerifyCertificateChainPolicy';
  17315. {$ENDIF DYNAMIC_LINK}
  17316. end.